Software apps and online services
Hand tools and fabrication machines
This project is the culmination of my first project getting me into hobby electronics when for reasons I have long forgotten I decided to try making an IoT enabled weather station.
After recently getting some new components, purchasing a 3d printer and discovering Adafruit IO I pushed to finish and document this project, my solar powered, Adafruit IO powered weather station.Overview
The project consists of three key areas:
- The Feather M0 micro-controller taking the weather readings and uploading them to Adafruit IO
- Sensors:The BME280 sensor for temperature, pressure and humidity readingsThe SparkFun Weather Meters for wind and rain readings
- The power system consisting of the Sunny Buddy along with the solar cell and battery
The electronics are relatively simple in this project. There is:
- The main Feather board hooked up to a reset button, weather gauges and the BME280.
- The Sunny Buddy hooked up to the solar cell, battery, and power switch.
- The connection from the Sunny Buddy to the Feather providing power.
Reset ButtonThis is the easiest connection. The reset button connects to the Reset and Ground pins on the feather. Solder the button to each pin with a small piece of wire.
BME280The BME280 hooks up via I2C. It requires connections to the Feathers 3.3V, Ground, SDA and SLC pins. There are different options for this connection individual wires or a 4-wire ribbon cable both work. I suggest using a JST or similar connector near the feather so you can plug and unplug the BME280 for easier setup as the sensor will reside in the radiation shield.
In my case the Feather was seated on a small circuit board I made that had holes to wire out to the BME280. A small breadboard or protoboard would work just as well.
Remember to keep the total wire length for the BME280 under 1m (shorter the better).
Weather GaugesThe weather gauge has two connection points both are RJ-11. I suggest buying RJ-11 female connectors to plug these into so you can disconnect them when required. You may also cut the end of the connector to connect the wires directly.
One connector is for the rain gauge. The RJ-11 connector must connect to Ground and Feather pin 11.
The other connector handles the wind speed and direction. The wind speed wires connect to Ground and Feather pin 6. The wind direction requires an analog measurement as the value changes based on the direction the gauge is pointing to. To properly measure this value a voltage divider is required.
The wind direction gauge consists of one pin to ground, the other to a 10K resistor that also ties into Feather pin A2. The other side of the resistor goes to the Feather 3.3V pin.
For more information on hooking up the Sparkfun Weather Gauges see the tutorial on the Sparkfun page.
Sunny BuddySolar ChargerThe Sunny Buddy requires some setup described in its own setup guide. You will have to solder on the connector for the solar panel and configure the potentiometer for the optimal solar charging. Please see the Sparkfun guide to set yours up.
The battery will plug into the battery connector on the Sunny Buddy.
The power switch is connected to one of the load terminals on the Sunny Buddy, soldered by a small wire. The other side of the power switch and the wire from the other load terminal end in a 2 pin JST connector. This connector will plug into the Feather battery connector..
IMPORTANT NOTE ON POWERDo NOT plug the Feather into USB power while the load wires are connected. The Feather has a build in LiPo charger that will attempt to charge the attached battery when it has USB power. But in this setup there is no battery, instead there is the load wires going to the Sunny Buddy. If you need to hook up the USB to for any reason disconnect the JST power connector going to the Feather.
WaterproofingWhile the enclosures should prevent most water from getting on any of the electronics it is still possible. As an extra layer of protection I applied "CorrosionX" to the electronics. It is used in marine applications to help prevent water damage and had good online reviews to protect electronics.Adafruit IO
Adafruit IO is an excellent platform to connect IoT projects to allowing you to easily send data to a service that lets you visualize it and retrieve it later from other devices.
Adafruit has many tutorials on setting up and using the service below is a what is required for this project.
Your first step will be to sign up for an account. After sign-up you will have access to your Adafruit IO Key and Username. You will add these to the config.h file in
#define IO_USERNAME "YOUR USERNAME HERE"
#define IO_KEY "YOUR IO KEY HERE"
The weather station requires creating 9 feeds. They are:
- Battery Voltage
- Wind Direction
- Wind Gust
- Wind Speed
The names are self-explanatory except "Start". Start records the processor reason for a power up/reset. This may be a first power on, or a watch-dog reset. I added it to monitor any exceptions that are happening.
You can view these feeds live as data arrives to them.
You may also create a dashboard. Dashboards allows you to display many feeds in many formats all at once. I created a dashboard showing the feeds in a convenient way for myself.
My station dashboard is: https://io.adafruit.com/Gamblor21/dashboards/weatherCode
The code consists of two main tasks: setup and taking measurements. Most of the included code will work with no changes though some setup is required.
Edit config.hThe config file holds you Adafruit IO username and key, as well as the SSID and password for the WiFi router you will connect to.
Set Your Altitude
// Set this to your location's altitude above sea level in meters
#define ALTITUDE 235
You will have to set your own location's altitude here in meters above sea level. Google maps and other tools can help you determine this value.
Check The Pins
// Pins for the weather gauages. Wind/Rain are digital, Wind direction must be analog
#define VBAT_PIN A7
#define LED_PIN 5
#define WIND_PIN 6
#define RAIN_PIN 11
#define WIND_DIR_PIN A2
If you connected any of the gauges to different pins then I mentioned you will have to change the pin number here.
Setup()As expected the setup function, sets the weather station up to run. The main tasks are:
- Setting pin modes and interrupts on the weather gauge pins
- Setting up and connecting to Adafruit IO
- Initializing the BME280 sensor
- Sending the last reset reason to Adafruit IO
- Resetting the real time clock (RTC) and setting an alarm to wake up in 60 seconds
Loop()The first thing the main loop does is... go to sleep. This allows the station to sit in low power mode until a interrupt goes off, either from a gauge registering a reading or the alarm goes off singling time to take weather measurements.
The next section only runs when the the alarm has gone off. Any other interrupts will skip it and the Feather will go back to sleep.
Every minute when the alarm triggers the following happens:
- Flash the LED (optional this could be turned off)
- Call the
io.run()to ensure data flow to Adafruit IO. This is called several times over the course of the loop or the WINC1500 buffers get full. If you ever notice the WiFi transmit light stuck on this may have occurred.
- Take measurements that happen once a minute
- Check the time and take measurements that happen every two minutes
- Check the time and take measurements that happen every five minutes
- Reset the alarm to trigger at the next minute mark
The timing of the measurements can be easily changed by moving them from one time block to another.
The measure functions read one or more sensor values (or variables that were set by interrupts), optionally does some basic processing and sends the final value to Adafruit IO.
Some values are saved up over a few measurement intervals to get an average value that makes more sense then an instantaneous measurement.
InterruptsThe interrupts allow the Feather to wake up for low power mode when the weather gauges register a reading. They also allow the RTC alarm to trigger every 60 seconds allowing the Feather to wake up from sleeping to take readings.
Any interrupt needs to be written to do a very fast task as nothing else can execute while the interrupt is executing. In the weather station the interrupts either increase a variable or set a flag and exit immediately.3d Printed Components
The Weather Meters come on a 3/4" metal pole so the idea is to mount the other parts to the same pole.
The BME280 is protected by a radiation shield (also referred to as a Stevenson screen). The shield consists of several layers and a bottom piece to protect the sensor from direct sunlight and rain while allowing it to still sense the weather. It was designed to use neodymium magnets to hold sections together to allow future access. I added a handle piece that can be put on the top and bottom to allow the shield to clip to the metal pole of the weather gauges.
Each layer of the shield is printed separately. You will need one of each piece except for two of the middle piece and two of the handles (optional).
The bottom piece is epoxied to one of the middle pieces. And the top piece of epoxied to the other middle piece.
Neodymium magnets are epoxied to the pegs and holes of the holder piece layer. Also attach magnets to the pegs of the top layer (to fit in the sensor layer holes) and to the holes of the bottom section (to attach to the pegs of the sensor layer).
Finally two clips were printed and epoxied to the top and bottom of the shield to attach to the metal pole of the Weather Meters.
The BME280 will attach to the holder piece with a M2.5 screw and nut.
The electronics box holds all the other components that must be protected from the elements. This includes the Feather M0, Sunny Buddy, battery and switches.
The box was designed for the PCB I had for the Feather. That space could fit a small protoboard cut to size as well. There are mounting holes for the Sunny Buddy that take 3.5mm screws.
The bottom of the box has several holes to pass the sensor wires in as well as mounting points for a power switch and reset button.
The top part of the box will slide over the case and snap in place. It was designed with overhangs to help keep out water from rain and snow but it is not waterproof.
Fusion 360 FilesYou can get a copy of the original Fusion 360 files here:Assembly
Your final location for assembly will depend on where you want to measure the weather. The more space around your project the less other objects may affect your readings such as a building blocking the wind or a surface holding heat and raising the temperature.
In this project I chose to mount all the parts to the metal pole that comes with the SparkFun weather gauges. The wind gauges are at the top, followed by the radiation shield, the electronics box and then the rain gauge.
The solar panel is mounted to the other side of the electronics box. It should go without saying that this needs to be pointed towards the area that gets the most sun, preferably angled upwards. By aware the position of the sun can change through-out the year so try to pick an optimal position (or change it as the seasons change).
This has been a long running project that started me deeper into electronics. I am sure that as time goes on I will continue to update and improve on parts of this project. Below is a list of some ideas I had. Feel free to try any of them yourself:
- Detect light levels (day/night detection, clear/cloudy)
- Lightning detector
- Sync the time to the actual time
- Build a separate device to display the weather data inside on a small eInk display
- Aggregate data to more human usable formats
- Experiment with AI for short term weather prediction
I hope you enjoyed the project. Please let me know any feedback, concerns, or errors you see.