Skip to content
Snippets Groups Projects
Commit cb14b03d authored by thiebolt's avatar thiebolt
Browse files

added temperature support for SCD4x

parent deb916df
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
*/ */
#define BOARD_NAME "neOSensor" #define BOARD_NAME "neOSensor"
#define BOARD_REVISION 1.2 #define BOARD_REVISION 1.2
#define BOARD_FWREV 211129 // Firmware revision <year><month><day> in 2 digits each #define BOARD_FWREV 220314 // Firmware revision <year><month><day> in 2 digits each
/* ############################################################################# /* #############################################################################
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
@section HISTORY @section HISTORY
F.Thiebolt mar.22 added early detection support to distinguish with
newer SCD4x (0x62) chips
2017-July - F.Thiebolt Initial release 2017-July - F.Thiebolt Initial release
*/ */
...@@ -52,10 +54,14 @@ boolean MCP47X6::is_device( uint8_t a ) { ...@@ -52,10 +54,14 @@ boolean MCP47X6::is_device( uint8_t a ) {
if( found == false ) return false; if( found == false ) return false;
/* /*
* UNABLE to read MCP47X6 devices because of the specific I2C protocol that does not match * WARNING: custom I2C reading !!!
* those used at arduino :( * We'll ONLY read ONE byte (we don't care about the others)
*/ */
// unable to read anything so we assume it is ok :s #warning "Please confirm MCP47X06 eading code"
uint8_t status,_res;
_res = readList_ll( a, &status, 1);
if( _res!=1 ) return false;
if( (status & 0xE0) != (uint8_t)0xC0 ) return false;
// ... okay // ... okay
return true; return true;
......
...@@ -33,13 +33,22 @@ ...@@ -33,13 +33,22 @@
#include "SCD4x.h" #include "SCD4x.h"
/*
* Definitions
* Time to obtain a new data point = _MAX_MEASURES * (5s or 30s) if periodic or low-power periodic)
*/
#define _MEASURES_INTERLEAVE_MS DEFL_READ_MSINTERVAL // delay between two measures in the 'measuring' state
#define _MAX_MEASURES 3 // max. number of measures during a single campaign
//#define _MAX_MEASURES DEFL_THRESHOLD_CPT // max. number of measures during a single campaign
/**************************************************************************/ /**************************************************************************/
/*! /*!
@brief Declare list of possible I2C addrs @brief Declare list of possible I2C addrs
*/ */
/**************************************************************************/ /**************************************************************************/
const uint8_t SCD4x::i2c_addrs[] = { 0x69 }; const uint8_t SCD4x::i2c_addrs[] = { 0x62 };
/* [static] declare kind of units */ /* [static] declare kind of units */
...@@ -91,7 +100,8 @@ boolean SCD4x::is_device( uint8_t a ) { ...@@ -91,7 +100,8 @@ boolean SCD4x::is_device( uint8_t a ) {
@brief Instantiates a new class @brief Instantiates a new class
*/ */
/**************************************************************************/ /**************************************************************************/
SCD4x::SCD4x( scd4xMeasureType_t kindness ) : generic_driver() { SCD4x::SCD4x( scd4xMeasureType_t kindness ) : generic_driver( _MEASURES_INTERLEAVE_MS,
_MAX_MEASURES ) {
_i2caddr = -1; _i2caddr = -1;
_measureType = kindness; _measureType = kindness;
} }
...@@ -323,7 +333,7 @@ bool SCD4x::_readSensor( void ) { ...@@ -323,7 +333,7 @@ bool SCD4x::_readSensor( void ) {
// DEBUG // DEBUG
hex_dump( (char*)buf, sizeof(buf) ); hex_dump( (char*)buf, sizeof(buf) );
break; //break;
// CO2 + CRC // CO2 + CRC
if( crc_check(buf, 2, buf[2]) ) { if( crc_check(buf, 2, buf[2]) ) {
...@@ -504,8 +514,8 @@ bool SCD4x::_check_identity( uint8_t a ) { ...@@ -504,8 +514,8 @@ bool SCD4x::_check_identity( uint8_t a ) {
} }
// DEBUG // DEBUG
hex_dump( (char*)buf, sizeof(buf) ); //hex_dump( (char*)buf, sizeof(buf) );
break; //break;
// check answer's CRC // check answer's CRC
if( not crc_check(buf, 2, buf[2]) ) { if( not crc_check(buf, 2, buf[2]) ) {
...@@ -526,8 +536,8 @@ bool SCD4x::_check_identity( uint8_t a ) { ...@@ -526,8 +536,8 @@ bool SCD4x::_check_identity( uint8_t a ) {
// DISPLAY retrieved serial number :) // DISPLAY retrieved serial number :)
{ {
char tmp[48]; char tmp[64];
snprintf(tmp, sizeof(tmp),"\n[SCD4x] serial number = 0x%02X%02X %02X%02X %02X%02X", snprintf(tmp, sizeof(tmp),"\n[SCD4x] detected serial number = 0x%02X%02X %02X%02X %02X%02X",
buf[7],buf[6],buf[4],buf[3],buf[1],buf[0]); buf[7],buf[6],buf[4],buf[3],buf[1],buf[0]);
log_debug(tmp); log_flush(); log_debug(tmp); log_flush();
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* TODO: * TODO:
* - convert all 'frequency' parameters & define into 'cooldown' ones * - convert all 'frequency' parameters & define into 'cooldown' ones
* --- * ---
* F.Thiebolt mar.22 add support for SCD4x sensor
* F.Thiebolt aug.20 switched to intelligent data sending vs timer based data sending * F.Thiebolt aug.20 switched to intelligent data sending vs timer based data sending
* Thiebolt.F nov.20 previous 'force data as float' didn't work! we need to * Thiebolt.F nov.20 previous 'force data as float' didn't work! we need to
* use serialized(String(1.0,6)); // 1.000000 * use serialized(String(1.0,6)); // 1.000000
...@@ -128,6 +129,21 @@ boolean temperature::add_sensor( uint8_t adr ) { ...@@ -128,6 +129,21 @@ boolean temperature::add_sensor( uint8_t adr ) {
_sensor_added=true; _sensor_added=true;
} }
} }
// check for SHT3x
else if( SCD4x::is_device( adr ) == true ) {
SCD4x *cur_sensor = new SCD4x( scd4xMeasureType_t::temperature ); // because it features several sensors
if( cur_sensor->begin( adr ) != true ) {
log_debug(F("\n[temperature] ###ERROR at SCD4x startup ... removing instance ..."));log_flush();
free(cur_sensor);
cur_sensor = NULL;
}
else {
cur_sensor->powerON(); // remember that device is shared across several modules
cur_sensor->powerOFF(); // remember that device is shared across several modules
_sensor[_sensors_count++] = cur_sensor;
_sensor_added=true;
}
}
//else if( TCN75A::is_device( adr ) == true ) { //else if( TCN75A::is_device( adr ) == true ) {
// add check for additional device here // add check for additional device here
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "Adafruit_MCP9808.h" #include "Adafruit_MCP9808.h"
#include "SHT2x.h" #include "SHT2x.h"
#include "SHT3x.h" #include "SHT3x.h"
#include "SCD4x.h" // Sensirion SCD4X CO2 sensor including temp + hygro
//#include "TCN75A.h" later maybe //#include "TCN75A.h" later maybe
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment