Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Compiling Sensor code using BME280 and ESP8266

Compiling Sensor code using BME280 and ESP8266

Scheduled Pinned Locked Moved Troubleshooting
3 Posts 2 Posters 25 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • dpconsD Offline
    dpconsD Offline
    dpcons
    wrote on last edited by
    #1

    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 SPI

    void 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.

    1 Reply Last reply
    0
    • nagelcN Offline
      nagelcN Offline
      nagelc
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • dpconsD Offline
        dpconsD Offline
        dpcons
        wrote on last edited by
        #3

        Thanks for looking. What arduino ide version are you using and what version of mysensors?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        13

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular