The following was a birthday gift for my Dad; inspired by another Instructable that I saw and initially intended to be proved to him as a self-build kit. However on starting to work on this project with him I very quickly realised that the initial tutorial that inspired the gift was out of date and that many of the other online tutorials had significant gaps in their explanations. I therefore decided to publish yet another IoT Weather Station which hopefully would be easy to follow form start to finish.
Further this instructable shows you how to use Blynk, Google Sheets or both to monitor and record sensor readings. What is more, the Google Sheets entries are written directly to the sheet (without having to go via a 3rd party service).
Regarding the Stevenson Screen, there are many available online that can be 3D-printed e.g. https://www.thingiverse.com/thing:1718334. I will be building on this one for this Instructable.
A Stevenson Screen is an "instrument shelter is a shelter or an enclosure to meteorological instruments against precipitation and direct heat radiation from outside sources, while still allowing air to circulate freely around them." (Wikipedia).
Parts
Software
Tools
As already mentioned, download the files from https://www.thingiverse.com/thing:1718334 and print the required bits. Assembly instructions are also found in the above link. I did make some modifications (see notes below).
Parts printed are:
The assembly order is:
I drilled holes in the Solid plates to allow the charging cable from the Solar Panel to connect to the charger and then one to allow the cable to run from the controller to the sensor on the Sensor_Grid.
Once completed, the sensor was programmed to take the following readings every 60 minutes:
Notes
Connect the circuit as shown in the schematic, mounting the LoLin and BME280 on the 3D-printed mesh as shown in the photo.
BME280 -> LiLon
LiLon -> LiLon
NOTE
I had challenges getting a suitable LiLon battery. Also for some reason I had no success powering via VIN. I therefore powered as follows:
"Blynk is a hardware-agnostic IoT platform with customizable mobile apps, private cloud, rules engine, and device management analytics dashboard". Basically it allows you to securely manage and monitor remote sensors from anywhere in the world via the Internet. While a commercial service, each account comes with 2000 free credits. Credits enable you to associate different gauges, displays, notifications etc with your sensor or sensors. While the subscription pricing is out of the range of a hobbyist's budget, the free credits are enough for a simple project like this one.
To start using the service you will need to first download the Blynk App to your phone/device, create and account (or log on with existing account) and then create a new project as follows:
You will not need to add the required widgets. With my 2000 free credits I added the following:
The gauges and charts were set up as per the attached photos, each being assigned its own virtual pin that would be used latter in the code.
Once done with the settings, the play button on the top right can be pressed to start collecting date.
For more information see
The following libraries will need to be added to the Arduino IDE in order to complete this project:
For instructions on installing libraries for the Arduino IDE, visit https://www.arduino.cc/en/guide/libraries.
My hardware settings where as follows:
When using the attached code in the following steps, please always refer to the comments in the code with respect to adding the following:
I battled for ages to get my BME280 sensor to work until I found an example that contained the following line.
It appears that I needed to set the sensor address. Once I had done this it all worked just fine.
Blynk has a really nice mobile user-interface it does however have the following limitations:
For the above reasons I looked at how I could integrate my data collecting process into a Google Sheet. This is covered in the next section.
In order to record your readings so that you can analyse historical data at a later date you need to write it to some sort of database. The HTTPSRedirect library lets us do this by writing our data to a Google Sheet.
The main limitations with this approach are as follows:
The Google Sheet is set-up as follows.
Create a Google Sheet with two sheets.
Sheet 1: Data
The Data sheet needs 4 columns i.e. Date/Time, Temperature, Humidity, Pressure (columns A to D). Format the columns appropriately e.g. Column A to be "Date Time" so that the date and time is shown in the cells.
Sheet 2: Dashboard
Create the Dashboard sheet as per the attached photos, entering the formulae as listed below:
Google Sheets can have a maximum of 400,000 cells. This is used, together with the fact that each reading uses 4 cells, to calculate how much space is left and when it will run out.
It may be possible to improve on these formulae. I was doing two things here i.e. learning about the query formula and then also writing some formula in such a way as to help me remember the logic behind them.
The "Chart Editor" screenshot show the basic set-up for the the Temperature graph. The other graphs where created using the same set-up. The only difference between the graphs was the minimum vertical axis values (found under the customise tab). The customise tab also has the other settings like access names, graph titles, etc.
We now need a Google Script that will enable us to write our data by calling a URL.
Creating the script
In the Google Sheet URL, note down the key between the "d/" and "/edit". This is your —Your-Google-Sheet-Sharing-Key– and will be needed in the code below.
Next go to Tools > Script Editor and create the Google App Script, pasting the code in the attached GS file. Update the var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/—Your-Google-Sheet-Sharing-Key–/edit"); to reflect your sharing key.
Now publish the script by going to Publish > Deploy as Web App.
Copy the Current web app URL and save it somewhere as you will need it for extracting the GScriptID (—Your-Google-Script-ID–). The GScriptID is the string between "s/" and "/exec?". Ensure that "Anyone, even anonymous" has access to the app. During this process you will be asked to grant some permissions. It is important that you grant these.
Note: Whenever you modify your code, you have to create a “New” Project version and publish it otherwise you will still be hitting the same old code.
You can now test the script by browsing tohttps://script.google.com/macros/s/—Your-Google-Script-ID–/exec?Temperature=10&Humidity=11&Pressure=12. Each time that you refresh this link, a new entry should be added to the Google Sheet.
This above was taken from the following tutorial: http://embedded-lab.com/blog/post-data-google-sheets-using-esp8266/. This tutorial is however out of date and so the associated Arduino code in the next section has been changed to accommodate the latest HTTPSRedirect libraries.
The Arduino Code
See attached code.
In order to get the best out of both worlds, one can combine the code for both Blynk and Google Sheets.
See attached code.
None of the above are my ideas but rather this a project built on the ideas and work of others. I have enjoyed pulling it altogether into one place. using different technologies and tools to great a fun and practical project. I especially enjoyed learning how to store my readings in a Google Sheet. For this I wish to thank the ElectronicsGuy (Sujay Phadke).
Update
After completing this project I needed to change my wireless settings. I was now working on a different computer. After uploading the changes, the project stopped working. After some troubleshooting I concluded that the deepsleep function was failing. I took the project back home and uploaded it there (using the same code) and it worked. I have therefore concluded that something must have changed in the libraries that I added. I have therefore attached the libraries that are currently on my home computer to this section; just in case somebody else comes across this issue.