DS18B20 on WiPi reading "none"
-
@cbourne No. That should be the same. I simply forgot that I had made a repository for them. Quite a while ago. We never could convince Pycom to use these.
So take the files from the repository. They are proper documented.
-
@robert-hh Thanks, I'll try this again later. So are these different to the ones here: https://github.com/robert-hh/Onewire_DS18X20 ?
-
@cbourne I tried to replicate that on my lopy, only to find that I seem to have a completely different set of functions, which however work. Since I am not allowed to upload them here, i've put it to a different place:
https://github.com/robert-hh/Shared-Stuff/blob/master/ds18x20.zip
-
OK so I just tested my DS18X20 on a Raspberry Pico & Circuit Python using this code:
import time import board from adafruit_onewire.bus import OneWireBus from adafruit_ds18x20 import DS18X20 # Initialize one-wire bus on board pin D5. ow_bus = OneWireBus(board.GP16) # Scan for sensors and grab the first one found. ds18 = DS18X20(ow_bus, ow_bus.scan()[0]) # Main loop to print the temperature every second. while True: print("Temperature: {0:0.3f}C".format(ds18.temperature)) time.sleep(1.0)
It worked first time:
Temperature: 28.750C Temperature: 28.750C Temperature: 28.813C Temperature: 28.750C Temperature: 28.688C Temperature: 28.625C Temperature: 28.625C Temperature: 28.625C Temperature: 28.563C Temperature: 28.563C Temperature: 28.625C Temperature: 28.688C Temperature: 28.625C Temperature: 28.625C Temperature: 28.625C Temperature: 28.625C Temperature: 28.688C Temperature: 28.625C Temperature: 28.625C Temperature: 28.625C Temperature: 28.688C Temperature: 28.688C Temperature: 28.813C Temperature: 28.750C Temperature: 28.750C Temperature: 28.750C Temperature: 28.750C Temperature: 28.750C Temperature: 28.750C Temperature: 28.750C Temperature: 28.688C
So obviously there's something different happening here and it proved that the DS18X20 is working properly. Can anyone shed some light on this problem please.
-
@robert-hh So ?I get 3.2v between GND and Vdd and 2.8v between GND and the data pin. I've tried 3 seperate DS18B20 from here https://thepihut.com/products/ds18b20-digital-temperature-sensor-extras?
Just tried a new WiPi 3 and expansion board. Same result. i.e. and empty Roms array.
-
@cbourne So you have the data pin at 3.2, when there is not data requested. That's fine. During transfer you should see with a voltage meter a slight drop. Is the DS18B20 cold or warm? If warm, the wiring is wrong.
Did the DS18B20 ever work? If not, it may be broken.
-
@d-alvrzx So I also tested the voltage across the DS18X20 - its ~3.2 volt. Data is now on Pin10. Also tried a brand new Wipy 3. Still not seeing the DS18X20 and Roms return an empt array.
-
@d-alvrzx Thanks for getting back on this. So I've wired everything as per the diagram and tried PINS 10, 17, 20. Ans still get an empty array for Roms using your suggested code. Not sure what else to do next now.
-
@cbourne As far as the library I linked to goes, the
scan()
function is a part of theDS18X20
object (not theow
object). So your code should be something like this:from ds18x20 import DS18X20 from onewire import OneWire from machine import Pin from utime import sleep # setup temp sensor ow = OneWire(Pin('P22')) # replace for data pin in your setup TempSensor = DS18X20(ow) Roms = TempSensor.scan() if Roms: print("DS18S20 Resolution", TempSensor.resolution(Roms[0], 9)) # read temp sensor if Roms: TempSensor.convert_temp() sleep(1) # wait for temp conversion currTemp = TempSensor.read_temp(Roms[0]) print(currTemp)
Then, I'm not sure why you have the DS18B20
VDD
(power) pin connected toP11
. You should connect that to the WiPy3V3
output. As per the datasheet, these should be your connections:In your case,
VPU=VDD
.
-
@d-alvrzx said in DS18B20 on WiPi reading "none":
ds18x20
Thanks for this - very helpful.
Seems that my problem is that the Pycom is not seeing any of my DS18X20's on the bus.
i.e.
ow.scan()
returns and empty array.
I've got my pins configured as:
ds18x20 Pycom WiPy
gnd => gnd
data => P10
Power => P11I also have a 4.7k resistor between data and Power.
These are what I'm using https://thepihut.com/products/ds18b20-digital-temperature-sensor-extras?variant=27740417553
-
I'm not exactly sure which
onewire
library you are using, because the imports usually look like this:from ds18x20 import DS18X20 from onewire import OneWire
Yours imports
DS18X20
fromonewire
. However, you should look into using this library by @robert-hh , which I've used without problems for months now. His example code in the repo shows you how to get a temp reading.