I have a Photon running with the Particle battery shield attached.
Reading the SOC (state-of-charge) of the LiPo threw the shield works totally fine.
When trying to read values from a DHT11 sensor module - a three pin one with a resistor build in - the humidity/temperature values as well as the SOC measurements are garbage (NAN or 255).
The wiring is pretty simple:
- DHT VCC is attached to Particle D0
- DHT DATA is attached to Particle D1
- DHT GND is attached to Particle GND
Removing the VCC wire to the DHT results in correct battery gauge values.
Also not initializing I2C via lipo.begin() leads to correct DHT measurements.
How can I read both SOC and DHT values at the same time? Thanks
#include <Adafruit_DHT.h>
#include <SparkFunMAX17043.h>
const int DHT_POWER = D0;
const int DHT_DATA = D1;
DHT dht(DHT_DATA, DHT11);
void setupSerial() {
Serial.begin(9600);
}
void setupDHT() {
pinMode(DHT_POWER, OUTPUT);
digitalWrite(DHT_POWER, HIGH);
pinMode(DHT_DATA, INPUT);
}
void setupLipo() {
lipo.begin();
}
void setup() {
setupSerial();
setupDHT();
setupLipo();
}
void printMeasurements() {
Serial.printlnf("humidity: %.2f", dht.getHumidity());
Serial.printlnf("temperature: %.2f", dht.getTempCelcius());
lipo.quickStart(); // restarts the MAX17043 chip to get more accurate results for SOC
Serial.printlnf("battery charge: %.2f", lipo.getSOC());
}
void loop() {
printMeasurements();
delay(1000);
}