How’s it going. I’m going to try and limit this for simplicity. I am a student studying EE. I have an UltraSonic Sensor connected using USB Serial Port CH340. I have tried to look for a python script that could give the distance but it seems it’s not possible. Any help or guidance is greatly appreciated.
Or any help with GPIO is also greatly appreciated but I’ve read online it’s not recommended because of OS.
I have looked into this article and have attached a script on this.
import serial
import time
import sys
ser = serial.Serial('/dev/ttyUSB0') # open serial port
byte = b'\xff' # xff is the start byte
while True:
x = ser.read()
if x == byte: #starbyte found
b1 = ser.read(1)
b2 = ser.read(1)
x1 = int.from_bytes(b1, sys.byteorder)
dist = (((x1 << 8) + int.from_bytes(b2, sys.byteorder)) / 10) # some bitshift magic, no idea what's happening here
print(dist - 5) # for some reason the distance value is 5cm off, remove them before printing the value
clear = ser.read_all()
ser.flushOutput()
time.sleep(2)
Hey @kayccc so I have looked into using GPIO from other forums. However, this forum and a couple of others point to not using GPIO because it is unreliable. I wanted to look into using USB Serial Port.
Are you using the devkit or custom board for Jetson Nano?
What’s the Jetpack version in use?
It seems you want to use an UltraSonic Sensor connecting through USB.
So, it is an USB device for Jetson.
What’s your current issue about this device?
Have you also tried using this device on an Ubuntu host pC?
About GPIO issue, I would suggest you creating another topic to discuss in details since it is not relating to the current USB device.
Hey @KevinFFF yeah I probably should have specified. The Jetson Nano I’m using is the dev kit using the board B01. In addition the jet pack version is 4.6.1. It’s an old board but nevertheless works well with our RPLidar C1 sensor.
Here’s the set up I have. I have the AJ-SR04M (ultrasonic sensor) connected using RX → to TXD and vice versa TX - RXD to my usb. I have tried this using a host PC and Jetson but reads wrong distance.
There is no update from you for a period, assuming this is not an issue anymore.
Hence, we are closing this topic. If need further support, please open a new one.
Thanks
What’s the module with RED LED light-ON in your picture?
Is it a USB to serial converter?
If so, it is still a USB device for Jetson Nano.
Why don’t you just connect them to the UART interface(at 40 pins expansion header) on Jetson Nano devkit?
Do you mean that host PC read the correct value but Jetson Nano dosen’t?