Page 1 of 1

Sparkfun ESP32 Thing with DS18b20 not working

Posted: Wed Jan 30, 2019 4:41 am
by kenglover
Hello everyone,
Thanks for the great work on MicroPython.

I am trying to get temperature readings working using a ds18b20 using a Sparkfun ESP32 Thing board. It was working when using Arduino, but when I change over to MicroPythod it always returns 85 (indicates error).

I am using the most recent release v1.10 and have even tried building it myself from source.

My code is:
[code]
import time
import machine, onewire
import ds18x20

# the device is on GPIO19
dat = machine.Pin(19)

# create the onewire object
ds = ds18x20.DS18X20(onewire.OneWire(dat))

# scan for devices on the bus
roms = ds.scan()
print('found devices:', roms)

ds.convert_temp()
time.sleep_ms(750)
ds.read_temp(roms[0])
[/code]

Thanks
Ken

Re: Sparkfun ESP32 Thing with DS18b20 not working

Posted: Tue Mar 10, 2020 10:49 pm
by sloathog
kenglover,

Any luck with a solution?

I'm facing the same problem....

I have two boards, Lolin D32 and a Lolin D1.

On the D1, I can get valid readings from the DS18B20; so I know the sensor is working.
on the D32, I get 85 degrees - which I understand is bus read failure.
I have tried multiple GPIO and different working sensors, but I get the same issue.

Setup on both boards is the same, with a 4.7k pull-up from the data pin to 3.3V.

ds.scan returns a valid bytearray with the rom id, by read_temp returns 85.

Thanks.

Re: Sparkfun ESP32 Thing with DS18b20 not working

Posted: Wed Mar 11, 2020 8:02 am
by kevinkk525
For the esp32 check this issue: https://github.com/micropython/micropython/issues/4647

Some firmware builds don't seem to work correctly on the esp32 when it comes to onewire. Looks like it has something to do with the building process and the device.. It's weird.

Re: Sparkfun ESP32 Thing with DS18b20 not working

Posted: Wed Mar 11, 2020 8:14 am
by sloathog
Thanks for the tip, but I fixed my issue.

After 1.5 hours playing and replacing all parts, I noticed that the connection from 3.3v pin on the D32 to the power rail on the breadboard was at an angle - I'm must have knocked it at some point. Measuring with the multi-meter, the voltage was ~+2.5V, not high enough to power the DS18B20. :oops:

Replaced the jump cable and moved it to a different hole on the + power rail (previous hole felt loose), all works fine.

Build I'm using is: MicroPython v1.12-188-gd3b2c6e44 on 2020-02-21; ESP32 module with ESP32

Conclusion: firmware & code work fine. it was a hardware issue.

Re: Sparkfun ESP32 Thing with DS18b20 not working

Posted: Wed Mar 11, 2020 2:30 pm
by kevinkk525
Then I'm glad it was just a wiring issue and easily fixed.