Node failing to register with EasyIoT server.....



  • Hello everyone!

    Can someone please take a look and see if I have done something stupid? I have already a node with 2 x DS18B20 working well. This node works (sensors work and the LCD displays as intended) but it won't register with the gateway/controller Rpi running Easy IoT server.
    Programmed with Win7 and IDE 1.6.4 using MS 1.5....Also the NRF24 has chip cap across the power and has worked well for over a year.

    ''''
    #include <MySensor.h>
    #include <SPI.h>
    #include <DHT.h>
    #include <Wire.h>
    #include <LiquidCrystal_I2C.h>
    //#define BATTERY_SENSE_PIN A5
    #define Fge 7
    #define Fzr 6
    #define Fge_HUM 1
    #define Fge_TEMP 1
    #define Fzr_HUM 2
    #define Fzr_TEMP 2
    //#define Fge_door 4
    //#define Fzr_door 5
    #define SHORT_WAIT 50

    //D4 = Fridge door
    //D5 = Freezer door
    //D7 = Fridge AM2302
    //D6 = Freezer AM2302
    //D9-13 = NRF24L01+

    //setup I2C to LCD
    #define I2C_ADDR 0x27
    #define BACKLIGHT_PIN 3
    #define En_pin 2
    #define Rw_pin 1
    #define Rs_pin 0
    #define D4_pin 4
    #define D5_pin 5
    #define D6_pin 6
    #define D7_pin 7

    LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

    MySensor gw;
    DHT dht;
    DHT dht1;
    int lastBatLevel;
    int P=0;
    float fgetemp;//Fridge
    float fzrtemp; //Freezer
    float FgelastTemp;
    int FgelastHum;
    float FzrlastTemp;
    int FzrlastHum;
    //boolean receivedConfig = false;
    boolean metric = true;
    MyMessage msgFgeHum(Fge_HUM, V_HUM);
    MyMessage msgFgeTemp(Fge_TEMP, V_TEMP);
    MyMessage msgFzrHum(Fzr_HUM, V_HUM);
    MyMessage msgFzrTemp(Fzr_TEMP, V_TEMP);

    //int oldBatteryPcnt = 0;

    void setup()
    {
    // analogReference(INTERNAL);
    //Serial.begin(9600);
    SPI.begin();
    lcd.begin (16,2);
    // Switch on the backlight
    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
    lcd.setBacklight(255);
    /* lcd.setCursor(0,0);
    lcd.print(F(" ####### "));
    lcd.setCursor(0,1);
    lcd.print(F(" Fridge Freezer "));
    delay(3000);*/
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(F(" Ver. 14-09-15 "));
    delay(1500);
    lcd.setCursor(0,0);
    lcd.print(F(" * Radio init * "));

    gw.begin();
    dht.setup(fge);
    dht1.setup(fzr);
    // Send the Sketch Version Information to the Gateway
    gw.sendSketchInfo("EASYIOT_FgeFzr", "0.1");
    gw.present(Fge, S_TEMP);
    gw.wait(SHORT_WAIT);
    gw.present(Fge, S_HUM);
    gw.wait(SHORT_WAIT);
    gw.present(Fzr, S_TEMP);
    gw.wait(SHORT_WAIT);
    gw.present(Fzr, S_HUM);
    gw.wait(SHORT_WAIT);

      metric = gw.getConfig().isMetric;
      
      lcd.setCursor(0,0);
      lcd.print(F(" Radio Success! "));
      delay(1500);
      lcd.setCursor(0,0);
      lcd.print(F("  Getting data  "));
      lcd.setCursor(0,1);
      lcd.print(F("  Please wait   "));     
    

    }

    void loop()
    {
    // Process incoming messages (like config from server)
    gw.process();

    delay(dht.getMinimumSamplingPeriod());
    delay(dht1.getMinimumSamplingPeriod());

    float Fgetemperature = dht.getTemperature();
    if (Fgetemperature != FgelastTemp) {
    FgelastTemp = Fgetemperature;
    gw.send(msgFgeTemp.set(Fgetemperature, 1));
    }

    int Fgehumidity = dht.getHumidity();
    if (Fgehumidity != FgelastHum) {
    FgelastHum = Fgehumidity;
    gw.send(msgFgeHum.set(Fgehumidity));
    }

    float Fzrtemperature = dht1.getTemperature();
    if (Fzrtemperature != FzrlastTemp) {
    FzrlastTemp = Fzrtemperature;
    gw.send(msgFzrTemp.set(Fzrtemperature, 1));
    }

    int Fzrhumidity = dht1.getHumidity();
    if (Fzrhumidity != FzrlastHum) {
    FzrlastHum = Fzrhumidity;
    gw.send(msgFzrHum.set(Fzrhumidity));
    }

    //Print fgetmp and fgehum values to lcd
    {
    lcd.setCursor(0,0);
    lcd.print(F("Fge "));
    lcd.setCursor(0,1);
    lcd.print(F("Fzr "));
    lcd.setCursor(12,0);
    lcd.print(F("H"));
    lcd.setCursor(12,1);
    lcd.print(F("H"));
    lcd.setCursor(13,0);
    lcd.print(Fgehumidity);
    lcd.setCursor(13,1);
    lcd.print(Fzrhumidity);
    lcd.setCursor(15,0);
    lcd.print(F("%"));
    lcd.setCursor(15,1);
    lcd.print(F("%"));

     //Fridge Display
       LCD (Fgetemperature, 0, 4);  //var, line no, position of +/-
     //Freezer Display
       LCD (Fzrtemperature, 1, 4);  //var, line no, position of +/-
    

    }
    }''''



  • @skywatch Try using the "insert code here" button when posting your sketch. It looks like this </>. It makes reading your sketch much easier.

    It appears that you have multiple sensors on your node but do not present them as child sensors to your controller. Are you using DHT22s? What else is on your sensor node - e.g "#define Fge-door 4", are these reed switches?



  • I tried to see if I could edit my post to see what went wrong with the formatting, but could not see how. Maybe the 'How to ask for help' sticky should be updated.

    Anyway, there are 2 x AM2302 (DHT22) sensors as you so correctly noted. The door sensors are for future use and are not referenced in the code except as the commented out bit which reminds me to keep those pins free!

    gw.sendSketchInfo("EASYIOT_FgeFzr", "0.1");
    gw.present(Fge, S_TEMP);
    gw.wait(SHORT_WAIT);
    gw.present(Fge, S_HUM);
    gw.wait(SHORT_WAIT);
    gw.present(Fzr, S_TEMP);
    gw.wait(SHORT_WAIT);
    gw.present(Fzr, S_HUM);
    gw.wait(SHORT_WAIT);''''
    
    This is what I thought predented the sensors. Have I missed something obvious?
    
    Thank you for the reply. I appreciate the help.

Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 1
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts