Timeout error when reading from USB Multimeter - python

I need to extract data from a digital multimeter using a USB connection and Python on my Raspberry Pi. Here I have a very basic Python script for reading from a generic USB device, and note that the idVendor and idProduct variables are correct for the multimeter I am using:
import usb.core
dev=usb.core.find(idVendor=0x067b,idProduct=0x2303)
ep=dev[0].interfaces()[0].endpoints()[0]
i=dev[0].interfaces()[0].bInterfaceNumber
dev.reset()
if dev.is_kernel_driver_active(i):
dev.detach_kernel_driver(i)
dev.set_configuration()
eaddr=ep.bEndpointAddress
r=dev.read(eaddr,1024)
print(len(r))
I have a rules file in the path /etc/udev/rules.d/99-usbftdi.rules. It has the following:
SUBSYSTEM=="usb", ATTRS{idVendor}=="0x067b", MODE="0666"
When I try to execute the file while I have the multimeter turned on connected to my Raspberry Pi, I get the following error message:
Traceback (most recent call last):
File "usbRead.py", line 14, in <module>
r=dev.read(eaddr,1024)
File "/home/pi/.local/lib/python2.7/site-packages/usb/core.py", line 1024, in read
self.__get_timeout(timeout))
File "/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 869, in intr_read
timeout)
File "/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 954, in __read
_check(retval)
File "/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 602, in _check
raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out
------------------
(program exited with code: 1)
Press return to continue

Related

Send data between two pico with LoRa

I am trying to send data from a Pico Raspberry Pi to another Pico through an SX1262, but I can't send it.
I already tried the ping pong example, but the SX1262 library gives me errors in the Thonny IDE.
Traceback (most recent call last):
File "", line 19, in
File "/lib/sx1262.py", line 27, in begin
File "/lib/sx126x.py", line 115, in begin
File "/lib/sx126x.py", line 240, in reset
File "/lib/sx126x.py", line 389, in standby
File "/lib/sx126x.py", line 1270, in SPIwriteCommand
File "/lib/sx126x.py", line 1287, in SPItransfer
TypeError: object with buffer protocol required
Then we tried to use AT commands, but there is no response (code). We don't want to use LoRaWAN.
Can you please help if you found the solution?
I tried this and it works: try this
https://github.com/ehong-tl/micropySX126X

Adafruit MAX 31856 communicating with raspberrypi

I have been trying to read a thermocouple temperature on my raspberrypi however cant get the raspi to communicate with the adafruit MAX 31856. I have downloaded necessary libraries and checked that all connections are secure and correct however keep running into this error when I try to execute this code.
Any help is greatly appreciated!!
CODE
import board
import digitalio
import adafruit_max31856
spi = board.SPI()
cs = digitalio.DigitalInOut(board.D5)
cs.direction = digitalio.Direction.OTUPUT
thermocouple = adafruit_max31856.MAX31856(spi,cs)
print(thermocouple.temperature)
ERROR:
Traceback (most recent call last):
File "/home/pi/test4.py", line 6, in <module>
spi = board.SPI()
File "/usr/local/lib/python3.7/dist-packages/board.py", line 299, in SPI
return busio.SPI(SCLK, MOSI, MISO)
File "/usr/local/lib/python3.7/dist-packages/busio.py", line 289, in __init__
self._spi = _SPI(portId)
File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 25, in __init__
self._spi = spi.SPI(device=(portid, 0))
File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 167, in __init__
raise IOError("{} does not exist".format(device))
OSError: /dev/spidev0.0 does not exist
Code
Errors
Most probably there is a device driver loaded for spi0-0 and that removes /dev/spidev0.0 device.
check your /boot/config.txt for overlays loading MAX 31856 driver module.
if you want to use adafruit_max31856 lib you shouldn't be loading this driver. hope that helps

Please help! Not able to read from a USB multimeter

I am still quite new to USB protocol, and I need help extracting data from a digital multimeter using a USB connection and Python on my Raspberry Pi. Here I have a very basic Python script for reading from a generic USB device, and note that the idVendor and idProduct variables are correct for the multimeter I am using:
import usb.core
dev=usb.core.find(idVendor=0x067b,idProduct=0x2303)
ep=dev[0].interfaces()[0].endpoints()[0]
i=dev[0].interfaces()[0].bInterfaceNumber
dev.reset()
if dev.is_kernal_driver_active(i):
dev.detach_kernal_driver(i)
dev.set_configuration()
eaddr=ep.bEndpointAddress
r=dev.read(eaddr,1024)
print(len(r))
When I try to execute the script while the multimeter is reading a voltage, I receive the following error message:
Traceback (most recent call last):
File "usbRead.py", line 6, in <module>
dev.reset()
File "/home/pi/.local/lib/python2.7/site-packages/usb/core.py", line 949, in reset
self._ctx.managed_open()
File "/home/pi/.local/lib/python2.7/site-packages/usb/core.py", line 113, in wrapper
return f(self, *args, **kwargs)
File "/home/pi/.local/lib/python2.7/site-packages/usb/core.py", line 131, in managed_open
self.handle = self.backend.open_device(self.dev)
File "/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 804, in open_device
return _DeviceHandle(dev)
File "/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 652, in __init__
_check(_lib.libusb_open(self.devid, byref(self.handle)))
File "/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 604, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
------------------
(program exited with code: 1)
Press return to continue
My apologies if this is an amateur question, but I've been trying my best to solve the insufficient permissions problem, but every solution I could find is filled with jargon that I'm hopeless in understanding. There was one thread that discussed changing things in a "rule file", and when I tried that, I ended up completely bricking the Raspberry Pi I was using!
Please help a novice like me on how I can be able to get data from this USB multimeter. Thank you so much in advance! I can answer questions for additional information as best I can.

Add GPS to Your Raspberry Pi Project with Google Maps Pubnub

(I'm following this tutorial : https://www.pubnub.com/blog/raspberry-pi-gps-lte-google-maps-api/ and I use a Raspberry pi 4 model B connected trough wifi )
I carefully followed all steps carefully untill I tried to run the modified gps_simpletest.py file. When I try to run it I get the following error:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 323, in _rec onfigure_port
orig_attr = termios.tcgetattr(self.fd)
termios.error: (5, 'Input/output error')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "gps_simpletest.py", line 21, in <module>
uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=10)
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 240, in __ini t__
self.open()
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 272, in open
self._reconfigure_port(force_update=True)
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 326, in _rec onfigure_port
raise SerialException("Could not configure port: {}".format(msg))
serial.seria
I'm pretty sure I installed all modules, libraries, ....
Any help would be much appreciated!Thanks in advance

Coudl not find video device with name [integrated camera]amoung source devices of type video

Im testing aiortc becouse i wanna stream webcam audio and video to browser but when im trying to run webcam.py i get I/O error I/O error: 'video=Integrated Camera'
CODE IS HERE on github
Traceback (most recent call last):
File "C:\Users\user\Desktop\New folder\env\lib\site-packages\aiohttp\web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "C:\Users\user\Desktop\New folder\env\lib\site-packages\aiohttp\web_app.py", line 499, in _handle
resp = await handler(request)
File "webcam.py", line 69, in offer
audio, video = create_local_tracks(args.play_from)
File "webcam.py", line 36, in create_local_tracks
"video=Integrated Camera", format="dshow", options=options
File "C:\Users\user\Desktop\New folder\env\lib\site-packages\aiortc\contrib\media.py", line 238, in __init__
self.__container = av.open(file=file, format=format, mode="r", options=options)
File "av\container\core.pyx", line 355, in av.container.core.open
File "av\container\core.pyx", line 226, in av.container.core.Container.__cinit__
File "av\container\core.pyx", line 258, in av.container.core.Container.err_check
File "av\error.pyx", line 336, in av.error.err_check
av.error.OSError: [Errno 5] I/O error: 'video=Integrated Camera'
Okey if you get this error you need to check names of your devices with ffmpeg
windows
ffmpeg -list_devices true -f dshow -i dummy
linux
v4l2-ctl --list-devices
and get correct names for your devices and change them accordingly

Categories

Resources