OneWire Interface

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
dakotadev
Posts: 3
Joined: Sat Feb 12, 2022 1:52 am
Location: Minnesota, USA

OneWire Interface

Post by dakotadev » Sat Feb 12, 2022 2:04 am

I'm having problems deciding if there is a problem with micropython's handling of DS18x20 devices. I cannot find anything regarding this in this forum, nor the web at large, so I figured i'd ask.

I was hoping to control a heater with temperature samples from a DS18B20 device. I'm using an RP2040 for my controller, I think I have it updated to the latest micripython (I just checked the INFO_UF2.TXT file, but that doesn't seem to carry the micropython version - but here maybe I am getting confused with circuitpython).

Anyway. When i use the ds18x20.scan() method, nothing returns - I just see empty brackets. But if I use the onewire.scan() method, i actually get something in the bytestream. Furthermore, if I connect this sensor to a board programmed with arduino, it works fine as well, and i get a temperature reading.

So, maybe if someone can help answer why arduino works fine, and the one-wire scan method in MicroPython works fine, but the ds-method does nothing?

I really don't know enough about python (for whatever reason i have a hard time dealing with the bytearray object) to add further info.. But i know enough to be sure i have this connected properly, with 4.7kohm resistor pulling up the data line.

dakotadev
Posts: 3
Joined: Sat Feb 12, 2022 1:52 am
Location: Minnesota, USA

Re: OneWire Interface

Post by dakotadev » Sat Feb 12, 2022 3:00 pm

Ok, so I went back to it today, and there was nothing wrong. Of course. I tried the ds18x20.scan() method and it populated the same as the onewire.scan() method.

There is nothing worse than an intermittent problem with no explanation. I finally got all the different source files set up to compare with the arduino library to see what might have been messing up. Probably stupid of me to question the python library at all.

But, I will say that this is not the first time I've had intermittent problems with the dallas thermocouple using python. I used to have a raspberry pi set up to log temperatures in a room, and it would flake out from time to time. Although I always guessed it had something to do with the way I was running the python script. Maybe it was both.

:?: Perhaps one-wire devices are just not that reliable??

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: OneWire Interface

Post by davef » Sat Feb 12, 2022 6:55 pm

Google "fake DS18B20".

Post Reply