DS1820 issues with prototype board
-
Hi,
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 correctlyAny 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!
-
@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 the3V3
rail, but a GPIO pin (P8
), which we set toHIGH
just before getting the measurement and for DATA we use pinP10
.
So something like this (assuming you have also loaded theOneWire
module):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)
-
@Don-iot Another alternative to make it rock solid - is to use the DS2482-100
Single-Channel 1-Wire Master.
-
Thanks a bunch @andreas we will defintely take a look and evaluate!
-
Dear @Don-iot,
we had many troubles with 1-Wire and reading the DS18B20 sensors by using the pure-Python driver included with Pycom [1], so we finally unlocked the native C-level driver coming from Genuine MicroPython through [2].
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 [5] to be API-compatible with the Python interface of the native one [6].
With kind regards,
Andreas.[1] https://community.hiveeyes.org/t/untersuchung-und-verbesserung-des-timings-bei-der-ansteuerung-der-ds18b20-sensoren-unter-micropython/2309
[2] https://github.com/pycom/pycom-micropython-sigfox/pull/356
[3] https://community.hiveeyes.org/t/squirrel-firmware-for-pycom-esp32/2960
[4] https://packages.hiveeyes.org/hiveeyes/foss/pycom/
[5] https://github.com/robert-hh/Onewire_DS18X20
[6] https://github.com/micropython/micropython/tree/master/drivers/onewire
-
@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.
-
@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.