Personal weather stations are not only fun and informative projects, but they also serve as an important data source for governments, forecasters, and researchers. In this simple tutorial, we will show you how to build a very low power weather station that measures wind speed, luminosity, temperature, pressure, humidity, air quality, soil moisture, and rain level. Then, measurements will be automatically saved to your preferred storage location! Storage options we will be covering in this tutorial include a microSD card, Google Sheets, Cayenne IoT, and the Blynk IoT App. These services all provide free data storage and visualization. Best of all, your design will fit in the palm of your hand and will harness all the power it needs from the sun. Let's get started!
- TinyZero Processor
- WiFi TinyShield -and/or- MicroSD TinyShield
- 1x Wireling Adapter TinyShield per 4 Wireling sensors
- 1100 mAh LiPo Battery
- MicroUSB Cable
- Solar Cells (optional)
- 2 ping pong balls (optional, used with the laser cut 3D model anemometer)
Any of the below Wireling sensors, depending on your needs:
- Temperature, Pressure, Humidity, and VOC Wireling
- Ambient Light Wireling
- Hall Effect Wireling (measures wind speed by measuring the magnetic field generated by a magnet mounted on your anemometer)
- Moisture Sensor Wireling
- 0.96'' Screen Wireling (if you are interested in a display output of all currently connected Wirelings)
- Wireling Cables (1 for each Wireling you plan to use)
- Arduino IDE
- Weather Code
- Blynk App (iOS, Android) (optional)
- Google Sheets Integration Script (optional)
- Large 3D Anemometer Model -or- Tiny Anemometer Model (optional, used to measure wind speed)
- 3D printer -or- Laser Cutter (optional methods of creating an anemometer)
Step 1: Planning
The build for this project depends on your needs. Here are 5 tips you should keep in mind when choosing your Wirelings, measurement interval, data storage mechanism, and power supply:
- In most cases, the entire weather station consumes about 30mA when using the WiFi TinyShield and less than 1.8mA when using the microSD TinyShield. Both are low enough to be powered by small solar panels, but for true low power needs the choice is clear. Note: if measuring wind speed or using the 0.96'' OLED Wireling, add 13mA to the above figures.
- A great deal of power can be saved by sleeping the processor between measurement intervals. Therefore, a 2-minute measurement interval may have 1/4 the energy usage of a 500-millisecond measurement interval. We have optimized the sleep functionality in the code already, so all you have to do is edit one line of code to change the measurement interval!
- If using solar power, consider that panels rarely perform as well as they claim. In our solar tracker tutorial, we found that the solar panels delivered between 1/3 and 2/3 of their rated output current on overcast and very sunny days respectively.
- If you want to measure wind speed, you will need to either 3D print, laser-cut, or otherwise build an anemometer. 3D models are available for both 3D printing and laser cutting in the software section of the tutorial. The large model is about 3x the size of the tiny model, but you may find it more accurate.
- You can use up to 32 Wirelings, 4 for each Wireling TinyShield.
The Hall Sensor Wireling counts RPM by detecting large changes in magnetic field strength as two disk magnets travel past.
Step 2: Sending Sensor data to your preferred storage method
In this step, we will give instructions for using a microSD card, Google Sheets, Cayenne IoT, or Blynk. We will also describe some of the advantages and disadvantages of each so that you can choose the best method for your use case.
Step 2a: MicroSD Card
MicroSD cards have two key advantages over the other 3 WiFi-based options.
- Consistency. WiFi options will be unable to record data if you move them out of range of the WiFi network they were programmed with.
- Power consumption is much (~90%) lower. This gives you options like using very tiny solar cells and a minuscule battery as your power supply. Or, you could opt to recharge a cheap cell phone power bank once or twice a year.
The main disadvantage is that you have to visit your station to access the raw data.
- To set up your microSD data storage, download the zip file from the software section above.
- Then, open the weather.ino file in your IDE or text editor of choice.
- For your application, you can choose how often you would like to store the data from all sensors by changing SD_SYNC_INTERVAL:
const int SD_SYNC_INTERVAL = 15; // represents minimum # of seconds between sd card writes.
That's it for microSD card setup! To complete the build, assemble your weather station by connecting your Wirelings to the Wireling TinyShield and connecting your microSD TinyShield and Wireling TinyShield to your processor of choice.
Finally, upload the Weather code from the software section. If you need help with this check out the TinyZero Setup Tutorial or the TinyScreen+ Setup Tutorial to ensure that you configure the Arduino IDE correctly. For advanced configuration tips and information about using solar power, check out the optional section at the end of the article.
The pressure/humidity/temperature/altitude and light Wirelings displayed on the 0.96'' OLED Wireling while logging data to a microSD card. Screen flicker from the camera!
Step 2b: Cayenne IOT Cloud
Cayenne is a very popular web platform and mobile app (Android and iOS) for IoT visualization. One unique feature of cayenne is the ability to send push notifications if sensor values reach predefined levels.
- To set up Cayenne for this project, click here to sign up for a new account.
- Then, select Arduino from the list of devices.
- If this is your first time using TinyCircuits products, please refer to the TinyZero Setup Tutorial or the TinyScreen+ Setup Tutorial to configure the Arduino IDE correctly.
- Then, connect the WiFi Tinyshield and Wireling TinyShield to your TinyZero or TinyScreen+. Make sure to connect the battery as well.
- Next, follow the directions here to add the Cayenne library to your IDE.
- Finally, follow these directions to set up your new device. When uploading your code, follow the same steps, but make sure to use the Weather Code from the software section above. Then, open the Arduino library manager by clicking Tools->Manage Libraries and make sure to install the SdFat and Arduino Low Power Libraries (pictured below.)
- You may need to add more channels to your dashboard depending on which Wirelings you have selected.
Here is an example of a completed dashboard for the weather station!
That's all there is to it! Your cayenne account or app should be receiving data directly from your weather station every few seconds. For advanced configuration tips and information about using solar power, check out the optional section at the end of the article.
Step 2c: Google Sheets
Google Sheets provides a cloud-hosted spreadsheet platform that gives you ultimate control over your sensor raw data. We have written a direct integration between the WiFi TinyShield and Google Sheets. No need for third-party services and pay per row pricing! This method is slightly more difficult to set up.
- Firstly, navigate to script.google.com and create a new script.
- Then, copy the google sheets integration script "code.gs" found in the software section and paste it into your new script.
- File>New->Script File and name it Weather.gs. Copy the text from the "Weather.gs" file found in the software section into this new script. The new script will be a part of the original project you created, which you can name whatever you want.
- Open google sheets and create a new spreadsheet to store your weather data. If you wish, you can paste the column headers below into the first row.
- The dateTime field represents epoch time. If you wish to convert it to a traditional date, you can use the following excel formula to change the date format to the standard excel format =(((A1/60)/60)/24)+DATE(1970,1,1)
- On your new spreadsheet, copy the portion of the URL after "https://docs.google.com/spreadsheets/d" as shown below:
- Paste this id in between the single quotes around 'YOUR_ID_HERE' on line 41 of code.gs.
- Copy your entire URL and paste it between the double quotes around "YOUR_URL_HERE" on line 24 of Weather.gs.
- Deploy your script as a web app. Publish->Deploy as web app. Make sure that you allow "Anyone, even anonymous" access to the app.
- Copy the web app URL obtained from the previous step.
- Download the Arduino sketch from the software section and open weather.ino.
- Paste your web app URL in between the double quotes of logURL on line 1316 of the weather.ino sketch.
const String logURL = "YOUR_URL_HERE";
- Change the code on line 132 of weather.ino to match the code shown below.
const bool GOOGLE_SHEETS = true;
That's it for the Google Sheets integration! Assemble your weather station and upload the code using bullet points 3, 4, and 6 of step 2b. Then, watch as new rows are added to your google spreadsheet every few seconds! It's like magic!
For advanced configuration tips and information about using solar power, check out the optional section at the end of the article.
Step 2d: Blynk
- Once installed, open the app and create a new account.
- Then, create a new project and name it whatever you like.
- Regardless of whether you are using the TinyZero or TinyScreen+, select the Arduino Zero as your device and WiFi as your connection type.
- Your project will be granted a unique authentication token, which will be sent to your email. We will be using this token later.
- Next, tap or click anywhere on the black background to add a widget to your project. The most relevant widgets for a weather station dashboard include the SuperChart, LCD, labeled value, gauge, and value display widgets.
Each widget has settings of its own, which can be accessed by tapping on the widget. Most are self-explanatory and nonessential, but the most important for this project is pin assignment and reading rate. Make sure to select the virtual pin for your widget following the table below. In this case, you would be displaying humidity on the value display widget because you assigned virtual pin V2. Finally, always use the PUSH reading rate.
|Pin||Associated Data||Arduino Sketch Code - not necessary to know, but useful as a reference in case you want to add new data streams.|
|V6||VOC Air Quality Index||
- Once you have created your custom weather dashboard, download the Arduino sketch from the software section and open weather.ino in your favorite text editor/IDE.
- Next, replace BLYNK_AUTH_TOKEN with yours on line 68.
- Finally, set BLYNK = true on line 133 of weather.ino as shown below:
const bool BLYNK = true; // if set to true blynk will be used and other datamodes will be disabled.
Congratulations, your custom Blynk weather station is complete! Assemble your weather station and upload the code using bullet points 3, 4, and 6 of step 2b.
For advanced configuration tips and information about using solar power, check out the optional section at the end of the article.
*Optional: Advanced Configuration Tips
Changing Sync Interval
The sync interval represents how often data is reported to the data storage method. It can be increased or decreased by modifying the below constants:
const int WIFI_SYNC_INTERVAL = 60; // represents # seconds between wifi syncs. setting lower than 60 will prevent wind speed measurments from functioning. const int SD_SYNC_INTERVAL = 60; // represents minimum # of seconds between sd card writes.
Very Low Power Mode
To utilize the very low power mode, you must meet the following requirements.
- Using microSD, not WiFI
- Not measuring wind
- Not using 0.96'' OLED Wireling
To enable the mode, change the const bool LOW_POWER on line 105 to true, as shown below.
const bool LOW_POWER = true; // will dramatically reduce power consumption, but will disable serialUSB during loop.
WiFi Low Power Mode (~30 ma)
This is enabled by default. Little else can be done to reduce WiFi power consumption.
Setting the start time
To get the correct epoch time, you must specify the date and time you upload the sketch by changing the seconds, minutes, hours, day, month, and year constants on lines 153-160 of weather.ino.
Tips on using Solar Power
Using solar cells to power your tiny weather station is very simple because both the TinyZero and TinyScreen+ have an onboard charging circuit. To take advantage of this, choose solar cells that output near 5v. Then, wire your solar cells in parallel to maximize their current output. Finally, cut open a microUSB cord and connect your solar panel power output lines to the VCC and ground lines of a microUSB cable. When you plug this micro USB cable into your processor, you will charge the lithium battery at a moderate rate, but not overcharge it, similarly to when you plug your TinyZero/TinyScreen+ into your computer. If you need a step by step picture tutorial of this process, check out steps 2 and 3 of our solar tracker tutorial.
If you want your weather station to be completely self-sufficient, you must measure the current draw of your weather station and compare that to the current provided by your solar panels on an overcast day. If your panels provide less current than needed on overcast days, it is only a matter of time until a string of overcast days causes the battery to completely discharge.
Changing Anemometer Radius
Windspeed measurements require an accurate anemometer radius, which can be changed on line 134:
const int ANEMOMETER_RADIUS = 1.9375; // inches or cm depending on value of USE_INCHES. measure from axis of rotation to center of cup for radius
Calibrating your Anemometer
Every anemometer has a different calibration constant. To find yours, you need to have an independent source of wind speed. Or, you can wait for a day with no wind and use a speedometer on your bike or car while holding your anemometer. Either way, adjust your calibration constant on line 138.
const int CALIBRATION = 10; // calibration constant in the formula for converting RPM to MPH
We hope you learned a lot while building and programming your tiny weather station! One cool improvement challenge would be pulling the current time from the internet if the user was using WiFi so that they would not have to rely on the Arduino real-time clock (RTC) to be set by the user beforehand!
As always, if you have any questions or feedback, feel free to email us at firstname.lastname@example.org. We would love to hear any ideas for improvement or new IoT projects you were inspired to work on!
Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!
Thanks for making with us!!