I am trying to run the DS18B20 onewire thermal sensor from a Jetson Xavier. For testing purposes, i am using the jetson nano. We are using jetpack version 4.5.1 due to some other driver dependencies
I followed the following two forum posts:
Based on this, i have made kernel modifications, recompiled and flashed the kernel and device tree.
For the kernel, i have added to the config file
CONFIG_W1_MASTER_GPIO=y
CONFIG_W1=y
CONFIG_W1_SLAVE_THERM=y
This can be checked in /sys/bus
where is have aw1
directory
And for the device tree, i have added
onewire@0 {
compatible = “w1-gpio”;
gpios = <&gpio TEGRA_GPIO(H, 4) 0>;
};
This can be checked here: /proc/device-tree
i can see: onewire@0
To check if things are working i have used the following python code in python 3.6
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())
i get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nano/.local/lib/python3.6/site-packages/digitemp/device/thermometer.py", line 275, in __init__
OneWireTemperatureSensor.__init__(self, bus, rom)
File "/home/nano/.local/lib/python3.6/site-packages/digitemp/device/thermometer.py", line 32, in __init__
self.rom_code = self.bus.read_ROM()
File "/home/nano/.local/lib/python3.6/site-packages/digitemp/master.py", line 245, in read_ROM
self.write_byte(0x33)
File "/home/nano/.local/lib/python3.6/site-packages/digitemp/master.py", line 162, in write_byte
raise AdapterError('Noise on the line detected')
digitemp.exceptions.AdapterError: Noise on the line detected
I am also not sure if my wiring is correct. I have a B01 carrier board on my jetson nano, and I am using both the Rx and Tx from the J50 header and the 3.3V /GND from the J41 header. RX and TX both go to the middle data pin and i have a 4.7k resistor going from the data pin to VCC
I am not sure if the device tree is correct for the jetson nano, but i am not sure what else to specify in the DTS: gpios = <&gpio TEGRA_GPIO(H, 4) 0>;