Configuring DS18B20 temperature sensor using python on Jetson Nano

Hi, i spend today few hours to connect DS18B20 temperature sensor to my Jetson Nano A02 and i succes!!! It’s a few steps:

  1. I am install pydigitemp library using pip

  2. Connect to J44 UART A02 header : Pin 2 → TXD , Pin 3 → RXD , Pin 6 ->GND and 3.3V i get from J41 header. PS. Important B01 version of Nano have other pin numbers J50 header Pin 4 → TXD, Pin 3 → RXD, Pin 7 → GND

  3. On DS18B20 sensor TXD,RXD is conected together to Data pin and 4.7K Ohms pull up resistor to VCC pin

https://raw.githubusercontent.com/mcsakoff/pydigitemp/75b2c914538e7178cf302be2dbec73f21216fc5c/docs/ds18b20-uart.svg

  1. I wrote this program(Demo Code from library documentation;) ):

from digitemp.master import UART_Adapter
from digitemp.device import AddressableDevice
from digitemp.device import DS18B20

bus = UART_Adapter(‘/dev/ttyS0’) #J44 header name

sensor = DS18B20(bus)

sensor.info()

print(sensor.get_temperature())

Importand DS18B20 class is only for this version sensor, for other type sensors read library documentation

https://github.com/mcsakoff/pydigitemp/issues/1

  1. And Violla!!! its working!!! Bye

and multiple sensors version

from digitemp.master import UART_Adapter
from digitemp.device import AddressableDevice
from digitemp.device import DS18B20

print(AddressableDevice(UART_Adapter(‘/dev/ttyS0’)).get_connected_ROMs())

bus = UART_Adapter(‘/dev/ttyS0’) # DS9097 connected to COM1

sensor_01 = DS18B20(bus, rom=‘28FF2DAE02198A03’)
sensor_02 = DS18B20(bus, rom=‘28FF0BDD02198A47’)

sensor_01.info()
print(sensor_01.get_temperature())

sensor_02.info()
print(sensor_02.get_temperature())

and connected sensors in parasite power mode:
Both senors GND and VDD together, and 4.7K Ohms resistor pull up Data to VCC

1 Like