Skip to content
Snippets Groups Projects
Commit a9959895 authored by francois's avatar francois
Browse files

corrected TSL2561 detection with latest i2c primitives from neOCampus

parent e4819d38
Branches
No related tags found
No related merge requests found
......@@ -337,7 +337,7 @@ bool SCD4x::_readSensor( void ) {
status = true;
// DEBUG
hex_dump( (char*)buf, sizeof(buf) );
//hex_dump( (char*)buf, sizeof(buf) );
//break;
// CO2 + CRC
......
......@@ -33,6 +33,8 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@history
F.Thiebolt mar.22 switch to newer i2c primitives that better match TSL2561
communications requirements.
2017 - mostly rewritten for neOCampus
*/
......@@ -209,30 +211,29 @@ void TSL2561::_powerOFF( uint8_t a ) {
*/
bool TSL2561::_check_identity( uint8_t a ) {
uint8_t res, data;
// stop'n start device
_powerOFF(a); delay(10);
data = (uint8_t)(-1);
res = readList( a, (uint8_t)(TSL2561_COMMAND_BIT | TSL2561_CLEAR_BIT | TSL2561_REGISTER_CONTROL), &data, 1 );
if( !res ) return false;
//log_debug(F("\n[TSL2561] REGISTER_CONTROL = 0x"));log_debug(data,HEX);log_flush();
if( (data&0x03)!=0x00 ) return false;
_powerON(a); delay(10);
data = (uint8_t)(-1);
res = readList( a, (uint8_t)(TSL2561_COMMAND_BIT | TSL2561_CLEAR_BIT | TSL2561_REGISTER_CONTROL), &data, 1 );
if( !res ) return false;
//log_debug(F("\n[TSL2561] REGISTER_CONTROL = 0x"));log_debug(data,HEX);log_flush();
if( (data&0x03)!=0x03 ) return false;
// check Register ID
Wire.beginTransmission(a);
Wire.write((uint8_t)(TSL2561_COMMAND_BIT | TSL2561_CLEAR_BIT | TSL2561_REGISTER_CONTROL));
Wire.beginTransmission(a);
Wire.requestFrom(a, (uint8_t)1);
TO BE CONTINUED
else yield();
uint8_t i=0;
while( Wire.available() and (i < tabsize) ) {
tab[i++] = Wire.read();
}
Wire.endTransmission();
TO BE CONTINUED
uint8_t _res = read8(a,TSL2561_REGISTER_ID);
if( (_res&0xF0)!=REGISTER_ID_TSL2561 and (_res&0xF0)!=0x00 ) return false;
data = (uint8_t)(-1);
res = readList( a, (uint8_t)(TSL2561_COMMAND_BIT | TSL2561_CLEAR_BIT | TSL2561_REGISTER_ID), &data, 1 );
if( !res ) return false;
//log_debug(F("\n[TSL2561] REGISTER_ID = 0x"));log_debug(data,HEX);log_flush();
if( (data&0xF0)!=REGISTER_ID_TSL2561 and !(data&0xF0) ) return false;
return true;
}
......
......@@ -99,7 +99,7 @@ void PMS::passiveMode()
void PMS::requestRead()
{
if (_mode == MODE_PASSIVE) {
// uint8_t command[] = { 0x11, 0x01, 0x02, 0xEC }; // [PREFIX] [nb_octets] [code_command] [checksum]
//uint8_t command[] = { 0x11, 0x01, 0x02, 0xEC }; // [PREFIX] [nb_octets] [code_command] [checksum]
uint8_t command[] = { 0x11, 0x02, 0x0b, 0x01, 0xE1 }; // [PREFIX] [nb_octets] [code_command] [checksum]
_stream->write(command, sizeof(command));
}
......@@ -202,7 +202,7 @@ void PMS::loop()
/* Declarations */
//#define DEBUG_SERIAL
#define DEBUG_SERIAL
#define PM_PASSIVE_MODE 1 // PASSIVE vs ACTIVE modes
#define PM_POWER_SAVING 1 // enable sleep() wakeUp() cycles to save power
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment