DS1820 issues with prototype board
I have some issues with DS1820 sensor. We are using the GPY on our own prototype board with a lot of other sensors. This was the first sensor we tested and it was successful. Now when going back to the final testing everything rocks and works, but the DS1820 sensor is no success story. The value of the sensor is around +0.125 degrees or minus 2 C. Tried various sensors, and various board iterrations (of our own design) but the problem remains. The wiring for that part is as follows.
My suspicions are that
a) we should feed the sensor with 5 V and not 3V3
b) the 3V3 and ground wires are shared with other sensors. However even with everything removed from the board, we get the same data reading
c) I have not wired everything correctly
Any advice and suggestions welcome. We ran a test with the same basic setup for a few months with huge success, so this one is bothering me. However on that test we just realised that we had the resistor between ground and data PIN instead, it worked perfectly though. Has anyone else tested this with success? The wiring is as follows:
@agotsis Thanks, that one was smart and also, I guess, power optimised. Will try that!
agotsis last edited by
@Don-iot We have been using the OneWire library from Pycom's Github repository (https://github.com/pycom/pycom-libraries/blob/master/examples/DS18X20/onewire.py) without any problem for a long-time both with LoPy4 and GPy.
As far as the circuit implementation we use a pull-up resistor, i.e. put the 4.7k resistor between VCC and DATA pins. For VCCwe even don't use the
3V3rail, but a GPIO pin (
P8), which we set to
HIGHjust before getting the measurement and for DATA we use pin
So something like this (assuming you have also loaded the
import machine from machine import Pin import utime VCC_PIN = 'P8' DATA_PIN = 'P10' # enable supply to sensor tpin=Pin(VCC_PIN,Pin.OUT) tpin.value(1) # initialize DS18X20 ow = OneWire(machine.Pin(DATA_PIN)) tempObj = DS18X20(ow) # sensor reading tempObj.start_conversion() utime.sleep(1) temp = tempObj.read_temp_async() # disable supply to sensor tpin.value(0)
ShanevanJ last edited by
Thanks a bunch @andreas we will defintely take a look and evaluate!
andreas last edited by
we had many troubles with 1-Wire and reading the DS18B20 sensors by using the pure-Python driver included with Pycom , so we finally unlocked the native C-level driver coming from Genuine MicroPython through .
So, as soon as you got everything right on the electrical aspects, you might want to use one of our custom builds available from [3,4] in order to use the improved driver.
@robert-hh was so kind to adapt a version of the pure-Python driver  to be API-compatible with the Python interface of the native one .
With kind regards,
@robert-hh Thanks. After further investigation it seems like output current of 3V3 is not enough to supply all sensors on the board or the chinese prototype circuit board is just so thin that it is limiting the current. We moved the 5V to be supplied the battery directly and now it works, so clearly hardware related.
robert-hh last edited by robert-hh
@Don-iot Did you have a look at the signals on the data line with an oscilloscope, whether they look properly?
3.3V is fine for the DS18B20.