Skip to content

Commit

Permalink
Adding a fix to make sure the MS8607 is detected correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulZC committed Nov 27, 2020
1 parent a602ac6 commit 1afaa12
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Firmware/OpenLog_Artemis/OpenLog_Artemis.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
This firmware runs the OpenLog Artemis. A large variety of system settings can be
adjusted by connecting at 115200bps.
The Board should be set to SparkFun Apollo3 \ SparkFun RedBoard Artemis ATP.
v1.0 Power Consumption:
Sleep between reads, RTC fully charged, no Qwiic, SD, no USB, no Power LED: 260uA
10Hz logging IMU, no Qwiic, SD, no USB, no Power LED: 9-27mA
Expand Down Expand Up @@ -69,10 +71,11 @@
(done) Add support for the MPRLS0025PA micro pressure sensor
(done) Add support for the SN-GCJA5 particle sensor
(done) Add IMU accelerometer and gyro full scale and digital low pass filter settings to menuIMU
(done) Add a fix to make sure the MS8607 is detected correctly: https://github.com/sparkfun/OpenLog_Artemis/issues/54
*/

const int FIRMWARE_VERSION_MAJOR = 1;
const int FIRMWARE_VERSION_MINOR = 7;
const int FIRMWARE_VERSION_MINOR = 8;

//Define the OLA board identifier:
// This is an int which is unique to this variant of the OLA and which allows us
Expand All @@ -82,7 +85,7 @@ const int FIRMWARE_VERSION_MINOR = 7;
// the variant * 0x100 (OLA = 1; GNSS_LOGGER = 2; GEOPHONE_LOGGER = 3)
// the major firmware version * 0x10
// the minor firmware version
#define OLA_IDENTIFIER 0x117 // Stored as 279 decimal in OLA_settings.txt
#define OLA_IDENTIFIER 0x118 // Stored as 280 decimal in OLA_settings.txt

#include "settings.h"

Expand Down
47 changes: 47 additions & 0 deletions Firmware/OpenLog_Artemis/autoDetect.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,7 @@ deviceType_e testDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portNumb

//Given an address, returns the device type if it responds as we would expect
//This version is dedicated to testing muxes and uses a custom .begin to avoid the slippery mux problem
//However, we also need to check if an MS8607 is attached (address 0x76) as it can cause the I2C bus to lock up if not detected correctly
deviceType_e testMuxDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portNumber)
{
switch (i2cAddress)
Expand All @@ -1283,7 +1284,53 @@ deviceType_e testMuxDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portN
case 0x73:
case 0x74:
case 0x75:
{
//Ignore devices we've already recorded. This was causing the mux to get tested, a begin() would happen, and the mux would be reset.
if (deviceExists(DEVICE_MULTIPLEXER, i2cAddress, muxAddress, portNumber) == true) return (DEVICE_MULTIPLEXER);

//Confidence: Medium - Write/Read/Clear to 0x00
if (multiplexerBegin(i2cAddress, qwiic) == true) //Address, Wire port
return (DEVICE_MULTIPLEXER);
}
break;
case 0x76:
{
//Ignore devices we've already recorded. This was causing the mux to get tested, a begin() would happen, and the mux would be reset.
if (deviceExists(DEVICE_MULTIPLEXER, i2cAddress, muxAddress, portNumber) == true) return (DEVICE_MULTIPLEXER);

// If an MS8607 is connected, multiplexerBegin causes the MS8607 to 'crash' and lock up the I2C bus... So we need to check if an MS8607 is connected first.
// We will use the MS5637 as this will test for itself and the pressure sensor of the MS8607
// Just to make life even more complicated, a mux with address 0x76 will also appear as an MS5637 due to the way the MS5637 eeprom crc check is calculated.
// So, we can't use .begin as the test for a MS5637 / MS8607. We need to be more creative!
// If we write 0xA0 to i2cAddress and then read two bytes:
// A mux will return 0xA0A0
// An MS5637 / MS8607 will return the value stored in its eeprom which _hopefully_ is not 0xA0A0!

// Let's hope this doesn't cause problems for the BME280...! We should be OK as the default address for the BME280 is 0x77.

qwiic.beginTransmission((uint8_t)i2cAddress);
qwiic.write((uint8_t)0xA0);
uint8_t i2c_status = qwiic.endTransmission();

if (i2c_status == 0) // If the I2C write was successful
{
qwiic.requestFrom((uint8_t)i2cAddress, 2U); // Read two bytes
uint8_t buffer[2];
for (uint8_t i = 0; i < 2; i++)
{
buffer[i] = qwiic.read();
}
if ((buffer[0] != 0xA0) || (buffer[1] != 0xA0)) // If we read back something other than 0xA0A0 then we are probably talking to an MS5637 / MS8607, not a mux
{
return (DEVICE_PRESSURE_MS5637);
}
}

//Confidence: Medium - Write/Read/Clear to 0x00
if (multiplexerBegin(i2cAddress, qwiic) == true) //Address, Wire port
return (DEVICE_MULTIPLEXER);
}
break;
case 0x77:
{
//Ignore devices we've already recorded. This was causing the mux to get tested, a begin() would happen, and the mux would be reset.
Expand Down
6 changes: 6 additions & 0 deletions Firmware/OpenLog_Artemis/menuAttachedDevices.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool detectQwiicDevices()

//First scan for Muxes. Valid addresses are 0x70 to 0x77 (112 to 119).
//If any are found, they will be begin()'d causing their ports to turn off
//testMuxDevice will check if an MS8607 is attached (address 0x76) as it can cause the I2C bus to lock up if we try to detect it as a mux
uint8_t muxCount = 0;
for (uint8_t address = 0x70 ; address < 0x78 ; address++)
{
Expand All @@ -73,6 +74,11 @@ bool detectQwiicDevices()
Serial.printf("detectQwiicDevices: multiplexer found at address 0x%02X\r\n", address);
muxCount++;
}
else if (foundType == DEVICE_PRESSURE_MS5637)
{
if (settings.printDebugMessages == true)
Serial.printf("detectQwiicDevices: MS8607/MS5637 found at address 0x%02X. Ignoring it for now...\r\n", address);
}
}
}

Expand Down

0 comments on commit 1afaa12

Please sign in to comment.