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
Related
so I bought a thermal printer thinking I could use his usb port with python 3.9.7 to print with it but I get this error message:
c:/Users/gabpe/OneDrive/Documents/Python/Projet/Billing/TP_Test.py
Traceback (most recent call last):
File "c:\Users\gabpe\OneDrive\Documents\Python\Projet\Billing\TP_Test.py", line 6, in <module>
p = Usb(0x416, 0x5011)
File "C:\ProgramData\AnacondaML\lib\site-packages\escpos\printer.py", line 51, in __init__
self.open()
File "C:\ProgramData\AnacondaML\lib\site-packages\escpos\printer.py", line 68, in open
self.device.detach_kernel_driver(0)
File "C:\ProgramData\AnacondaML\lib\site-packages\usb\core.py", line 1121, in detach_kernel_driver
self._ctx.backend.detach_kernel_driver(
File "C:\ProgramData\AnacondaML\lib\site-packages\usb\backend\libusb0.py", line 662, in detach_kernel_driver
raise NotImplementedError(self.detach_kernel_driver.__name__)
NotImplementedError: detach_kernel_driver
This is the code I'm using for now:
from escpos.printer import Usb
TPrinter = Usb(0x416, 0x5011)
TPrinter.text("Please work\n")
TPrinter.close()
Just a basic thing to get me started. '0x416', '0x5011', '0x8', '0x1' this is my printer: idVendor, idProduct, address and bus. I'm using Windows 10 and I didn't install any driver for the thermal printer, which seems to be the problem as I saw on another post, but I don't know if I can do it without or if I need and driver or something and which driver to use, or maybe if there's another library I could use. Thx
I'm working on interfacing an old Optical Spectrum Analyzer Anritsu MS9710B with a RS232 connection. A year ago, I managed to comunicate with him, send SCPI command using pyvisa and receive data. Today, I execute the exact same code with libraries up to date and I get an error Timeout when I query IDN or anything. The RS232-USB drivers are ok, I manage to open a communication but a query or read fail.
I changed the parameter to "RS232C" on the OSA parameters and my communication parameters are the same between OSA and program. Following advices from the forum, I tried the connection with NI-VISA where I get the same error. I tried to change timeout parameter, write_termination and read_termination but there isn't any change. The manual is very hard to understand termination value, but when it worked I didn't add anything.
I don't know anymore what to do.
Any advices and help would be warmly welcome to fix my problem !
import pyvisa
from pyvisa.constants import StopBits, Parity
rm = pyvisa.ResourceManager()
print(rm.list_resources())
my_instrument = rm.open_resource('ASRL5::INSTR')
my_instrument.baud_rate=9600
my_instrument.data_bits=8
my_instrument.parity=Parity.even
my_instrument.stop_bits=StopBits.one
my_instrument.write('*IDN?')
print(my_instrument.read())```
'''
('ASRL5::INSTR',)
Traceback (most recent call last):
File "PremiereComm.py", line 26, in <module>
print(my_instrument.read())
File "C:\Program Files\Python38\lib\site-packages\pyvisa\resources\messagebased.py", line 486, in read
message = self._read_raw().decode(enco)
File "C:\Program Files\Python38\lib\site-packages\pyvisa\resources\messagebased.py", line 442, in _read_raw
chunk, status = self.visalib.read(self.session, size)
File "C:\Program Files\Python38\lib\site-packages\pyvisa\ctwrapper\functions.py", line 2337, in read
ret = library.viRead(session, buffer, count, byref(return_count))
File "C:\Program Files\Python38\lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 222, in _return_handler
return self.handle_return_value(session, ret_value) # type: ignore
File "C:\Program Files\Python38\lib\site-packages\pyvisa\highlevel.py", line 251, in handle_return_value
raise errors.VisaIOError(rv)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
>>> '''
I am using Pyo (http://ajaxsoundstudio.com/software/pyo/) in Python 2.7.14 and I an trying to play an audio file with this code
from pyo import *
s = Server()
s.boot()
s.start()
sf = SfPlayer("C:\Users\name\Downloads\audio.mp3", speed=1, loop=True).out()
but I get this message:
Traceback (most recent call last):
File "C:\Python27\pyotest.py", line 5, in <module>
sf = SfPlayer("C:\Users\name\Downloads\audio.mp3", speed=1, loop=True).out()
File "C:\Python27\lib\site-packages\pyolib\players.py", line 98, in __init__
PyoObject.__init__(self, mul, add)
File "C:\Python27\lib\site-packages\pyolib\_core.py", line 967, in __init__
PyoObjectBase.__init__(self)
File "C:\Python27\lib\site-packages\pyolib\_core.py", line 809, in __init__
raise PyoServerStateException("The Server must be booted before "
PyoServerStateException: The Server must be booted before creating any audio object.
I had the same error once (on Windows). Started the E-Pyo Editor that comes with installing Pyo. After that it worked fine.
If that doesn't help you might want to set the server options and the output device manually.
Get the ID of the desired output device with
pa_list_devices()
If you found your ID you can set it with this command (change the 0 to your device ID) and then boot the server:
s.setOutputDevice(0)
s.boot()
I am trying to get the usb.find command to work properly in a python script I'm writing on Angstrom for the Beagleboard.
Here is my code:
#!/usr/bin/env python
import usb.core
import usb.util
import usb.backend.libusb01 as libusb
PYUSB_DEBUG_LEVEL = 'debug'
# find our device
# Bus 002 Device 006: ID 1208:0815
# idVendor 0x1208
# idProduct 0x0815
# dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
# iManufacturer 1 TOROBOT.com
dev = usb.core.find(idVendor=0x1208, idProduct=0x0815,
backend=libusb.get_backend() )
I don't know what's missing, but here is what I do know.
When I don't specify the backend, no backend is found. When I do specify the backend "usb.backend.libusb01" I get the following error:
root#beagleboard:~/servo# ./pyServo.py
Traceback (most recent call last):
File "./pyServo.py", line 17, in <module>
dev = usb.core.find(idVendor=0x1208, idProduct=0x0815, backend=libusb.get_backend() )
File "/usr/lib/python2.6/site-packages/usb/core.py", line 854, in find
return _interop._next(device_iter(k, v))
File "/usr/lib/python2.6/site-packages/usb/_interop.py", line 60, in _next
return next(iter)
File "/usr/lib/python2.6/site-packages/usb/core.py", line 821, in device_iter
for dev in backend.enumerate_devices():
File "/usr/lib/python2.6/site-packages/usb/backend/libusb01.py", line 390, in enumerate_devices
_check(_lib.usb_find_busses())
File "/usr/lib/python2.6/ctypes/__init__.py", line 366, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python2.6/ctypes/__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: usb_find_busses
What am I missing so that this will work properly?
Thank you.
Python, pyusb, libusb.
I think that's it.
Well libc, ld-linux.so too of course, but those are in your system by default.
Do nm -D /path-to/libusb.so and see if usb_find_busses symbol is really there. There's always a chance that your libusb is outdated or somehow specially compiled.
Check if you get any log, for example missing libusb.so should produce something like 'Error loading libusb 0.1 backend'
I have a Keithley 2701 DMM and I am trying to communicate with it via TCPIP using python 2.7 and pyVISA. I am running python 2.7 with virtualenv and wxPython. I know the device is active because I can ping the IP address, I am trying to access the machine using the following code:
from pyvisa.vpp43 import visa_library
visa_library.load_library("/Library/Frameworks/Visa.framework/VISA")
import visa import instrument
Keithley = visa.instrument("TCPIP::192.168.0.2::INSTR")
when I run the code I get the following error:
Traceback (most recent call last):
File "Keithley.py", line 4, in <module>
Keithley = visa.instrument("TCPIP::192.168.0.2::INSTR")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyVISA-1.4-py2.7.egg/pyvisa/visa.py", line 294, in instrument
return Instrument(resource_name, **keyw)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyVISA-1.4-py2.7.egg/pyvisa/visa.py", line 358, in __init__
"lock")))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyVISA-1.4-py2.7.egg/pyvisa/visa.py", line 132, in __init__
keyw.get("lock", VI_NO_LOCK))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyVISA-1.4-py2.7.egg/pyvisa/vpp43.py", line 753, in open
byref(vi))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyVISA-1.4-py2.7.egg/pyvisa/vpp43.py", line 398, in check_status
raise visa_exceptions.VisaIOError, status
pyvisa.visa_exceptions.VisaIOError: VI_ERROR_RSRC_NFOUND: Insufficient location information or the requested device or resource is not present in the system.
Any help will be greatly appreciated....
V
I have not played with this particular DMM, but I have connected to several other devices using your same setup.
1) Check your documentation / DMM to ensure that the board number is in fact zero. Otherwise you'll need to change the following line:
Keithley = visa.instrument("TCPIP::192.168.0.2::INSTR")
To something more like
Keithley = visa.instrument("TCPIP1::192.168.0.2::INSTR")
2) Try to use a raw SOCKET connectional rather than the typical INSTR method.
NI Socket Examples
Keithley 2701 Examples
If I can dream up anything else I will update my response.