'MySensors' does not name a type



  • hello, i'm new in arduino and in das forum
    and i have this error in code
    i hope they can help me.
    /////////error//////////////
    exit status 1
    'MySensors' does not name a type
    /////////////////////////////////////////////////////////////



  • Maybe post the code so that people can see what is wrong with your code



  • @adrian_kbb73
    #define MY_RADIO_RFM69
    #define MY_RFM69_FREQUENCY RF69_915MHZ
    #define MY_IS_RFM69HW
    #define MY_RF69_IRQ_PIN 2
    #define MY_RF69_SPI_CS 10
    #include <SPI.h>
    #include <MySensors.h>
    #include <DHT.h>

    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)

    MySensors gw;/// Here I get the error
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true;
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);

    void setup()
    {
    gw.begin();
    dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);

    // Send the Sketch Version Information to the Gateway
    gw.sendSketchInfo("Humidity", "1.0");

    // Register all sensors to gw (they will be created as child devices)
    gw.present(CHILD_ID_HUM, S_HUM);
    gw.present(CHILD_ID_TEMP, S_TEMP);

    metric = gw.getConfig().isMetric;
    }

    void loop()
    {
    delay(dht.getMinimumSamplingPeriod());

    float temperature = dht.getTemperature();
    if (isnan(temperature)) {
    Serial.println("Failed reading temperature from DHT");
    } else if (temperature != lastTemp) {
    lastTemp = temperature;
    if (!metric) {
    temperature = dht.toFahrenheit(temperature);
    }
    gw.send(msgTemp.set(temperature, 1));
    Serial.print("T: ");
    Serial.println(temperature);
    }

    float humidity = dht.getHumidity();
    if (isnan(humidity)) {
    Serial.println("Failed reading humidity from DHT");
    } else if (humidity != lastHum) {
    lastHum = humidity;
    gw.send(msgHum.set(humidity, 1));
    Serial.print("H: ");
    Serial.println(humidity);
    }

    gw.sleep(SLEEP_TIME); //sleep a bit
    }



  • This line is not necessary in MYS 2.0



  • @Sander-Stolk
    o thank you, i will prove without that line


  • Mod

    @adrian_kbb73 Welcome to the MySensors commu ity!

    Most of this code seems to be for MySensors 1.x. It needs to be converted to work with 2.x. A guide is available at https://forum.mysensors.org/topic/4276/converting-a-sketch-from-1-5-x-to-2-0-x/


Log in to reply
 

Suggested Topics

  • 4
  • 2
  • 15
  • 9
  • 9
  • 2

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts