Dallas18B20 begin causes reset [solved]
-
I have connected a single DS18B20 as described on https://www.mysensors.org/build/temp (including the 4.7kohm pullup)
When I call sensor.begin, the Pro Mini resets.
With a before function looking like this I get "proof" that the node dies on begin:
void before() { // Startup up the OneWire library Serial.println("Calling begin"); Serial.flush(); sensors.begin(); Serial.println("Begin was OK"); sensors.requestTemperatures(); Serial.println("request returned"); Serial.println(sensors.getTempCByIndex(0)); }
Debug:
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 4 MCO:BGN:BFR Calling begin 0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 4 MCO:BGN:BFR Calling begin 0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 4 MCO:BGN:BFR Calling begin 0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 4 MCO:BGN:BFR Calling begin 0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 4 MCO:BGN:BFR Calling begin 0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
- I have tried two different DS18B20 sensors. No difference.
- If I disconnect the data pin, begin returns and all temperature readings return -127.00C, as expected.
- If I disconnect the GND pin (and re-connect the data pin), begin returns and all temperature readings return -127.00C, as expected.
- I have tried using the bare DS18B20 library (without MySensors) and get the same result.
Any idea what could be wrong or what I could do to troubleshoot this?
-
Try to call
Serial.flush();
after each print line, this ensures that all data sent to serial port before next line executed.
Can you post image with connection wires to DS18B20 sensor? Could the problem be that this chip is a fake?
-
Thanks @robosensor
I decided to re-do all wiring to make a clear photo. When I did that I realized that I had connected GND on the DS18B20 to the reset pin on the Pro Mini.
No wonder the mcu was reset when communication occurred on the onewire bus.
-
This post is deleted!