Sparkfun ESP32 Thing with DS18b20 not working

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
kenglover
Posts: 1
Joined: Wed Jan 30, 2019 4:20 am

Sparkfun ESP32 Thing with DS18b20 not working

Post by kenglover » Wed Jan 30, 2019 4:41 am

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

sloathog
Posts: 9
Joined: Tue Mar 10, 2020 10:30 pm

Re: Sparkfun ESP32 Thing with DS18b20 not working

Post by sloathog » Tue Mar 10, 2020 10:49 pm

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.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Sparkfun ESP32 Thing with DS18b20 not working

Post by kevinkk525 » Wed Mar 11, 2020 8:02 am

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.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

sloathog
Posts: 9
Joined: Tue Mar 10, 2020 10:30 pm

Re: Sparkfun ESP32 Thing with DS18b20 not working

Post by sloathog » Wed Mar 11, 2020 8:14 am

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.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Sparkfun ESP32 Thing with DS18b20 not working

Post by kevinkk525 » Wed Mar 11, 2020 2:30 pm

Then I'm glad it was just a wiring issue and easily fixed.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

Post Reply