Compiling Sensor code using BME280 and ESP8266
-
I'm getting this error compiling. MySensors.h:94:18: error: expected unqualified-id before '(' token. Any Help??
Here's the code/*********
East Yard Outside Temp, Pressure, Humidity
*********/
// Enable debug prints
#define MY_DEBUG// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485#include <MySensors.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1#define SEALEVELPRESSURE_HPA (1013.25)
unsigned long delayTime;
float temperature;
float humidity;
float pressure;
bool metric = true;
static const uint64_t UPDATE_INTERVAL = 60000;MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);void presentation()
{
// Send the sketch version information to the gateway
sendSketchInfo("East Yard THP", "1.1");// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
metric = getControllerConfig().isMetric;
}
Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPIvoid setup() {
Serial.begin(115200);
Serial.println(F("BME280 Sensor"));
bool status;
// default settings
// (you can also pass in a Wire library object like &Wire2)
status = bme.begin(0x76);
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
delayTime = 10000;Serial.println();
}void loop() {
printValues();
sleep(UPDATE_INTERVAL);
}void printValues() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
// Convert temperature to Fahrenheit
Serial.print("Temperature = ");
Serial.print(1.8 * bme.readTemperature() + 32);
temperature = 1.8 * bme.readTemperature() + 32;
send(msgTemp.set(temperature, 1));
Serial.println(" *F");Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
pressure = bme.readPressure() / 100.0F;
Serial.println(" hPa");Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
humidity = bme.readHumidity();
send(msgHum.set(humidity, 1));
Serial.println(" %");
}
BME code works fine, but when I add MySensors code, I get the error. -
I didn't see anything obviously wrong, so I tried compiling your code. Your code compiled fine for me. I used ESP8266 Boards (2.5.0-Beta3) -> Generic ESP8266 Module.
Unfortunately, that doesn't help much with figuring out why your compiler is giving the error.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login