Closed beleme closed 7 years ago
@beleme
What does your code look like?
I was able to solve that problem last but now I have this problem
this is my code:
import spidev import opc
spi = spidev.SpiDev() spi.open(0, 0) spi.mode = 1 spi.max_speed_hz = 500000
try: alpha = opc.OPCN2(spi) except Exception as e: print ("Startup Error: {}".format(e)) else: alpha.on() print alpha.histogram() alpha.off()
and I get:
pi@raspberrypi:~ $ python uno.py Startup Error: Your firmware version could not be automatically detected. This is usually caused by a bad wiring or poor power supply. If niether of these are likely candidates, please open an issue on the GitHub repository at https://github.com/dhhagan/py-opc/issues/new
how can I resolve it?
@dhhagan
hello @dhhagan you can helpme with my problem?
@beleme Have you checked the details on the other issue? The most likely cause is a power issue. It's really hard for me to debug it from afar without knowing exactly how you have it wired, what PSU you are using, etc. Can you tell me more about your setup?
@dhhagan ok thanks!
I am connected as is in the py-opc documentation
as is in the picture
@beleme It looks like you're trying to power the OPC-N2 through the GPIO 5V Pin of the RPi..? I don't think that will provide enough current (needs >250 mA); does the OPC-N2 fan ever start?
@dhhagan Yes i am connected the opc with the 5V of the RPi but the fan turns on with that voltage.
The firmware version of OPC-N2 is 18 The version of python is 2.7
Unless you have access to a Logic Analyzer, I would probably focus on trying to get a better voltage source. As mentioned in the docs, you should have a single power source that powers both the Pi and the OPC (not through the GPIO pins).
@dhhagan ok
have i to connect the power of the Pi with the micro-usb? or with the port usb?
@beleme It shouldn't matter, but I have used to microUSB
@dhhagan @DancingQuanta I already connected the OPC and the Pi with power supply and it still gives the same problem. The power supply have 5V and 2A.
How can i solve it?
Can you please attach an image or diagram?
@dhhagan
@beleme Ahh. I didn't realize you were using the breakout from the SPI-USB converter. Although it's hard to tell from the image, I imagine there is a mixed up pin; the SPI-USB converter Alphasense sells is not ordered (i.e. the pin ordering on the micro-clasp side is different than the larger Molex connector). I would follow those back carefully to make sure they are correctly ordered.
The other option is to just directly use the RPi with the SPI-USB converter as shown here. and here.
already i checked, and unfortunately i committed a mistake in the connection with the terminals of OPC but now i have this error
Startup Error: Your firmware is not yet supported. Only versions 14-18 are currently supported.
my OPC-N2 have a firmware version is 18
@dhhagan already I checked, and unfortunately I committed a mistake in the connection with the terminals of OPC but now I have this error
Startup Error: Your firmware is not yet supported. Only versions 14-18 are currently supported.
my OPC have a firmware version 18
@beleme Okay. Your firmware version probably has a minor version as well. Can you let me know what that is?
@dhhagan I keep on with the same problem, I will try with the usb converter
@beleme Try this code from @lionfish0 for start up. import spidev import opc from time import sleep
spi = spidev.SpiDev() spi.open(0, 0)
spi.mode = 0b01 spi.max_speed_hz = 10000
to_send = [0x3F] spi.xfer(to_send);
sleep(1.0) try: alpha = opc.OPCN2(spi) except Exception as e: print ("Startup Error: {}".format(e)) print alpha
print alpha.on() sleep(1.0) #give it time to turn on...
# Read the histogram and print to console
print alpha.histogram()
@JananiVJ Am new to the pi, I have all setup including the above code, I get importEr: No module named opc. How can I install this module?
@semajoel That means you haven't installed the py-opc library. If you go to your terminal and type pip list
, is opc vx.x listed?
@dhhagan i have this listed "py-opc (1.3.0)"
@semajoel missing parentheses could mean that you are using Python 3 not Python 2
@semajoel Interesting. Could you post your code along with the version of python you are using?
@dhhagan and the rest, I appreciate your efforts, i figured something errors out, now I have another spi.open(0,0) IOError: no such file or directory
What is the traceback?
Yes, have enabled SPI in pi configuration, every seems fine for now. I can read from the histogram. I have pm data. Thanks a million.
@DancingQuanta I am using Python 3. and it works for me.
@dhhagan do you have experience working with any other alphasense sensors? the Nitrogen and ozone sensors to be specific.
@JananiVJ I do, yes. You can email me at dhagan@mit.edu for more details/conversation on that topic.
@semajoel So can you confirm what the error was? I'd like to add it to a FAQ since many people have had similar issues.
@dhhagan SPI was not enabled in the configuration of the PI.
Why do I get this type of error?
Startup Error: 'module' object has no attribute 'OPCN2'