Skip to content

Commit

Permalink
inprove check for RAK12035VBSOIL Sensor by checking device registry f…
Browse files Browse the repository at this point in the history
…or expected values..
  • Loading branch information
Justin-Mann committed Dec 2, 2024
1 parent 3aed9e6 commit c9abb81
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,16 @@
"cmake.configureOnOpen": false,
"[cpp]": {
"editor.defaultFormatter": "trunk.io"
},
"files.associations": {
"array": "cpp",
"chrono": "cpp",
"functional": "cpp",
"istream": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp"
}
}
34 changes: 11 additions & 23 deletions src/detect/ScanI2CTwoWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,33 +291,21 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)

case RAK12035VB_ADDR: // (0x20) can be RAK12023VB Soil Sensor or TCA9535 I2C expander

// check if it is a RAK12035, if not can assume it is a TCA9535 I2C expander
// registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x20), 1); // get ID
// if (registerValue == 0xC0) {
// type = RAK12035VB;
// LOG_INFO("RAK12035VB Soil Sensor found");
// } else {
//#ifdef RAK4631
// type = NCP5623;
// logFoundDevice("NCP5623", (uint8_t)addr.address);
//#endif
// type = TCA9535;
// LOG_INFO("TCA9535 I2C expander found\n");
// }
// break;

// ^^^^^^^^^^^ not working... so we will just assume it is a RAK12035VB Soil Sensor so I can keep testing.
#ifdef RAK4631
// Check if it is a RAK12035, if not can assume it is a TCA9535 I2C expander
// additional info about registry values can be found here [https://github.com/RAKWireless/RAK12035_SoilMoisture/blob/main/RAK12035_SoilMoisture.h]
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x02), 1); // get the default address for the device (stored in registry here [0x02]).. should come back as 0x20
LOG_INFO("Checking for RAK12035VB Soil Sensor with registry address 0x02...");
if (registerValue == 0x20) {
LOG_INFO("Found registry value 0x%x", registerValue);
type = RAK12035VB;
LOG_INFO("RAK12035VB Soil Sensor found");
#endif
} else {
LOG_INFO("Found registry value 0x%x", registerValue);
type = TCA9535;
LOG_INFO("TCA9535 I2C expander found\n");
}
break;






case MCP9808_ADDR:
// We need to check for STK8BAXX first, since register 0x07 is new data flag for the z-axis and can produce some
// weird result. and register 0x00 doesn't seems to be colliding with MCP9808 and LIS3DH chips.
Expand Down

0 comments on commit c9abb81

Please sign in to comment.