Now, we are going to build the Arduino sketch. You need to import all the libraries for the Arduino Yun web & bridge functionalities. You can read more about starting out with Temboo & Yun here: https://www.temboo.com/arduino/yun/
These are all the libraries used in this project:
#include <Bridge.h> #include <Temboo.h> #include <Process.h> #include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BMP085_U.h>
I also placed all my Temboo account information in a separate file, please make sure that you update your personal account information in this file:
#include "TembooAccount.h"
You also need to set your own informations about your Google account:
const String GOOGLE_CLIENT_ID = "your-google-client-id"; const String GOOGLE_CLIENT_SECRET = "your-google-client-secret"; const String GOOGLE_REFRESH_TOKEN = "your-google-refresh-token"; const String SPREADSHEET_TITLE = "your-spreadsheet-title";
In the setup() part of the sketch, we initialise the Arduino Bridge library:
Bridge.begin();
We also start a date process, to automatically send the measurements date to Google Docs:
time = millis(); if (!date.running()) { date.begin("date"); date.addParameter("+%D-%T"); date.run(); }
In the loop() part, the most important line is:
runAppendRow(humidity, lightLevel, pressure, temperature, altitude);
Which calls the function to automatically send the data to the Google Docs spreadsheet. I won’t get into the details of these two functions, but of course you will find all the code in the GitHub repository of this project.
The loop() of the Arduino sketch is repeated every 10 minutes with a delay() function, as these variables are usually changing slowly over time.
Text editor powered by tinymce.