#include <SoftwareSerial.h>
#include <EnvironmentCalculations.h>
#include <BME280I2C.h>
#include <Wire.h>
BME280I2C bme;
SoftwareSerial mySerial(8,9);
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
Serial.setTimeout(100);
}
String data;
uint8_t dataRead = 0;
void loop()
{
Serial.println (data);
if (mySerial.available() > 0) {
delay(50);
String readData = “”;
Serial.print("Command from Bolt: ");
while (mySerial.available() > 0 ) {
readData = readData + (char)mySerial.read();
}
Serial.println(readData);
if (readData.indexOf(“RD”) != -1) {
String data = sensor_data_to_push();
mySerial.print(data);
Serial.print("Data sent to Bolt: ");
Serial.println(data);
}
delay (950);
}
}
String sensor_data_to_push() {
String data;
float temp(NAN), hum(NAN), pres(NAN);
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
BME280::PresUnit presUnit(BME280::PresUnit_Pa);
bme.read(pres, temp, hum, tempUnit, presUnit);
EnvironmentCalculations::AltitudeUnit envAltUnit = EnvironmentCalculations::AltitudeUnit_Meters;
EnvironmentCalculations::TempUnit envTempUnit = EnvironmentCalculations::TempUnit_Celsius;
float altitude = EnvironmentCalculations::Altitude(pres, envAltUnit);
float dewpoint = EnvironmentCalculations::DewPoint(temp, hum, envTempUnit);
float sealevel = EnvironmentCalculations::EquivalentSeaLevelPressure(altitude, temp, pres);
data = String(pres) + “,” + String(temp) + “,” + String(hum) + “,” + String(altitude) + “,” + String(dewpoint) + “,” + String(sealevel);
return data;
}
I have tried doing everything available on the Internet. This code is with BMP280 sensor (An I2C based sensor for the readings of temperature, pressure, humidity, dew point, sea level and altitude. I want that the values put up at at the end of the code i.e. the value of data must be read and interpreted by bolt cloud and a graph must be plotted. I tried using the library but its complex code for the DHT sensor wasn’t comprehended by me. I am using software serial pins 8 and 9.
The error I am seeing is that Bolt is communicating with Arduino (Its lights are blinking after every 5 minutes for receiving data). Arduino is also constantly sending data after every 1 second. But in the bolt cloud line graph I am not able to see anything. The serial monitor is also blank. I checked it after every 5 minutes. Only the monitor scrolls itself each time I open it but no value is registered.
All pins of sensor are accurately connected.
Library for BMP280 sensor: https://github.com/finitespace/BME280.git