Open TangoRom opened 8 years ago
You can easily set the GPS coordinates manually in the code or remove them entirely. Rain Bucket -> Just connect one of the two wires to the pin indicated in your code (the interrupts). Wind Vane -> I took my wind vane apart to determine which two wires i needed. I think mine were the red and black). I gave one side (Black i think) 3.3v (assuming thats what your MCP3008) is getting. The other (Red) goes to ground. In line with the Vin I have a wire going to channel 3 on the MCP3008. Anemometer -> same as rain bucket (I think yellow and green).
MCP3008 -> http://www.raspberrypi-spy.co.uk/2013/10/analogue-sensors-on-the-raspberry-pi-using-an-mcp3008/ That link should give you a decent idea at what you are looking at. Remember, in the code as is, we are not using SPI for the MCP3008 so that link should only be used for understanding of wiring.
Software -> I had a look here and brought some of the conversions etc for windspeed: https://github.com/switchdoclabs/WeatherPi https://github.com/switchdoclabs/SDL_Pi_Weather_80422
Notes: -I used a 10k resistor in line with the vin side of the wind vane a lot like you would with the light sensor. -The MCP3008 gives you a value ranging from 0 - 1023 based on voltage on that channel. You will need to be able to convert that to voltage and then into degrees (in the case of the windvane). You can find other methods for changing degrees into capital wind direction if you are interested in that.
Ex: (Only code relevant to windvane included) some of this is unnecessary.
GPIO.setmode(GPIO.BOARD)
SPICLK = 23 #17
SPIMISO = 21 #24
SPIMOSI = 19 #25
SPICS = 24 #27
winddir_adc = 2
# read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)
def readadc(adcnum, clockpin, mosipin, misopin, cspin):
if ((adcnum > 7) or (adcnum < 0)):
return -1
GPIO.output(cspin, True)
GPIO.output(clockpin, False) # start clock low
GPIO.output(cspin, False) # bring CS low
commandout = adcnum
commandout |= 0x18 # start bit + single-ended bit
commandout <<= 3 # we only need to send 5 bits here
for i in range(5):
if (commandout & 0x80):
GPIO.output(mosipin, True)
else:
GPIO.output(mosipin, False)
commandout <<= 1
GPIO.output(clockpin, True)
GPIO.output(clockpin, False)
adcout = 0
# read in one empty bit, one null bit and 10 ADC bits
for i in range(12):
GPIO.output(clockpin, True)
GPIO.output(clockpin, False)
adcout <<= 1
if (GPIO.input(misopin)):
adcout |= 0x1
GPIO.output(cspin, True)
adcout >>= 1 # first bit is 'null' so drop it
return adcout
# convert light into percent
def ConvertVoltage(data, supplyVolt):
voltage = data/1024. * supplyVolt #// convert to voltage value
return voltage
def ConvertPercent (data, supplyVolt, places):
percent = (data / supplyVolt) * 100
percent = round(percent,places)
return percent
def fuzzyCompare(compareValue, value):
VARYVALUE = 0.05
if ( (value > (compareValue * (1.0-VARYVALUE))) and (value < (compareValue *(1.0+VARYVALUE))) ):
return True
return False
def voltageToDegrees(value, defaultWindDirection):
ADJUST3OR5 = 0.66
PowerVoltage = 3.3
if (fuzzyCompare(3.84 * ADJUST3OR5, value)):
return 0.0
if (fuzzyCompare(1.98 * ADJUST3OR5, value)):
return 22.5
if (fuzzyCompare(2.25 * ADJUST3OR5, value)):
return 45
if (fuzzyCompare(0.41 * ADJUST3OR5, value)):
return 67.5
if (fuzzyCompare(0.45 * ADJUST3OR5, value)):
return 90.0
if (fuzzyCompare(0.32 * ADJUST3OR5, value)):
return 112.5
if (fuzzyCompare(0.90 * ADJUST3OR5, value)):
return 135.0
if (fuzzyCompare(0.62 * ADJUST3OR5, value)):
return 157.5
if (fuzzyCompare(1.40 * ADJUST3OR5, value)):
return 180
if (fuzzyCompare(1.19 * ADJUST3OR5, value)):
return 202.5
if (fuzzyCompare(3.08 * ADJUST3OR5, value)):
return 225
if (fuzzyCompare(2.93 * ADJUST3OR5, value)):
return 247.5
if (fuzzyCompare(4.62 * ADJUST3OR5, value)):
return 270.0
if (fuzzyCompare(4.04 * ADJUST3OR5, value)):
return 292.5
if (fuzzyCompare(4.34 * ADJUST3OR5, value)): # chart in manufacturers documentation wrong
return 315.0
if (fuzzyCompare(3.43 * ADJUST3OR5, value)):
return 337.5
return defaultWindDirection # return previous value if not found
def windDirectionFromDegrees (Degrees):
if (348.75 <= Degrees <= 360.00):
hour1WindDirection = "N"
elif (0 <= Degrees <= 11.25):
hour1WindDirection = "N"
elif (11.25 < Degrees <= 33.75):
hour1WindDirection = "NNE"
elif (33.75 < Degrees <= 56.25):
hour1WindDirection = "NE"
elif (56.25 < Degrees <= 78.75):
hour1WindDirection = "ENE"
elif (78.75 < Degrees <= 101.25):
hour1WindDirection = "E"
elif (101.25 < Degrees <= 123.75):
hour1WindDirection = "ESE"
elif (123.75 < Degrees <= 146.25):
hour1WindDirection = "SE"
elif (146.25 < Degrees <= 168.75):
hour1WindDirection = "SSE"
elif (168.75 < Degrees <= 191.25):
hour1WindDirection = "S"
elif (191.25 < Degrees <= 213.75):
hour1WindDirection = "SSW"
elif (213.75 < Degrees <= 236.25):
hour1WindDirection = "SW"
elif (236.25 < Degrees <= 258.75):
hour1WindDirection = "WSW"
elif (258.75 < Degrees <= 281.25):
hour1WindDirection = "W"
elif (281.25 < Degrees <= 303.75):
hour1WindDirection = "WNW"
elif (303.75 < Degrees <= 326.25):
hour1WindDirection = "NW"
elif (326.25 < Degrees < 348.75):
hour1WindDirection = "NNW"
else:
hour1WindDirection = nil
return hour1WindDirection
def AdjustWindDir(data,adjustor):
#if current wind direction in degrees is less than 90
if (data < adjustor):
#add 360 before subtracting 90
adjustedwinddir = (data + 360.00) - adjustor
#otherwise, simply subtract 90
else:
adjustedwinddir = (data - adjustor)
#return the compensated value
return adjustedwinddir
# Main Loop
if __name__ == '__main__':
try:
# gpsp.start() # start it up
while (runner == True):
winddir_level = readadc(winddir_adc, SPICLK, SPIMOSI, SPIMISO, SPICS)
winddir_voltage = ConvertVoltage (winddir_level, 3.3)
winddir = voltageToDegrees(winddir_voltage, lastwinddir)
#Mounted windvane improperly (not facing north) so adjusting in the software
winddir = AdjustWindDir(winddir, 87)
lastwinddir = winddir
capitalwinddir = windDirectionFromDegrees(winddir)
Daniel Pile
@zxPILEDRIVERxz 's post had a lot of good information in it, that should hopefully help.
As was stated for GPS, you don't need it, you can just plug in the coordinates. If you do want to use a chip, then for the one I used I had to hook the data pin on to the UART_RXD pin for the Pi, which is GPIO 15. Chances are a similar GPS would probably do the same.
I used the MCP008 in another project, the schematic for that may be helpful for figuring out your setup a little better. The schematic is here: https://github.com/kmkingsbury/raspberrypi-data-acq/tree/master/schematics
The Adafruit site also has a pretty good tutorial for that chip: https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi
I haven't used the sparkfun weather sensors, but they're modeled off the same component, their pinout is in the doc (at https://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf) and looks accurate. You're using pin 1 and 4 in the jack and take the voltage reading from the pi, that voltage will correspond to a direction. I really liked the code @zxPILEDRIVERxz posted for that, explains it out well. And as you can see at the end of the code, direction depends on orientation so if you don't align the wind vane to North then you might have to do a little calibrating to figure out what voltage reading corresponds with which direction.
do you know the coding of wind vane with adc mcp3008? i have a project for weather station. please help us
Hello, has anyone managed to reproduce this station? I still have a lot of questions about wiring (ldr, mpc3008 ...) all sensors have to go through the mpc3008? i use the maplin wind vane.
I totally gave up. Mine was so close to be completed but got lots of errors running the code, I personally couldn't fix it.I've switched to this one, less headache: GroveWeatherPi - Solar Raspberry Pi based Weather Station - No Soldering Required (Updated October 24, 2016)
|
GroveWeatherPi - Solar Raspberry Pi based Weather Station - No Soldering Re... Building a Solar Powered Raspberry Pi Weather Station - GroveWeatherPi (Updated October 25, 2016)The Raspberry P... | |
|
|
"A clever person solves a problem. A wise person avoids it."
A.Einstein
From: orega35 <notifications@github.com>
To: kmkingsbury/raspberrypi-weather-station raspberrypi-weather-station@noreply.github.com Cc: OKenobi tangorom@yahoo.com; Author author@noreply.github.com Sent: Tuesday, January 24, 2017 4:33 AM Subject: Re: [kmkingsbury/raspberrypi-weather-station] stuck in the middle... (#8)
Hello, has anyone managed to reproduce this station? I still have a lot of questions about wiring (ldr, mpc3008 ...) all sensors have to go through the mpc3008? i use the maplin wind vane.— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
too bad. I teach in a college and in club we try to run this station with server. It seems to me very well, but it is true that it lacks some explanations to the " instructables". I will continue....
i know... but hey, good luck and please keep me posted in case you get to the bottom of it; thanks --Obiwan
"A clever person solves a problem. A wise person avoids it."
A.Einstein
From: orega35 <notifications@github.com>
To: kmkingsbury/raspberrypi-weather-station raspberrypi-weather-station@noreply.github.com Cc: OKenobi tangorom@yahoo.com; Author author@noreply.github.com Sent: Wednesday, January 25, 2017 2:50 PM Subject: Re: [kmkingsbury/raspberrypi-weather-station] stuck in the middle... (#8)
too bad. I teach in a college and in club we try to run this station with server. It seems to me very well, but it is true that it lacks some explanations to the " instructables". I will continue....— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
@orega35 Perhaps you could precise to me exactly what you need help on. I'm going to go ahead and begin to answer based on your previous post. Hello, has anyone managed to reproduce this station?
Wiring the MCP3008:
All sensors have to go through MCP3008:
Wiring the Light dependent resistor.
OK thanks for your answer. I'll test it all! Can I contact you again if necessary?
Of course, here is my site if it gives you any inspiration.
Great job !
I will see what my students will produce. I must not give them too many examples!
Le 26/01/2017 à 20:10, zxPILEDRIVERxz a écrit :
Of course, here is my site if it gives you any inspiration.
http://weather.danielpile.com:8080/
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kmkingsbury/raspberrypi-weather-station/issues/8#issuecomment-275481882, or mute the thread https://github.com/notifications/unsubscribe-auth/AQYu0OVPTognpxlS3pAF7xQcJN_9u3edks5rWO-VgaJpZM4HABZj.
Happy New Year, Kevin!
Hope you'll have a blast in 2016.
I'm planning to build the weather station project you've created. got the parts but I'm stuck. I REALLY need your help, brother! As not so experienced (yet :)) I need some guidlines connecting my components. following the diagram .fzz.file didn't help me much. I hope that you'll help me build this as I already invested time and money towards this great project.
What I have purchased so far: RPI2/Raspberry Pi camera Adafruit BMP180 pressure sensor Adafruit DHT 22 humidity sensor Adafruit MCP3008 Sparkfun Weather Meater https://www.sparkfun.com/products/8942 (got this just to save time building it)
tested individually BMP180 and DHT22 work fine, connected to Rpi2 GPIO as: BMP180: VIN - Pin #1 GND - Pin #6 SCL - Pin #5 SDA - Pin #3
DHT22: VDD - Pin #1 DATA - Pin #4 NULL GND - Pin #6
I don't use a GPS and light sensor; What I don't know where to connect: the Tipping Bucket Rain Gauge (2 wire conductor RJ11) the Wind Vane (4 wire conductor on RJ11); (the Anemometer gets connected to Wind Vane with a 2 wire conductor RJ11, I guess). I know your code is using BMP183, which is an SPI sensor as opossed the one I've purchased. Can you please give me some instructions so I can finish this? I don't want to give up on this, as I said, I've found it amazing, but I'm really stuck right now. Hope you understand my pain :)
thank you, much appreciated and looking fwd hearing from you!
Ovi TangoRom@yahoo.com
PS: forgot to tell you about MCP3008 connections. help on this one, too, please :)