Skip to content Skip to sidebar Skip to footer

How To Change My Wxpython Program That Read And Display Rain Sensor Data From Mcp3008 To Software Spi?

I have a completed wxpython code that can read data from rain sensor and convert it from analogue to digital with mcp3008. The problem is the current raspberry pi that I use, alrea

Solution 1:

Without knowing what Adafruit_MCP3008 is returning and without access to the hardware to be able to test it, I suspect that your existing line:

r = spi.xfer2([1, (8+channel) << 4, 0])

should be replaced by:

r = [0]*8
for i in range(8):
    # The read_adc function will get the value of the specified channel (0-7).
    r[i] = mcp.read_adc(i) 

The only way to know for sure would be to print out r as it is in your current set up and then do the same for the new one, to see if there are any differences and what they are.

Post a Comment for "How To Change My Wxpython Program That Read And Display Rain Sensor Data From Mcp3008 To Software Spi?"