OLA not able to log two PHT-MS8607 via Qwiic mux

Hi

I’m trying to log PHT data from two MS8607 sensors (inside/outside enclosure) connected to the OLA via the qwiic mux. Both sensors are detected and send data, but the data appears to be uncalibrated for at least one sensor. I’ve done some testing with a RedBoard Qwiic and manage to reproduce the data if I connect one sensor directly and run the basic example from the MS8607 arduino example library. If I then hot swap the sensors, the data will be off (up or down) until I hit reset and the sensor calibration is read again. Finally I manage to get good data from both sensors via mux (running mux example sketch) if I initialize the sensors before each read (ie. run begin() in the loop, not in setup).

Is there any way to make the OLA hold calibration data (or reinitialize continously) for two PHT-MS8607 sensors?

OLA debug info showing one sensor reading 16,16 degrees and one reading 22,40 on my desk:

Artemis OpenLog v1.8
Logging to: dataLog00026.TXT
Finding the next available log file.
This could take a long time if the SD card contains many existing log files.
Logging to: serialLog00000.TXT
SD card online
Data logging online
Serial logging online
IMU online
detectQwiicDevices started
Identifying Qwiic Muxes…
detectQwiicDevices: something detected at address 0x70
detectQwiicDevices: multiplexer found at address 0x70
detectQwiicDevices: found 1 multiplexer
beginQwiicDevices: attempting to begin deviceType Multiplexer at address 0x70 using mux address 0x00 and port number 0
beginQwiicDevices: device is online
Identifying Qwiic Devices…
detectQwiicDevices: something detected at address 0x70
Multiplexers found. Scanning sub nets…
detectQwiicDevices: scanning the ports of multiplexer 0
detectQwiicDevices: scanning port number 0 on multiplexer 0
detectQwiicDevices: added PHT-MS8607 at address 0x40.0x70.0
detectQwiicDevices: skipping device address 0x70 because we found one on the main branch
detectQwiicDevices: scanning port number 1 on multiplexer 0
detectQwiicDevices: added PHT-MS8607 at address 0x40.0x70.1
detectQwiicDevices: skipping device address 0x70 because we found one on the main branch
detectQwiicDevices: scanning port number 2 on multiplexer 0
detectQwiicDevices: skipping device address 0x70 because we found one on the main branch
detectQwiicDevices: scanning port number 3 on multiplexer 0
detectQwiicDevices: skipping device address 0x70 because we found one on the main branch
detectQwiicDevices: scanning port number 4 on multiplexer 0
detectQwiicDevices: skipping device address 0x70 because we found one on the main branch
detectQwiicDevices: scanning port number 5 on multiplexer 0
detectQwiicDevices: skipping device address 0x70 because we found one on the main branch
detectQwiicDevices: scanning port number 6 on multiplexer 0
detectQwiicDevices: skipping device address 0x70 because we found one on the main branch
detectQwiicDevices: scanning port number 7 on multiplexer 0
detectQwiicDevices: skipping device address 0x70 because we found one on the main branch
Autodetect complete
beginQwiicDevices: attempting to begin deviceType PHT-MS8607 at address 0x40 using mux address 0x70 and port number 0
beginQwiicDevices: device is online
beginQwiicDevices: attempting to begin deviceType PHT-MS8607 at address 0x40 using mux address 0x70 and port number 1
beginQwiicDevices: device is online
beginQwiicDevices: attempting to begin deviceType Multiplexer at address 0x70 using mux address 0x00 and port number 0
beginQwiicDevices: device is online
PHT-MS8607 online at address 0x40.0x70.0
PHT-MS8607 online at address 0x40.0x70.1
Multiplexer online at address 0x70
Device count: 3
rtcDate,rtcTime,aX,aY,aZ,gX,gY,gZ,mX,mY,mZ,imu_degC,humidity_%,hPa,degC,humidity_%,hPa,degC,output_Hz,
01/01/2000,00:01:05.33,-208.50,-47.36,-994.63,-1.13,-2.33,1.27,-6.45,0.15,-117.45,27.79,46.12,984.49,16.16,47.11,991.54,22.40,8.77,

Hi @kaarejor,

Great detective work! Thanks for reporting this. I have logged it here:

https://github.com/sparkfun/OpenLog_Artemis/issues/62

I will see if I can replicate this. I don’t think I have two MS8607’s so it may take me some time…

Best wishes,

Paul

Hi

After trying a ton of workarounds, I ended up adding a begin() before every reading of MS8607 in the v1.8 firmware, and it seems to give good data. This is probably an ugly hack, but now I can go on with my project.

Best regards

Nice detective work @kaarejor - thanks for letting us know!

I haven’t figured this one out yet. I’m trying to figure out how one of the two sensors can end up ‘uninitialized’. I’ll keep looking…

All the best,

Paul

In SparkFun_PHT_MS8607_Arduino_Library.cpp there is a global instance of eeprom_coeff and MS8607_pressure_resolution psensor_resolution_osr. These would be shared by multiple instances of the device, so they would get loaded from the last one that had the .begin() call. This may be the issue.

/mike

Good thinking Mike! I’ll have a good hard look at the linked-list code. Each instance will need its own parameters - I’ll need to make sure that happens.

Many thanks,

Paul

I have seen that before - we really shouldn’t use global variables in libraries so that the class can be instantiated multiple times. Using private variables in the class would keep them separate for each instance.

/mike

Hi @kaarejor,

Mike (@n1ist ) was completely correct - thanks Mike. More details are here:

https://github.com/sparkfun/OpenLog_Artemis/issues/62

I’ll update the MS8607 library and include the new library in version 1.9 of the firmware.

Cheers,

Paul