|
Post by T3chDad® on Jan 26, 2019 13:34:52 GMT -8
Sanity check please. I've purchased and received the Weather Rack sensors, The RJ11-Grove Interface Board and an ADS1115. I'm using a RPi model 3. I'm pretty sure I've got the software and RPi parts covered. The SwitchDoc stuff that has me a little confused. I've scoured the intarwebs, your tutorials, and support forums...but I'm not sure it has clicked for me. Documents I've referenced: Below is my best theory on how to get the wind sensors wired correctly. Wrong (see next post).  ...or is it connected using only a Grove cable like this? This is wrong too.   Any help would be greatly appreciated. Thank you.
|
|
|
Post by T3chDad® on Jan 26, 2019 15:50:39 GMT -8
I did some poking around with my multimeter. My first guess above is wrong. The RJ-11 pins are not straight through to the grove connectors. Below is the pinout for the RJ-11 -> Grove Interface Board. Things are starting to click a little...I'll keep at it!  
|
|
|
Post by T3chDad® on Jan 27, 2019 12:32:49 GMT -8
Okay, I have everything working. Here is my wiring. This isn't the only way to wire this setup, but it's how I chose to do it. You can use any GPIOs you wish for the rain bucket and anemometer.  Once everything was wired-up, I used the following script to test the anemometer and rain bucket. (You need to have gpiozero library installed) from gpiozero import Button
wind_speed_sensor = Button(5) #GPIO 5 wind_count = 0 rain_sensor = Button(26) #GPIO 26 rain_count = 0
def wind(): global wind_count wind_count = wind_count + 1 print("wind" + str(wind_count))
wind_speed_sensor.when_pressed = wind
def rain(): global rain_count rain_count += 1 print("rain" + str(rain_count)) rain_sensor.when_pressed = rain
The output should look like this. Every time the rain bucket is tipped or the anemometer completes one revolution, you will see the number increment.  To test the Wind Vane I used a script I found on SwitchDoc's git: github.com/switchdoclabs/SDL_Pi_Grove4Ch16BitADC This was by far the simplest way I found to test the Wind Vane and the ADS1115. It didn't require editing the scripts or installing libraries. Just download the zip or clone the git and extract/run. #!/usr/bin/python
#SwitchDoc Labs May 2016 # reads all four channels from the Grove4Ch16BitADC Board in single ended mode # also reads raw values # import time, signal, sys sys.path.append('./SDL_Adafruit_ADS1x15')
import SDL_Adafruit_ADS1x15 def signal_handler(signal, frame): print( 'You pressed Ctrl+C!') sys.exit(0) signal.signal(signal.SIGINT, signal_handler)
ADS1115 = 0x01 # 16-bit ADC
# Select the gain gain = 6144 # +/- 6.144V #gain = 4096 # +/- 4.096V # gain = 2048 # +/- 2.048V # gain = 1024 # +/- 1.024V # gain = 512 # +/- 0.512V #gain = 256 # +/- 0.256V
# Select the sample rate #sps = 8 # 8 samples per second # sps = 16 # 16 samples per second # sps = 32 # 32 samples per second # sps = 64 # 64 samples per second # sps = 128 # 128 samples per second sps = 250 # 250 samples per second # sps = 475 # 475 samples per second # sps = 860 # 860 samples per second
# Initialise the ADC using the default mode (use default I2C address) adc = SDL_Adafruit_ADS1x15.ADS1x15(ic=ADS1115) while (1): # Read channels in single-ended mode using the settings above print ("--------------------") voltsCh0 = adc.readADCSingleEnded(0, gain, sps) / 1000 rawCh0 = adc.readRaw(0, gain, sps) print ("Channel 0 =%.6fV raw=0x%4X dec=%d" % (voltsCh0, rawCh0, rawCh0)) voltsCh1 = adc.readADCSingleEnded(1, gain, sps) / 1000 rawCh1 = adc.readRaw(1, gain, sps) print ("Channel 1 =%.6fV raw=0x%4X dec=%d" % (voltsCh1, rawCh1, rawCh1)) voltsCh2 = adc.readADCSingleEnded(2, gain, sps) / 1000 rawCh2 = adc.readRaw(2, gain, sps) print ("Channel 2 =%.6fV raw=0x%4X dec=%d" % (voltsCh2, rawCh2, rawCh2)) voltsCh3 = adc.readADCSingleEnded(3, gain, sps) / 1000 rawCh3 = adc.readRaw(3, gain, sps) print ("Channel 3 =%.6fV raw=0x%4X dec=%d" % (voltsCh3, rawCh3, rawCh3)) print ("--------------------") time.sleep(1)
The output should look like this. Every time you rotate the wind vane, the voltage should change.  Now it's time to write all of my code. I'm building a custom weather station for my RC aircraft club so members can check the conditions before they come out and see the real-time data on a 32" TV at the field. Thanks for listening as I sorted through this learning experience.  I hope this helps someone if they need this information in the future.
|
|
|
Post by SDL on Jan 27, 2019 16:10:35 GMT -8
Awesome set of posts. That will help others who have the same problem. The anemometer, rain bucket and wind vane all have 10K ohm pull-ups.
Bp
|
|