Drive ds18b20 with jetson nano 4gb

hi every body
it’s been a while that i’m trying to drive digita tempreture sensor (ds18b20) with jetson nano
according this post

i add obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o to (/kernel/kernel-4.9/drivers/w1/slaves/Makefile)
and after that i added (CONFIG_W1_SLAVE_THERM=y) in tegra_deconfig in (/kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig) and after that i added (onewire@0 {
compatible = “w1-gpio”;
gpios = <&gpio TEGRA_GPIO(H, 4) 0>;
};) to device tree in ( sources/hardware/nvidia/platform/t210/common/kernel-dts/t210-common-platforms/tegra210-common.dtsi)
and after all of those i have been compiled the kernel and made the img file with this instruction
( Compiling Custom Kernel Modules on the Jetson Nano | Kevin’s Blog)
but after connecting ds18b20 through J50 header ( Pin 4 → TXD, Pin 3 → RXD, Pin 7 → GND) and run sample code of digitemp module base on this post

after all of those steps steel i have the same error

Traceback (most recent call last):
File “/home/abolfazl/Desktop/hrl.py”, line 7, in
sensor = DS18B20(bus)
File “/home/abolfazl/.local/lib/python3.6/site-packages/digitemp/device/thermometer.py”, line 275, in init
OneWireTemperatureSensor.init(self, bus, rom)
File “/home/abolfazl/.local/lib/python3.6/site-packages/digitemp/device/thermometer.py”, line 32, in init
self.rom_code = self.bus.read_ROM()
File “/home/abolfazl/.local/lib/python3.6/site-packages/digitemp/master.py”, line 244, in read_ROM
self.reset()
File “/home/abolfazl/.local/lib/python3.6/site-packages/digitemp/master.py”, line 220, in reset
raise AdapterError(‘Read/Write error’)
digitemp.exceptions.AdapterError: Read/Write error

Where did I do it wrong? how can i fix this and recieve data from ds18b20 in jetson nano
please help me guys this problem is driving me crazy

is there any way to check the kernel customization worked or the kernel customized right?

Check the kernel by below command.
You can confirm by the time.

nvidia@nvidia-desktop:~$ uname -a
Linux nvidia-desktop 4.9.253-tegra #1 SMP PREEMPT Mon Jul 26 12:19:28 PDT 2021 aarch64 aarch64 aarch64 GNU/Linux

right i checked that and was correct but still dosent work when i wanna communicate with ds18b20 with jetson nano
what i need to do to make it work?

I connected my sensor directly to jetson on gpio header, I did not use an external uart / usb adapter. Perhaps you need to grant permission for your “sudo chmod 666 / dev / ttys0” adapter. Make sure where your uart port “dmesg | grep tty” is mounted. Nothing else comes to mind

thanks for your response
do you make connection between ds18b20 and jetson nano or some other sensor ?

Do you add pull up resistor to data line?
68093499-5b310700-fe96-11e9-8d50-2be9982a59f2

For me, this sensor works without a problem. And i have a first revision of Jetson Nano for B01 revision have some pin number changed. Please read my instruction

Configuring DS18B20 temperature sensor using python on Jetson Nano - #5 by Artur4C2F1 I wrote this instruction and its working for me without a problems

yes i did.

so you didn’t any kernel and device tree modifications??
do you remember whitch jetpack did you used that time you wrote this topic??

No i didn’t any kernel modification and device tree. I dont remember i think JP 4.5 or 4.6. I connect TX and RX line togheter to Ds data line through 4.7k ressistor pull up to vcc 3.3V on Jetson. I have somthing simillar errors when i don’t grant permissions for uart or bad tty number. I try to help as much as I can, however my experience is not that much as I am a novice programmer

thank you so much for your advices
i will check them today and will post the updates in this topic
until then do you have any idea why this error happend when i run pydigitemp sample code?

error :

Traceback (most recent call last):
File “/home/abolfazl/Desktop/hrl.py”, line 7, in
sensor = DS18B20(bus)
File “/home/abolfazl/.local/lib/python3.6/site-packages/digitemp/device/thermometer.py”, line 275, in init
OneWireTemperatureSensor.init (self, bus, rom)
File “/home/abolfazl/.local/lib/python3.6/site-packages/digitemp/device/thermometer.py”, line 32, in init
self.rom_code = self.bus.read_ROM()
File “/home/abolfazl/.local/lib/python3.6/site-packages/digitemp/master.py”, line 244, in read_ROM
self.reset()
File “/home/abolfazl/.local/lib/python3.6/site-packages/digitemp/master.py”, line 220, in reset
raise AdapterError(‘Read/Write error’)
digitemp.exceptions.AdapterError: Read/Write error

I found similar problem than yours
Then resolved by uncomenting line 38 and 39 in termometer.py in pydigitemp lib

there is no commented thing in line 38 and 39 in digitemp/device/termometer.py it seems author fixed that before .
i think i just missed something in this link

pydigitemp library author said in bus driver section it will work only if we use ds9097 module or something like that
am i think right??
in your experience you connect sensor straight to the jetson nano without any interface module??

Yes directly. I am currently on vacation, after returning in a few days, I will repeat the connection of this sensor on my nano and contact you. Sorry for the delay, I really want you to successfully activate this sensor.

I’m appreciate for your concern , i’ll wait for your reply thanks a lot

Hello again. I replicate my circuit and its working good. I use Jetson Nano 4GB A01 with latest Jetpack and connect to uart port called J44.
First sudo /dev/ttyS0
then run my program, add on the end bus.close()

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

bus = UART_Adapter(‘/dev/ttyS0’)

sensor = DS18B20(bus)
sensor.info()

try:
while True:
print(sensor.get_temperature())

except KeyboardInterrupt:
print(“Press CRTL-C to terminate”)
pass
bus.close()

Make sure the connection is made in this order
Data pin from sensor to Tx then pull up resistor to 3.3V then Rx, Vdd to 3.3V and GND sensor to GND from J44 port Uart
Wrong order will cause uart errors and connection problems
If there are still problems, please write. In the newer Jetson, the pins have a different order, the uart port on the J41 GPIO will also have a different address




This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.