30 BMP280 Data Save in Google Sheet

 Introduction:

We are going to learn how to send data from NodeMCU to Google Spreadsheet.  Here we will use BMP280 sensor. It is Biometric pressure sensor. It provides Temperature and biometric pressure data so these data will be store in Google Spreadsheet.

Schematic Diagram:

We need NodeMCU board,  BMP280 Sensror and 16x2 LCD with I2C module. LCD and MBP280 sensor connect with Controller through I2C protocol so SCL, SDA pin of both module (LCD and BMP280) connect on D1 and D2. D1 pin is SCL and D2 pin is SDA in case of NodeMCU. BMP280 and LCD require 5v power supply so it connect in Vin pin of Node MCU because it is 5volt pin.

IFTTT Settings:

Go to www.ifttt.com and login with your google account then click on Create  to create new Applet.
Then create page will be open, Now click on plus + icon.

Now search "Webhooks" and click on webhooks icon.
Then it will be open "Choose Trigger". Then lick on "Receive web request".
Now "Complete trigger field" will be open and here type Event name then click on Create trigger.

Now click on Plus (+ Sign)
Now "Choose action service" will be open. Search here "Google Sheet" then click on Google sheets icon.
Now choose action will be open. Here click on "Add row to spreadsheet".
Then it will be open "Complete action fields" you have to fill here as per your requirement.
We will send only two data Temperature and Pressure so remove Value3 , and add "*C" with Value1 because Value1 is temperature and add  "hPa" with Value2. Value2 is Pressure. Then click on "Create Action".
Now "Finish and Review" step will be open. Click on "Finish" to finish step.
Then it will be open like this. Click on Webhooks icon then go to Documentation.
It will be open your API key, select and copy this API key.

Let us code:

We are using <Wire.h>library because we use I2C protocol for BMP280 and LCD, <Adafruit_BMP280.h>  is BMP280 library.  We use <LiquidCrystal_I2C.h>   library for I2C LCD. Replace API Key with you IFTT Applet API Key. Event name is BMP, we have already chosen event name in IFTTT Applet. Replace SSID and PASSWORD with your WiFI router 's SSID and PASSWORD.
#include <Wire.h>
#include <Adafruit_BMP280.h>
#include "IFTTTESP8266.h"
#include <Wire.h> // library for I2C protocol
#include <LiquidCrystal_I2C.h> // library for I2C LCD
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#define EVENT "BMP" // Put here your Maker Event Name
#define KEY "API_Key" // Put here your IFTTT key
#define WIFISSID "SSID"
#define PASSWORD "PASSWORD"
IFTTT client(KEY);
Adafruit_BMP280 bmp; // I2C
int temperature = 0;
int pressure = 0;
char temp[12];
char pres[12];
This is void setup function, Serial.begin function initialized serial at 115200 bps. bmp.begin function initialized BMP280 sensor. If board will not find BMP sensor then it will print "Could not find a valid BMP280 sensor, check wiring! " on serial monitor. client.wifiConnection  function establish connectivity with internet.
 void setup() {  
Serial.begin(115200);
lcd.init(); // initialize the lcd
lcd.backlight(); // backlight ON
lcd.setCursor(0,0);
lcd.print("voidloopRobotech");
lcd.setCursor(1,1);
lcd.print("& Automation");
delay(400);
lcd.clear();
delay(10);
lcd.setCursor(0,0);
lcd.print("Conn.");
Serial.print("Connecting to ");
Serial.println(WIFISSID);
client.wifiConnection(WIFISSID, PASSWORD);
if (!bmp.begin()) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (1);
}
/* Default settings from datasheet. */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
while (WiFi.status() != WL_CONNECTED) {
lcd.print(".");
Serial.print(".");
delay(200);
}
Serial.println("");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
delay(300);
lcd.clear();
}
bmp.readTemperature() function read the temperature and store in temperature variable. bmp.readPressure () function read the pressure and store in pressure variable.
 temperature = bmp.readTemperature();  
pressure = bmp.readPressure();
Temperature and pressure print on LCD 16x2.
 lcd.setCursor(0,0);  
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Press: ");
lcd.print(pressure/100);
lcd.print("hPa");
Here temperature and pressure print on Serial monitor.
  Serial.print(F("Temperature = "));  
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.println();
iota function convert int into char variable. client.add function add in queue data to be send. client.sendAll() function push data to server at particular event.
  itoa(temperature, temp, 10);  
itoa(pressure, pres, 10);
client.add(temp);
client.add(pres);
client.sendAll(EVENT);

Code:

  // https://www.youtube.com/c/voidloopRobotechAutomation  
#include <Wire.h>
#include <Adafruit_BMP280.h>
#include "IFTTTESP8266.h"
#include <Wire.h> // library for I2C protocol
#include <LiquidCrystal_I2C.h> // library for I2C LCD
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#define EVENT "BMP280" // Put here your Maker Event Name
#define KEY "kL2peudQwJUjSRPAQV_c2swvNyHkCCg0nUzs8O9a4eP" // Put here your IFTTT key
#define WIFISSID "voidloop"
#define PASSWORD "shivam1234"
IFTTT client(KEY);
Adafruit_BMP280 bmp; // I2C
int temperature = 0;
int pressure = 0;
char temp[12];
char pres[12];
void setup() {
Serial.begin(115200);
lcd.init(); // initialize the lcd
lcd.backlight(); // backlight ON
lcd.setCursor(0,0);
lcd.print("voidloopRobotech");
lcd.setCursor(1,1);
lcd.print("& Automation");
delay(400);
lcd.clear();
delay(10);
lcd.setCursor(0,0);
lcd.print("Conn.");
Serial.print("Connecting to ");
Serial.println(WIFISSID);
client.wifiConnection(WIFISSID, PASSWORD);
if (!bmp.begin()) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (1);
}
/* Default settings from datasheet. */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
while (WiFi.status() != WL_CONNECTED) {
lcd.print(".");
Serial.print(".");
delay(200);
}
Serial.println("");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
delay(300);
lcd.clear();
}
void loop() {
temperature = bmp.readTemperature();
pressure = bmp.readPressure();
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Press: ");
lcd.print(pressure/100);
lcd.print("hPa");
Serial.print(F("Temperature = "));
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.println();
itoa(temperature, temp, 10);
itoa(pressure, pres, 10);
client.add(temp);
client.add(pres);
client.sendAll(EVENT);
delay(600000); // delay 10 minuts
}
Download "IFTTT" Library

👇👇👇Watch this video for more detail👇👇👇
Thanks for visiting💖 🙏
Please Donate to help me and afford new equipment & components to make more videos and blogs.

Please donate us:

No comments:

Powered by Blogger.