Thanks for all the great responses.
I actually figure it out. I knew that my sensors were working because I could get the same code to work when using a ESP8266. I'm currently using GPIO25 for my 5 DS18B20 temperature sensors and I'm also using a 4.7 Ohm resistor as suggested by Dallas. At first, I could not see any sensor. After some thinkering, I was able to get the mac addresses of all 5 sensors with the Atom Lite but the temperature was ALWAYS 85. Googling for 85, someone said that we have to wait 750 ms after calling sensors.requestTemperatures();
sensors.requestTemperatures();
delay(750); // This seems critical to get the sensors to work with AtomLite
Then I can proceed to get the temperatures like so. Note that this only illustrates the spirit of what needs to be done and I haven't tested the exact code that follows.
#include <M5Atom.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// GPIO where the DS18B20 is connected to
const uint8_t oneWireBus = GPIO_NUM_25;
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
void setup() {
M5.begin(true, false, true); // But I need to test without this line.
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
delay(750); // This seems critical to get the sensors to work with AtomLite
const unsigned int num_DS18B20 = sensors.getDeviceCount();
for (unsigned int i=0; i<num_DS18B20; ++i) {
DeviceAddress mac;
sensors.getAddress(mac, i);
delay(10);
const float temperature = sensors.getTempCByIndex(i);
send_MQTT(mac, temperature);
}
}
delay(10000);
}
I hope that this information will be useful for someone else trying to hookup some DS18B20 to an Atom Lite.