Arduino IoT cloud
Connecting a Arduino to the Arduino IoT Cloud is very simple and straight forward. As long as you have the right Arduino board. At the moment there are only Arduino MKR 1000, Arduino MKR WIFI 1010 and Arduino MKR GSM 1400 supported. I have an Arduino MKR WIFI 1010 so I am fine. To connect it with the Arduino IoT Cloud you just have to follow the following tutorial:
This tutorial shows you how to connect your Arduino to the cloud, how to send data from the cloud to the Arduino (turn LED on and off) and how to read data from the Arduino to the cloud (position of potentiometer). For the Windchillator we only need the second part: read data from the arduino and send them to the cloud.
Based on the code of the tutorial I made the code for the windchillator
This project synchronizes two variables with the cloud: temp and battery.
The float temp stores the temperature in degrees celcius. The temperature is measured by a DS18B20 one wire sensor. The sensor is connected to digital pin 2 of the arduino. I use the OneWire and DallasTemperature libraries to read out the sensor.
The float battery is the second variable and stores the battery voltage in volts. On the arduino board the battery voltage is connected via a resistor devider to an analog_in pin of the microcontroller and you can simply read it out with the command analogRead(ADC_BATTERY).
The code reads the variables and pushes them to the cloud. Then it waits 10 seconds and starts all over again. For my setup this is not optimal and not very energy efficient but it works at the moment. I will improve this in my next blog post.
Now the data of my sensors appears in the Arduino IoT cloud. Unfortunatelly the cloud shows only the last transferred value. For my project I want some data logging as I am very interested in how the temperature and wind speed changes during the day or over several weeks.
Lucky me, Arduino allows to install web hooks which can forward the data to other web services. I decided to use Google Sheets and generate some nice diagrams. There exists also a tutorial which describes that:
Unfortunatelly the google code didn't work right out of the box. I had to do some modifications as described in this forum post:
With this modification the script worked fine. At the moment, my variables in the Arduino IoT cloud are set that they update every 30 seconds.
This generates the following diagram in Google Sheets
At the moment I am a little bit unhappy with the power consumption of the arduino board because I want to run it off a battery for weeks and months without charging. I will show you in my next blog post, what you can do about this.