/*
Sketch generated by the Arduino IoT Cloud Thing "WeatherStation"
https://create.arduino.cc/cloud/things/7ebbf684-a78f-4231-b8f7-2318c4cdd2da
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int humidity;
int pressure;
int temperature;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme; // I2C
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
Serial.begin(9600);
if (!bme.begin(0x76)) { // Try 0x76 or 0x77 depending on your sensor
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
ArduinoCloud.update();
// Your code here
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" °C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
delay(2000);
humidity=bme.readHumidity();
temperature=bme.readTemperature();
pressure= bme.readPressure();
}