Onewire DS18B20P
-
Wiring WiPy ver. 2.0 with DS18B20P
1 - # DS18B20P data line connected to WiPy pin P10
* DS18B20P - parasite mode wiring
A - # * DS18B20P GND pin connected to DS18B20P Vin pin
2 - # * DS18B20P GND pin connected to WiPy GNDB - # * in series to DS18B20P/WiPy data line connection point
3 - # * mount an 1 Kohm resistor that will be connected to WiPy 3V3In micropython example code I have divided by 100
the reading value to obtain the right temperature valueprint(temp.read_temp_async()/100) # added /100
** see the attachment : WiPi2_DS18B20P_readings.jpg
If I am right the tutorial example must be upgradedfrom :
https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/onewire.html?highlight=onewire
One-wire driver
This tutorial explains how to connect and read data from a DS18x20 temperature sensor.
Basic usage
import time
from machine import Pin
from onewire import DS18X20
from onewire import OneWire#DS18B20 data line connected to pin P10
ow = OneWire(Pin('P10'))
temp = DS18X20(ow)while True:
print(temp.read_temp_async()/100) # added /100 to have Celsius degrees
time.sleep(1)
temp.start_convertion()
time.sleep(1)