![adafruit trinket i2c adafruit trinket i2c](https://mythopoeic.org/wp-content/uploads/2014/02/DSC03067.jpg)
read pin 3 analog value of wind direction sensor anemometer counts interrupts for 10 second interval. Sbi(PCMSK,PCINT4) // Which pins are affected by the interrupt.
![adafruit trinket i2c adafruit trinket i2c](https://cdn-shop.adafruit.com/970x728/4570-06.jpg)
Sbi(PCMSK,PCINT1) // Which pins are affected by the interrupt. Sbi(GIMSK,PCIE) // Turn on Pin Change interrupt if requested position is 7, reset rain gauge variable. Function to set which register positions you wish to receive Function to send data when it is requested. Volatile int val2 = 0 // pin 4 value at interrupt Volatile int val1 = 0 // pin 1 value at interrupt Volatile unsigned long last_micros_wind // micros since last anemometer interrupt Long debouncing_time_wind = 100 //Debouncing Time in Milliseconds for anemometer Volatile unsigned long last_micros_rain // micros since last rain gauge interrput Long debouncing_time_rain = 300 //Debouncing Time in Milliseconds for rain gauge Volatile int windSpeedSend = 0 // used to send 10 second interrupt value to pi Volatile int windDirection = 0 // keep track of value of wind direction sensor Volatile int windSpeed = 0 // keep track of interrupts from anemometer Volatile int rainGauge = 0 // keep track of interrupts from rain gauge Volatile byte reg_position // keep track of reg position sent from master #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) Here is what I use which tracks the sensors and sends the data via I2C:
#Adafruit trinket i2c code
Then a portion of 1 1/2″ pipe (I think it’s 12 inches long) and then connect it back to another 1″ piece of pipe to mount it.īefore wiring up your trinket, make sure you upload the code to it. (You can see this bulge in the pic above) I use some connectors to move from 1″ to 1 1/2″ pipe. The idea is to house the trinket in some 3/4″ pipe that is waterproofed and have it sit inside some 1 1/2″ pipe. The lower mast is where the trinket comes in…I connect all the sensor wires to a single cat 5 cable to connect to trinket and then another wire for the I2C communication. (Sorry, but I don’t have any pics of this…) I then use another portion of 3 or so inches of 1″ pvc pipe to connect to the lower portion. I then use a small piece of 1 inch pipe (about 3 or so inches) to connect another T-connector for the anemometer.
![adafruit trinket i2c adafruit trinket i2c](https://cdn-learn.adafruit.com/assets/assets/000/097/884/medium640/circuitpython_Essentials_I2C_CPX_bb.jpg)
I used a piece of cedar fence board to secure the sensor, then some u-bolts to attach the board to a 1 inch pvc pipe, plugged one end and drilled a hole for the wire to run through.įor the rest of the top part of the mast I use a 1″ T-connector at the top with about 8 or so inches of 1″ pipe to connect the anemometer & wind vane. For the rain gauge, it’s a little different. In my anemometer & wind vane posts I have used certain PVC pieces to allow for connection to my mast. I’ve used PVC to build all my sensors as it’s easy to connect together.
![adafruit trinket i2c adafruit trinket i2c](https://cdn-learn.adafruit.com/assets/assets/000/010/772/medium800/trinket_adafruit_products_verifcationfail.gif)
It works with the sensors I built, but I’m sure you could incorporate it to use any sensors you have as well. (This is actually a pic of it at my house for testing) What you’ll need for this is 1 of each of an anemometer, wind vane & rain gauge. Here’s the completed mast with sensors attached. The communication between the two is accomplished using I2C. I had issues with the rain gauge not working too well with the pi directly, so I decided to use an Adafruit Trinket to capture the values of the sensors and send them to the pi for tracking. I finally completed migrating the weather sensors for the weather station that is at my father-in-law’s farm.