Okay, so I was able to get the code to work. I needed to download another library "Adafruit_GPIO". However, I am no encountering a new problem that I believe is raspberry pi specific. I am using a raspberry pi zero 2W with a MCP3008 ADC using python 3. The MCP3008 is using a 3.3V power supply. So i have four separate sensor scripts ready to run (code pasted below for sensor 1). I have four REV-C wind sensors hooked up with each requiring connections to 2 channels of the ADC (channel 0 & 1 goes to one REV-C sensor). Each REV-C sensor requires a GND and a 5 Volt connection to the raspberry pi. I am using 2 breadboard rails (GND and +5 V) and connecting all 4 sensors to the GND and 5V rail. If i unplug 3 of the sensors from the GND and +5V rail I am able to get the data i need (wind speed in mps that fluctuates by breathing on it). If i plug 2 or more sensors into GND and +V of the two rails, the code just displays a static number where the volts are saturated (meaning the meters per second is the max that the device will output). Each sensor requires 5V, and will consume only 20-40mA. Is there a problem with all four sensors being powered in parallel? This is the code for sensor 1,
import time
import Adafruit_MCP3008
TMP_1=0
RV_1=1
# To calibrate your sensor
zeroWindAdjustment = -1.6 # Negative numbers yield smaller wind speeds and vice versa
mcp=Adafruit_MCP3008.MCP3008(clk=18,cs=25,miso=23,mosi=24)
while True:
TMP_Therm_ADunits = mcp.read_adc(TMP_1)
RV_Wind_ADunits = mcp.read_adc(RV_1)
RV_Wind_Volts = RV_Wind_ADunits * 0.0048828125
TempCtimes100 = (0.005 * (float(TMP_Therm_ADunits) * float(TMP_Therm_ADunits))) - (16.862 * float(TMP_Therm_ADunits)) + 9075.4
zeroWind_ADunits = -0.0006 * (float(TMP_Therm_ADunits) * float(TMP_Therm_ADunits)) + 1.0727 * float(TMP_Therm_ADunits) + 47.172
zeroWind_volts = (zeroWind_ADunits * 0.0048828125) - zeroWindAdjustment
try:
WindSpeed_MPH = ((RV_Wind_Volts - zeroWind_volts) / 0.2300) ** 2.7265
WindSpeed_MPS = WindSpeed_MPH * 0.44704
except:
S1=None
print("----------------------")
print("MPS_1: ", S1)
time.sleep(1)
import time
import Adafruit_MCP3008
TMP_1=0
RV_1=1
# To calibrate your sensor
zeroWindAdjustment = -1.6 # Negative numbers yield smaller wind speeds and vice versa
mcp=Adafruit_MCP3008.MCP3008(clk=18,cs=25,miso=23,mosi=24)
while True:
TMP_Therm_ADunits = mcp.read_adc(TMP_1)
RV_Wind_ADunits = mcp.read_adc(RV_1)
RV_Wind_Volts = RV_Wind_ADunits * 0.0048828125
TempCtimes100 = (0.005 * (float(TMP_Therm_ADunits) * float(TMP_Therm_ADunits))) - (16.862 * float(TMP_Therm_ADunits)) + 9075.4
zeroWind_ADunits = -0.0006 * (float(TMP_Therm_ADunits) * float(TMP_Therm_ADunits)) + 1.0727 * float(TMP_Therm_ADunits) + 47.172
zeroWind_volts = (zeroWind_ADunits * 0.0048828125) - zeroWindAdjustment
try:
WindSpeed_MPH = ((RV_Wind_Volts - zeroWind_volts) / 0.2300) ** 2.7265
WindSpeed_MPS = WindSpeed_MPH * 0.44704
except:
S1=None
print("----------------------")
print("MPS_1: ", S1)
time.sleep(1)
Statistics: Posted by Wildman120 — Fri Mar 21, 2025 10:06 pm