/***************************************************************************
written by Rijk Meurs 16-05-2020
hardware: Arduino nana 33 iot, BME280 sensor
iot : Blynk
***************************************************************************/
#define BLYNK_PRINT Serial
#include <Wire.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "ikZEcrON32ZTQoS4ZcTjq3pM7DTy8pzY";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "your ssid";
char pass[] = "your password";
Adafruit_BME280 bme; // I2C
float t;
float h;
float p;
BlynkTimer timer;
void sendSensor()
{
t = bme.readTemperature();
h = bme.readHumidity();
p = bme.readPressure();
Blynk.virtualWrite(V5, t);
Blynk.virtualWrite(V6, h);
Blynk.virtualWrite(V7, p / 100.0F);
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
Serial.println("BME280 test");
if (!bme.begin()) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
timer.setInterval(3000,sendSensor);
}
void loop() {
// read the sensors and append to the string:
Blynk.run();
timer.run();
}
Comments