A few months ago I came across a fun project: I wanted to publish information on the climate of Huigra Viejo Camping - a camping site located in the Andes of Ecuador on the Web. The idea was that the interested tourist could consult the weather conditions in real time, through the site huigra.com, and incidentally, as an extra feature, check the weather forecast for the days you planned to book your stay.
The problem was that all the weather forecast providers like weather.com or forecast.io were giving me data that was far from the truth. The reason: apparently the temperature gradient in the area is very steep and the climate varies greatly from one location to another very close (less than 1 km away), making it difficult to extrapolate data from nearby monitoring stations or satellite information … Well, the camping site is precisely on the steep side of a mountain.
The solution? Take the temperature in-situ with some hardware and then report it in some way on the website in question. An ideal opportunity to play with the Arduino MKR1000, because thanks to its WIFI support, it will allow us to transmit data to the Internet, through a wireless router. If the reader does not get the Arduino MKR1000 you can also try with the Arduino UNO WiFi, I leave links to both options.
Humidity, temperature and pressure sensors
We will make the project very simple, with only 2 sensors (in fact this is how it is installed), which will allow us to report 3 parameters: temperature, humidity and barometric pressure. The connection is quite simple as we see in the following figure.
We find it at the top of the previous image. This sensor is basically a very easy to use barometric pressure sensor, since it allows us to connect with the MKR1000 through I2C. The I2C support in Arduino is wonderful, as it allows us to chain several devices (such as sensors) to the same I2C wiring. In this case we will only use ONE device (the BMP180), but we could add more with little modification. In any case, the only thing we need to connect is two data cables, marked as SCL (the clock) and SDA (the data), in addition to the GROUND reference. The SCL on the MKR1000 is pin D12 and the SDA corresponds to pin D11.
DHT11 (or DHT22)
A temperature and humidity sensor. Economical and easy to use. In the previous figure we find it in the lower part.
Weather Underground (wunderground.com)
Weather Underground is a community weather reporting platform, available online, that will allow us to report weather conditions to the cloud. It currently has more than 250,000 stations connected ... crazy! ... It also provides us with an API, called PWS, which makes it possible to have plugins for websites, as well as apps for tablets or smartphones.
The API documentation that we will use in this project can be found here http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol
To use this platform we must register a user (it is free) and create a weather station to start reporting. We will be assigned an identifier of the weather station created, as well as a key, to use from the invocations to the API.
The Arduino code
To make things easier I have created a repository on GitHub. http://www.github.com/elandivar/huigra
I am not going to explain all the code because it is quite simple, but there are a few lines to which I will dedicate a short explanation and it is the sendSample function from the file https://github.com/elandivar/huigra/blob/master/huigrastation.ino
PD Special mention to AsiriLabs, which provided us with the necessary components for the construction of this prototype.