Jetson nano with AMG8833 through GPIO always get Remote I/O error - gpio

As title mentioned, I tried to extract some data from AMG8833 through GPIO on Jetson nano, but always get
[Errno 121]Remote I/O error...
My AMG8833 SDA connect to GPIO pin 27, and SCL connect to pin 28. I have already tried
sudo i2cdetect -y -r 1
Then only shows 29, I have no idea about this, and still cannot work...
Is there anyone has any other solutions about this issue? Please share with me, I will be very appreciated for your help.
Following is the python code...
import busio
import time
import board
import adafruit_amg88xx
i2c = busio.I2C(board.SCL, board.SDA)
amg = adafruit_amg88xx.AMG88XX(i2c)
while True:
time.sleep(1)
for row in amg.pixels:
# Pad to 1 decimal place
print(["{0:.1f}".format(temp) for temp in row])
print(row)
print("")
print("\n")
time.sleep(1)

Related

RPi4 w/ Centos and RPI.GPIO: can't add edge detection

I am running CentOS7 with kernel 5.4.206-v8.1.el7 on a RPi4 and I am trying to setup edge detection on GPIO with RPi.GPIO-0.7.1-py3.9 (*)
I am getting the following error whatever the pin I try to configure:
RPi.GPIO.add_event_detect(self.pin, RPi.GPIO.BOTH, self._on_event) RuntimeError: Failed to add edge detection
I also get it when I run in sudo. I previously tuned the permissions to get:
[blabla#hostname]$ ls -l /dev/gpiomem crw-rw----. 1 root gpio 246, 0 Jan 1 1970 /dev/gpiomem
so that GPIO in output mode (to blink a LED for instance) works fine.
Running my basic RPi.GPIO-based edge detection code (*) with strace I noticed a few suspicious lines:
faccessat(AT_FDCWD, "/sys/class/gpio/gpio6", F_OK) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/sys/class/gpio/export", O_WRONLY) = -1 EACCES (Permission denied)
I thought RPi.GPIO was now based on GPIO character and not sysfs anymore? Although I am far from being an expert so I may be wrong / confused
I looked a bit into /sys/class/gpio on my RPi:
[blabla#hostname]$ ls /sys/class/gpio/ export gpiochip446 gpiochip454 unexport
It seems to me that attempting to create /sys/class/gpio/gpio6 makes no sense here, one should read the base of the controller and do base+6 ? Wouldn't that explain the Permission denied?
I tried to run the event.c example of the bcm2835 library and this works fine, ie button pressed are detected correctly. For technical reasons I would like to use RPi.GPIO.
Sorry again I am far from being an expert so maybe just confused myself, any help to unblock the situation would be great!
Thanks a lot
Best wishes
(*)
import RPi.GPIO as GPIO
X=6
# Set pin X in GPIO mode
GPIO.setmode(GPIO.BCM)
GPIO.setup(X, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Define a callback function to detect edge events
def my_callback(channel):
print(f"Edge event detected on pin {X}")
# Set the callback function
GPIO.add_event_detect(X, GPIO.RISING, callback=my_callback)
# Main loop
try:
while True:
pass
# Exit gracefully
except KeyboardInterrupt:
GPIO.cleanup()

Error opening serial USB port for communication

I am trying to establish communication with electrical test equipment for remote control and data logging with a python script. I am unable to even get off the ground. It looks like I am unable to open the port? Any help is appreciated.
I am on a Windows machine using VSCode terminal.
PS C:\Users\AaronVaughan> py -m serial.tools.list_ports
COM6
1 ports found
>>> import serial
>>> ser = serial.Serial(port="COM6")
...
serial.serialutil.SerialException: could not open port 'COM6': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
After acquiring the address, serial number, and version of the instrument, I gained access using pyvisa and libusb1. The address, SN, and ver. were acquired after driver installation from National Instruments and the device manufacturers website.
Some skeleton code below...
import pyvisa
rm = pyvisa.ResourceManager()
PM1 = rm.open_resource("USB0::0x0A69::0x0879::63212AL00409::INSTR")
PM1.write_termination = '\n'
PM1.read_termination = '\n'
PM1.timeout = 1000
PM1.write('*CLS')
print(PM1.query('*IDN?'))
PM1.write('*RST')

Trouble initializing SDK node using USB-TTL M210 v2

I am trying to connect M210 v2 RTK to a desktop computer with Ubuntu 18.04, ROS Melodic and parallel installation of Opencv 3.3.1 and 4.5.3 using a USB-TTL RS232 to make UART connection and an USB-USB connecting drone and desktop to be able to run Advanced Sensing.
When I call ls -l /dev/ttyACM* && ls -l /dev/ttyUSB* it returns that it is indentified the USB and ACM connection.
crw-rw---- 1 root dialout 166, 0 out 4 13:18 /dev/ttyACM0
crw-rw---- 1 root dialout 188, 0 out 4 13:18 /dev/ttyUSB0
I also set the transfer rate of TTL-USB to 921600 using minicom, and gave persmission to device to read and write with sudo usermod -a -G dialout $USER && sudo chmod 666 /dev/ttyUSB0
Unfortunatelly when I launch roslaunch dji_osdk_ros dji_sdk_node.launch it appears some connection problem presented below and I am not being able to fix it. I have been trying to turn on/off drone and RC several times ass described here, but the problem still stand.
started roslaunch server http://V3D06:43613/
SUMMARY
========
PARAMETERS
* /dji_sdk/acm_name: /dev/ttyACM0
* /dji_sdk/align_time: False
* /dji_sdk/app_id: 1076017
* /dji_sdk/app_version: 1
* /dji_sdk/baud_rate: 921600
* /dji_sdk/dxc: False
* /dji_sdk/enc_key: 6bd1d26f8dd897e4b...
* /dji_sdk/serial_name: /dev/ttyUSB0
* /dji_sdk/use_broadcast: False
* /rosdistro: melodic
* /rosversion: 1.14.12
NODES
/
dji_sdk (dji_osdk_ros/dji_sdk_node)
auto-starting new master
process[master]: started with pid [2436]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to bde7b4d2-252e-11ec-8a59-1831bfb3e154
process[rosout-1]: started with pid [2458]
started core service [/rosout]
process[dji_sdk-2]: started with pid [2464]
[ INFO] [1633364323.534426789]: Advanced Sensing is Enabled on M210.
Read App ID
User Configuration read successfully.
[1276751.089]STATUS/1 # getDroneVersion, L1702: ret = 0
[1276751.089]STATUS/1 # parseDroneVersionInfo, L1122: Device Serial No. = 1DADG3E00100U4
[1276751.089]STATUS/1 # parseDroneVersionInfo, L1124: Firmware = 3.4.3.44
[1276751.089]STATUS/1 # functionalSetUp, L279: Shake hand with drone successfully by getting drone version.
[1276751.089]STATUS/1 # legacyX5SEnableTask, L56: Legacy X5S Enable task created.
[1276752.089]STATUS/1 # sendHeartbeatToFCTask, L1576: OSDK send heart beat to fc task created.
[1276752.289]STATUS/1 # Control, L40: The control class is going to be deprecated.It will be better to use the FlightController class instead!
[1276752.290]STATUS/1 # FileMgrImpl, L253: register download file callback handler successfully.
[1276753.557]STATUS/1 # PSDKModule, L98: MOP only support M300, so mop client will not be initialized here.
[1276753.557]STATUS/1 # PSDKModule, L98: MOP only support M300, so mop client will not be initialized here.
[1276753.557]STATUS/1 # PSDKModule, L98: MOP only support M300, so mop client will not be initialized here.
[1276753.557]STATUS/1 # initDJIHms, L900: DJI HMS is not supported on this platform!
[1276753.567]STATUS/1 # getDroneVersion, L1702: ret = 0
[1276753.567]STATUS/1 # parseDroneVersionInfo, L1122: Device Serial No. = 1DADG3E00100U4
[1276753.567]STATUS/1 # parseDroneVersionInfo, L1124: Firmware = 3.4.3.44
[1276753.567]STATUS/1 # AdvancedSensing, L145: Advanced Sensing init for the M210 drone
[1276753.567]STATUS/1 # init, L49: Looking for USB device...
[1276753.572]STATUS/1 # init, L65: Found 8 USB devices, identifying DJI device...
[1276753.572]STATUS/1 # init, L83: Found a DJI device...
[1276753.572]STATUS/1 # init, L96: Attempting to open DJI USB device...
[1276753.572]ERRORLOG/1 # init, L101: Failed to open DJI USB device...
[1276753.572]ERRORLOG/1 # init, L102: Error code: -3
[1276753.572]ERRORLOG/1 # init, L105: Please make sure you provide a udev file for your system and reboot the computer
[1276753.573]STATUS/1 # LiveViewImpl, L89: Finding if liveview stream is available now.
[1276754.076]STATUS/1 # init, L254: Start advanced sensing initalization
[1276754.076]STATUS/1 # activate, L1329: version 0x304032C
[1276754.076]STATUS/1 # adv_pthread, L46: adv pthread created !!!!!!!!!!!!!!!!!!!!!!!
[1276754.076]STATUS/1 # adv_pthread, L48: adv pthread running !!!!!!!!!!!!!!!!!!!!!!!
[dji_sdk-2] process has died [pid 2464, exit code -11, cmd /home/vant3d/catkin_ws/devel/lib/dji_osdk_ros/dji_sdk_node __name:=dji_sdk __log:=/home/vant3d/.ros/log/bde7b4d2-252e-11ec-8a59-1831bfb3e154/dji_sdk-2.log].
log file: /home/vant3d/.ros/log/bde7b4d2-252e-11ec-8a59-1831bfb3e154/dji_sdk-2*.log
It appears it has some problem providing a udev file, but I don't know how to fix it. Does anyone have some idea to help on this problems?
Thank you!
That's my post. Firstly turn off advanced sensing to try whether a basic FTDI works.
The second which DJI OSDK version are you using? does the OSDK version match the version in OSDK-ROS? I saw you have M300 in. that is usually in OSDK 4+. For M210, I only use 3.8 and 3.9
If basic FTDI works, and you can get all the feedback. there is a higher chance that you have the wrong ACM config. DJI RNDIS thing is nasty and may not be config properly. You need to manually set static IP of 192.168.43.1 (or I remember something like this 42 or 43, you need to check on this static IP) and set it manually

Rpi Python interfacing RS232 to RS485 Converter Problem

I am establishing serial communication using raspberry Pi with ADAM-4520 device using pyserial lib using usb to serial converter.
1st,I tested device with PC using hyper terminal and with Pi using Gtkterm,
To read sensor values from device with command "#04".
Here i first giving output from Gtkterm.
#04
>+261.25+310.76+049.09+206.77+126.80+049.79
#04
>+261.25+310.76+049.09+206.75+126.80+049.79
But when i am trying through Pyserial program it isn't working.
Here is my code:
import serial
import time
s=serial.Serial(port='/dev/ttyUSB0',
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1)
st="#04"
st=''.join(str(ord(c)) for c in st)
x=st.encode('ascii')
while True:
s.write(x)
print(x)
time.sleep(0.2)
text=s.readline()
temp=text.decode('ascii')
#text=text.decode('utf-8')
#text=text[5:-1]
print(temp)
time.sleep(2)
As both hyper terminal and gtkterm work with ascii ,i am also tried to convert my command into ascii also but no result.
i am new to python ,please guide to find the issue guys
pi#raspberrypi:~ $ sudo python3 helloworld.py
b'354852'
b'354852'
b'354852'

Modbus cant read data from epever tracer 1210a to raspberry

i want to make a monitoring program for tracer
i use rs485 usb converter to connect epever tracer1210a to raspberry pi 3 model b
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
client = ModbusClient(method = 'rtu', port = '/dev/ttyACM0', baudrate = 115200)
client.connect()
print( client)
result = client.read_input_registers(0x3100,6,unit=1)
print (result)
solarVoltage = float(result.registers[0] /100.0)
solarCurrent = float(result.registers[1] /100.0)
batteryVoltage = float(result.registers[4] /100.0)
chargeCurrent = float(result.registers[5] /100.0)
print("solar voltage : ",solarVoltage)
print("solar current : ",solarCurrent)
print("battery volatage : ",batteryVoltage)
print("charge current : ",chargeCurrent)
client.close()
and i get error like this:
ModbusSerialClient(rtu baud[115200])
Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
Traceback (most recent call last):
File "yutub.py", line 9, in
solarVoltage = float(result.registers[0] /100.0)
AttributeError: 'ModbusIOException' object has no attribute 'registers'
please help me to fix this problem
I had faced the same problem.
Follow the below steps to fix the issue:
git clone https://github.com/kasbert/epsolar-tracer/tree/master/xr_usb_serial_common-1a
Follow the installation steps from Readme.
You might face problem when you execute make. In such case do sudo apt-get install linux-headers.
Check that the USB UART is detected by the system
lsusb
Check that the CDC-ACM driver was not installed for the Exar USB UART
ls /dev/tty*
To remove the CDC-ACM driver and install the driver:
sudo rmmod cdc-acm
sudo modprobe -r usbserial
sudo modprobe usbserial
sudo insmod ./xr_usb_serial_common.ko
After this when you do ls /dev/tty* you will see /dev/ttyXRUSB0. This means the driver is installed and you are in good shape.
Change the port in your code to '/dev/ttyXRUSB0'.
See the output image
After you restart the PI you might not see the ttyXRUSB0 instead you will see ttyACM0. In such case execute sudo echo blacklist cdc-acm > /etc/modprobe.d/blacklist-cdc-acm.conf. If PI does not allow you to execute then create the file in the path and write blacklist cdc-acm.
Reboot and verify if ttyACM0 is still displayed in ls /dev/tty*.

Resources