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
michlb1982M

michlb1982

@michlb1982
Unfollow Follow
About
Posts
24
Topics
6
Shares
0
Groups
0
Followers
0
Following
1

Posts

Recent Best Controversial

  • DHT12 + 2Relay + 2Button - Combining Problem
    michlb1982M michlb1982
    Development

    @mfalkvidd you are so right!!! the "wait" is the problem... i changed the script.. i use a if to check if the update-interval is over and then i go through the dht loop....
    now the bounce are also working..!

    here my code...

    #define MY_DEBUG
    #define MY_RADIO_NRF24
    //#define MY_REPEATER_FEATURE
    
    // Define Node ID
    #define MY_NODE_ID 101
    
    #define RELAY_ON 1
    #define RELAY_OFF 0
    
    #define SSR_A_ID 1   // Id of the sensor child
    #define SSR_B_ID 2   // Id of the sensor child
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 0//1
    #define SENSOR_TEMP_OFFSET 0
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <Bounce2.h>
    #include <DHT12.h>
    #include <Wire.h>
     
    const int buttonPinA = 7;
    const int buttonPinB = 8;
    const int relayPinA = 6;
    const int relayPinB = 5;
    int oldValueA = 0;
    int oldValueB = 0;
    unsigned long startMillis;
    unsigned long currentMillis;
    
    bool stateA = false;
    bool stateB = false;
    
    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = true;
    static const uint8_t FORCE_UPDATE_N_READS = 10;//10
    static const uint64_t UPDATE_INTERVAL = 30000;//30000
    
    
    Bounce debouncerA = Bounce();
    Bounce debouncerB = Bounce();
    
    MyMessage msgA(SSR_A_ID, V_STATUS);
    MyMessage msgB(SSR_B_ID, V_STATUS);
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    DHT12 dht12; 
    
    void setup()
    {
      //Serial.begin(115200);
      Wire.begin();
      pinMode(buttonPinA, INPUT_PULLUP); // Setup the button Activate internal pull-up
      pinMode(buttonPinB, INPUT_PULLUP); // Setup the button Activate internal pull-up
    
    
    
      // After setting up the buttons, setup debouncer
      debouncerA.attach(buttonPinA);
      debouncerA.interval(5); //5
      debouncerB.attach(buttonPinB);
      debouncerB.interval(5);//5
    
      // Make sure relays are off when starting up
      digitalWrite(relayPinA, RELAY_ON);
      digitalWrite(relayPinB, RELAY_ON);
      // Then set relay pins in output mode
      pinMode(relayPinA, OUTPUT);
      pinMode(relayPinB, OUTPUT);
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("2xRelais,2xButton,DHT12", "1.2a");
    
      // Register all sensors to gw (they will be created as child devices)
      present(SSR_A_ID, S_LIGHT);
      present(SSR_B_ID, S_LIGHT);
    
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
    
      metric = getControllerConfig().isMetric;
    
    }
    
    /*
       Example on how to asynchronously check for new messages from gw
    */
    void loop()
    {
      currentMillis = millis();
      debouncerA.update();
      // Get the update value
      int valueA = debouncerA.read();
      if (valueA != oldValueA) {
        send(msgA.set(stateA ? false : true), true); // Send new state and request ack back
      oldValueA = valueA;
      }
     
    
      debouncerB.update();
      // Get the update value
      int valueB = debouncerB.read();
      if (valueB != oldValueB) {
        send(msgB.set(stateB ? false : true), true); // Send new state and request ack back
      oldValueB = valueB;
      }
    
        
      // Force reading sensor, so it works also after sleep()
    //  dht12.readSensor(true);
      if (currentMillis - startMillis >= UPDATE_INTERVAL) 
      {
      // Get temperature from DHT library
      float temperature = dht12.readTemperature();
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT!");
      } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
        // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
        lastTemp = temperature;
    
        // apply the offset before converting to something different than Celsius degrees
        temperature += SENSOR_TEMP_OFFSET;
    
        if (!metric) {
          temperature = dht12.readTemperature();
        }
        // Reset no updates counter
        nNoUpdatesTemp = 0;
        send(msgTemp.set(temperature, 1));
    
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      } else {
        // Increase no update counter if the temperature stayed the same
        nNoUpdatesTemp++;
      }
    
      // Get humidity from DHT library
      float humidity = dht12.readHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
        // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
        lastHum = humidity;
        // Reset no updates counter
        nNoUpdatesHum = 0;
        send(msgHum.set(humidity, 1));
    
        #ifdef MY_DEBUG
        Serial.print("H: ");
        Serial.println(humidity);
        #endif
      } else {
        // Increase no update counter if the humidity stayed the same
        nNoUpdatesHum++;
      }
      startMillis = currentMillis;
      Serial.print("Startzeit: ");
      Serial.println(startMillis);
      }
      // Sleep for a while to save energy
      //wait(UPDATE_INTERVAL);
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type == V_STATUS) {
          
        switch (message.sensor) {
          case 1:
            stateA = message.getBool();
            digitalWrite(message.sensor + 4, stateA ? RELAY_ON : RELAY_OFF);
            break;
          case 2:
            stateB = message.getBool();
            digitalWrite(message.sensor + 4, stateB ? RELAY_ON : RELAY_OFF);
            break;
        }
       
          // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.println(message.sensor);
        //Serial.print("from node:");
        //Serial.println(message.sender);
        //Serial.print(", New status: ");
        Serial.println(message.getBool());
      }
    }
    

  • DHT12 + 2Relay + 2Button - Combining Problem
    michlb1982M michlb1982
    Development

    well i can't find anything strange in the node debug messages..

    90243 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:1
    08:25:35.541 -> Incoming change for sensor:2
    08:25:35.541 -> 1
    92163 TSF:MSG:READ,0-0-101,s=1,c=1,t=2,pt=0,l=1,sg=0:0
    08:25:37.478 -> Incoming change for sensor:1
    08:25:37.478 -> 0
    92843 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:0
    08:25:38.139 -> Incoming change for sensor:2
    08:25:38.139 -> 0
    93059 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:1
    08:25:38.375 -> Incoming change for sensor:2
    08:25:38.375 -> 1
    93458 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:0
    08:25:38.769 -> Incoming change for sensor:2
    08:25:38.769 -> 0
    93674 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:1
    08:25:38.963 -> Incoming change for sensor:2
    08:25:39.003 -> 1
    94012 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:0
    08:25:39.315 -> Incoming change for sensor:2
    08:25:39.315 -> 0
    94229 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:1
    08:25:39.524 -> Incoming change for sensor:2
    08:25:39.557 -> 1
    94721 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:0
    08:25:40.049 -> Incoming change for sensor:2
    08:25:40.049 -> 0
    94893 TSF:MSG:SEND,101-101-0-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:23.5
    08:25:40.213 -> T: 23.50
    94973 TSF:MSG:SEND,101-101-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:40.6
    08:25:40.284 -> H: 40.60
    08:25:40.284 -> 94981 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:1
    08:25:40.284 -> Incoming change for sensor:2
    08:25:40.284 -> 1
    95182 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:0
    08:25:40.495 -> Incoming change for sensor:2
    08:25:40.495 -> 0
    95396 TSF:MSG:READ,0-0-101,s=2,c=1,t=2,pt=0,l=1,sg=0:1
    08:25:40.702 -> Incoming change for sensor:2
    08:25:40.702 -> 1
    97184 TSF:MSG:READ,0-0-101,s=1,c=1,t=2,pt=0,l=1,sg=0:1
    08:25:42.505 -> Incoming change for sensor:1
    08:25:42.505 -> 1
    97225 TSF:MSG:READ,0-0-101,s=1,c=1,t=2,pt=0,l=1,sg=0:1
    08:25:42.547 -> Incoming change for sensor:1
    08:25:42.547 -> 1
    

    and the acting time delay is only sometimes... i don't know jet how to reproduce it....
    ok with the time delay i can live... but the buttons would be great if the could work...
    any ideas left?


  • DHT12 + 2Relay + 2Button - Combining Problem
    michlb1982M michlb1982
    Development

    @mfalkvidd you are right, but in the original Relay-Scetch there is also no digitalWrite command in the loop-section... https://www.mysensors.org/build/relay
    only in the viod receive message section is a digitalwrite command....

    there is also another problmem...sometimes (i can't say when) there is the RElay not working or works lately.. .maybe it is when the DHT is measuring? i can't explain...


  • DHT12 + 2Relay + 2Button - Combining Problem
    michlb1982M michlb1982
    Development

    Hello again.. long time ago.. but still here. ;-)

    well thankss for the tip... but now i have a other problem...
    the relay will work when the order comes from the gateway ... but when i press the button, nothing happens...
    any ideas?

    here the code:

    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_REPEATER_FEATURE
    
    // Define Node ID
    #define MY_NODE_ID 101
    
    #define RELAY_ON 1
    #define RELAY_OFF 0
    
    #define SSR_A_ID 1   // Id of the sensor child
    #define SSR_B_ID 2   // Id of the sensor child
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 0//1
    #define SENSOR_TEMP_OFFSET 0
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <Bounce2.h>
    #include <DHT12.h>
    #include <Wire.h>
     
    const int buttonPinA = 7;
    const int buttonPinB = 8;
    const int relayPinA = 6;
    const int relayPinB = 5;
    int oldValueA = 0;
    int oldValueB = 0;
    bool stateA = false;
    bool stateB = false;
    
    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = true;
    static const uint8_t FORCE_UPDATE_N_READS = 10;//10
    static const uint64_t UPDATE_INTERVAL = 30000;//30000
    
    Bounce debouncerA = Bounce();
    Bounce debouncerB = Bounce();
    
    MyMessage msgA(SSR_A_ID, V_STATUS);
    MyMessage msgB(SSR_B_ID, V_STATUS);
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    DHT12 dht12; 
    
    void setup()
    {
      //Serial.begin(115200);
      Wire.begin();
      pinMode(buttonPinA, INPUT_PULLUP); // Setup the button Activate internal pull-up
      pinMode(buttonPinB, INPUT_PULLUP); // Setup the button Activate internal pull-up
    
    
      // After setting up the buttons, setup debouncer
      debouncerA.attach(buttonPinA);
      debouncerA.interval(5); //5
      debouncerB.attach(buttonPinB);
      debouncerB.interval(5);//5
    
      // Make sure relays are off when starting up
      digitalWrite(relayPinA, RELAY_OFF);
      digitalWrite(relayPinB, RELAY_OFF);
      // Then set relay pins in output mode
      pinMode(relayPinA, OUTPUT);
      pinMode(relayPinB, OUTPUT);
      
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("2xRelais,2xButton,DHT12", "1.2");
    
      // Register all sensors to gw (they will be created as child devices)
      present(SSR_A_ID, S_LIGHT);
      present(SSR_B_ID, S_LIGHT);
    
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
    
      metric = getControllerConfig().isMetric;
    
    }
    
    /*
       Example on how to asynchronously check for new messages from gw
    */
    void loop()
    {
      debouncerA.update();
      // Get the update value
      int valueA = debouncerA.read();
      if (valueA != oldValueA) {
        send(msgA.set(stateA ? false : true), true); // Send new state and request ack back
      oldValueA = valueA;
      }
     
    
      debouncerB.update();
      // Get the update value
      int valueB = debouncerB.read();
      if (valueB != oldValueB) {
        send(msgB.set(stateB ? false : true), true); // Send new state and request ack back
      oldValueB = valueB;
      }
    
        
      // Force reading sensor, so it works also after sleep()
    //  dht12.readSensor(true);
    
      // Get temperature from DHT library
      float temperature = dht12.readTemperature();
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT!");
      } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
        // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
        lastTemp = temperature;
    
        // apply the offset before converting to something different than Celsius degrees
        temperature += SENSOR_TEMP_OFFSET;
    
        if (!metric) {
          temperature = dht12.readTemperature();
        }
        // Reset no updates counter
        nNoUpdatesTemp = 0;
        send(msgTemp.set(temperature, 1));
    
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      } else {
        // Increase no update counter if the temperature stayed the same
        nNoUpdatesTemp++;
      }
    
      // Get humidity from DHT library
      float humidity = dht12.readHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
        // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
        lastHum = humidity;
        // Reset no updates counter
        nNoUpdatesHum = 0;
        send(msgHum.set(humidity, 1));
    
        #ifdef MY_DEBUG
        Serial.print("H: ");
        Serial.println(humidity);
        #endif
      } else {
        // Increase no update counter if the humidity stayed the same
        nNoUpdatesHum++;
      }
    
      // Sleep for a while to save energy
      wait(UPDATE_INTERVAL);
      
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type == V_STATUS) {
          
        switch (message.sensor) {
          case 1:
            stateA = message.getBool();
            digitalWrite(message.sensor + 4, stateA ? RELAY_ON : RELAY_OFF);
            break;
          case 2:
            stateB = message.getBool();
            digitalWrite(message.sensor + 4, stateB ? RELAY_ON : RELAY_OFF);
            break;
        }
       
          // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.println(message.sensor);
        //Serial.print("from node:");
        //Serial.println(message.sender);
        //Serial.print(", New status: ");
        Serial.println(message.getBool());
      }
    }
    

  • Mysensort mit DHT12 (i2C)
    michlb1982M michlb1982
    Hardware

    Well i did it... i've got a working MYSENSOR with DHT12...
    here the Code ... its not nice but it works...

    // Enable debug prints
    #define MY_DEBUG
    
    // Define Node ID
    #define MY_NODE_ID 128
    //#define MY_REPEATER_FEATURE
    
    
    // Enable and select radio type attached 
    #define MY_RADIO_NRF24
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT12.h>
    #include <Wire.h>
    DHT12 dht12;
    
    #define SENSOR_TEMP_OFFSET 0
    
    // Sleep time between sensor updates (in milliseconds)
    // Must be >1000ms for DHT22 and >2000ms for DHT11
    static const uint64_t UPDATE_INTERVAL = 30000;
    
    static const uint8_t FORCE_UPDATE_N_READS = 10;
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    
    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = true;
    
    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("DHT12", "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;
    }
    
    
    void setup()
    {
      Wire.begin();
    }
    
    
    void loop()      
    {  
      // Force reading sensor, so it works also after sleep()
      //dht12.readSensor(true);
    
      // Get temperature from DHT library
      float temperature = dht12.readTemperature();
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT!");
      } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
        // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
        lastTemp = temperature;
    
        // apply the offset before converting to something different than Celsius degrees
        temperature += SENSOR_TEMP_OFFSET;
    
        if (!metric) {
          temperature = dht12.readTemperature();
        }
        // Reset no updates counter
        nNoUpdatesTemp = 0;
        send(msgTemp.set(temperature, 1));
    
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      } else {
        // Increase no update counter if the temperature stayed the same
        nNoUpdatesTemp++;
      }
    
      // Get humidity from DHT library
      float humidity = dht12.readHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
        // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
        lastHum = humidity;
        // Reset no updates counter
        nNoUpdatesHum = 0;
        send(msgHum.set(humidity, 1));
    
        #ifdef MY_DEBUG
        Serial.print("H: ");
        Serial.println(humidity);
        #endif
      } else {
        // Increase no update counter if the humidity stayed the same
        nNoUpdatesHum++;
      }
    
      // Sleep for a while to save energy
      sleep(UPDATE_INTERVAL); 
      //wait(UPDATE_INTERVAL); //for repeaters
    }
    

    i Used this library: https://github.com/Bobadas/DHT12_library_Arduino/blob/master/README.md

    here the datasheet of the dht12: http://www.robototehnika.ru/file/DHT12.pdf


  • DHT12 + 2Relay + 2Button - Combining Problem
    michlb1982M michlb1982
    Development

    @rejoe2
    thanks for the link.. i will try... and report if it worked..


  • DHT12 + 2Relay + 2Button - Combining Problem
    michlb1982M michlb1982
    Development

    Hello
    I tried to combine a DHT12 + 2 Relay incl. Buttons.
    ![alt text](0_1536489069705_SENS-DHT-12.JPG image url)
    Well it works (somtimes longer.. sometimes not..), i combined the Scetches of both but often i have the problme, that the Relays don't act anymore and the buttons didn't either since the beginning...

    i found something on google that i have to change the sleep to wait command so it works little better but after some time it also even quits working.

    what is my mistake???

    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_REPEATER_FEATURE
    
    #define RELAY_ON 1
    #define RELAY_OFF 0
    
    #define SSR_A_ID 1   // Id of the sensor child
    #define SSR_B_ID 2   // Id of the sensor child
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 0//1
    #define SENSOR_TEMP_OFFSET 0
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <Bounce2.h>
    #include <DHT12.h>
    #include <Wire.h>
     
    const int buttonPinA = 7;
    const int buttonPinB = 8;
    const int relayPinA = 6;
    const int relayPinB = 5;
    int oldValueA = 0;
    int oldValueB = 0;
    bool stateA = false;
    bool stateB = false;
    
    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = true;
    static const uint8_t FORCE_UPDATE_N_READS = 10;//10
    static const uint64_t UPDATE_INTERVAL = 30000;//30000
    
    Bounce debouncerA = Bounce();
    Bounce debouncerB = Bounce();
    
    MyMessage msgA(SSR_A_ID, V_STATUS);
    MyMessage msgB(SSR_B_ID, V_STATUS);
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    DHT12 dht12; 
    
    void setup()
    {
      //Serial.begin(115200);
      Wire.begin();
      pinMode(buttonPinA, INPUT_PULLUP); // Setup the button Activate internal pull-up
      pinMode(buttonPinB, INPUT_PULLUP); // Setup the button Activate internal pull-up
    
    
      // After setting up the buttons, setup debouncer
      debouncerA.attach(buttonPinA);
      debouncerA.interval(5); //5
      debouncerB.attach(buttonPinB);
      debouncerB.interval(5);//5
    
      // Make sure relays are off when starting up
      digitalWrite(relayPinA, RELAY_OFF);
      digitalWrite(relayPinB, RELAY_OFF);
      // Then set relay pins in output mode
      pinMode(relayPinA, OUTPUT);
      pinMode(relayPinB, OUTPUT);
      
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("2xRelais,2xButton,DHT12", "1.2");
    
      // Register all sensors to gw (they will be created as child devices)
      present(SSR_A_ID, S_LIGHT);
      present(SSR_B_ID, S_LIGHT);
    
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
    
      metric = getControllerConfig().isMetric;
    
    }
    
    /*
       Example on how to asynchronously check for new messages from gw
    */
    void loop()
    {
      debouncerA.update();
      // Get the update value
      int valueA = debouncerA.read();
      if (valueA != oldValueA) {
        send(msgA.set(stateA ? false : true), true); // Send new state and request ack back
      oldValueA = valueA;
      }
     
    
      debouncerB.update();
      // Get the update value
      int valueB = debouncerB.read();
      if (valueB != oldValueB) {
        send(msgB.set(stateB ? false : true), true); // Send new state and request ack back
      oldValueB = valueB;
      }
    
        
      // Force reading sensor, so it works also after sleep()
    //  dht12.readSensor(true);
    
      // Get temperature from DHT library
      float temperature = dht12.readTemperature();
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT!");
      } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
        // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
        lastTemp = temperature;
    
        // apply the offset before converting to something different than Celsius degrees
        temperature += SENSOR_TEMP_OFFSET;
    
        if (!metric) {
          temperature = dht12.readTemperature();
        }
        // Reset no updates counter
        nNoUpdatesTemp = 0;
        send(msgTemp.set(temperature, 1));
    
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      } else {
        // Increase no update counter if the temperature stayed the same
        nNoUpdatesTemp++;
      }
    
      // Get humidity from DHT library
      float humidity = dht12.readHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
        // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
        lastHum = humidity;
        // Reset no updates counter
        nNoUpdatesHum = 0;
        send(msgHum.set(humidity, 1));
    
        #ifdef MY_DEBUG
        Serial.print("H: ");
        Serial.println(humidity);
        #endif
      } else {
        // Increase no update counter if the humidity stayed the same
        nNoUpdatesHum++;
      }
    
      // Sleep for a while to save energy
      wait(UPDATE_INTERVAL);
      
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type == V_STATUS) {
          
        switch (message.sensor) {
          case 1:
            stateA = message.getBool();
            digitalWrite(message.sensor + 4, stateA ? RELAY_ON : RELAY_OFF);
            break;
          case 2:
            stateB = message.getBool();
            digitalWrite(message.sensor + 4, stateB ? RELAY_ON : RELAY_OFF);
            break;
        }
       
          // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.println(message.sensor);
        //Serial.print("from node:");
        //Serial.println(message.sender);
        //Serial.print(", New status: ");
        Serial.println(message.getBool());
      }
    }
    

    Thanks for help!


  • Mini Pro + DHT12 + NRF24L01+ SMD
    michlb1982M michlb1982
    Hardware

    @gohan thanks for the info.... you were right!
    i soldered the smd radio like in the building instruktions descripted,and because of that, that there were no infos about the voltage of the smd radio i used the 3,3v regulator ... that was the mistake!!!
    so i thaught, if it's not workimg, let's try tu use the 5v, worst case the radio will go to hell....
    so... testet with 5v on themradio and ... heureka it works.... now i have the dht12 with nrf24 smd on a mini pro.... so the sensor is very small and easy coded....
    i will make a build and wire diagramm and rewrite the code... who can i send it for publication on the mysensors site?


  • Mini Pro + DHT12 + NRF24L01+ SMD
    michlb1982M michlb1982
    Hardware

    @mfalkvidd Thanks for the link... got it..

    here the output from the debug..

    pi@SmartPi:~/MySensors $ sudo ./bin/mysgw -d
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.1.0-beta
    mysgw: MCO:BGN:INIT GW,CP=RNNG--Q,VER=2.1.0-beta
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=1
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=2
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=3
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=4
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=5
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=6
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=7
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    mysgw: TSF:MSG:READ,70-70-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    mysgw: TSF:MSG:BC
    mysgw: TSF:MSG:FPAR REQ,ID=70
    mysgw: TSF:PNG:SEND,TO=0
    mysgw: TSF:CKU:OK
    mysgw: TSF:MSG:GWL OK
    mysgw: Received SIGINT
    

    My other sensors are working fine, just the new one isn't .


  • Mini Pro + DHT12 + NRF24L01+ SMD
    michlb1982M michlb1982
    Hardware

    @mfalkvidd sure i can, but how? is this you want to see an extra log direct from the gateway? where will i find this log?

    as i said i'm not an it technican just an hobbyist, a little DIY'er....


  • Mini Pro + DHT12 + NRF24L01+ SMD
    michlb1982M michlb1982
    Hardware

    good morning

    here the config of my rpi-gateway with direct connected nrf24L01+.

    define SerialGate MYSENSORS /dev/ttyUSB020@115200
    attr SerialGate autocreate 1
    attr SerialGate first-sensorid 1
    attr SerialGate last-sensorid 255
    attr SerialGate requestAck 1
    attr SerialGate room 00_Sensornet
    attr SerialGate stateFormat connection```
    
    
    
    

    DEF /dev/ttyUSB020@115200
    DeviceName /dev/ttyUSB020@115200
    FD 4
    NAME SerialGate
    NOTIFYDEV global
    NR 63
    NTFY_ORDER 50-SerialGate
    PARTIAL
    STATE connected
    TYPE MYSENSORS
    ack 1
    inclusion-mode 1
    outstandingAck 0
    version 2.1.0-beta ```

    libraryversion on sensor 2.1.1
    version of Gateway 2.1.0-beta

    how can i update the gateway version?

    is it nessasary to update the old sensores too?

    greetings

    ps the log:

    2017.04.16 08:41:24 1: Including ./log/fhem.save
    2017.04.16 08:41:24 3: Opening SerialGate device /dev/ttyUSB020
    2017.04.16 08:41:24 3: Setting SerialGate serial parameters to 115200,8,N,1
    2017.04.16 08:41:24 3: SerialGate device opened
    2017.04.16 08:44:47 5: MYSENSORS/RAW: /70;0;1;0;0;18.0
    
    2017.04.16 08:44:47 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:44:47 5: MYSENSORS/RAW: /70;0;1;0;1;38.0
    
    2017.04.16 08:44:47 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:44:58 5: MYSENSORS/RAW: /170;0;1;0;0;20.0
    
    2017.04.16 08:44:58 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '20.0'
    
    2017.04.16 08:45:28 5: MYSENSORS/RAW: /170;0;1;0;1;36.0
    160;0;1;0;0;24.0
    160;0;1;0;1;35.0
    190;0;1;0;0;25.0
    190;0;1;0;1;39.0
    70;0;1;0;0;18.0
    70;0;1;0;1;38.0
    130;0;1;0;0;21.0
    130;0;1;0;1;36.0
    120;0;1;0;0;23.0
    120;0;1;0;1;35.0
    
    2017.04.16 08:45:28 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:45:28 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '24.0'
    
    2017.04.16 08:45:28 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:45:28 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '25.0'
    
    2017.04.16 08:45:28 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '39.0'
    
    2017.04.16 08:45:28 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:45:29 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:45:29 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '21.0'
    
    2017.04.16 08:45:29 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:45:29 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '23.0'
    
    2017.04.16 08:45:29 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:46:01 5: MYSENSORS/RAW: /70;0;1;0;0;18.0
    
    2017.04.16 08:46:01 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:46:02 5: MYSENSORS/RAW: /70;0;1;0;1;38.0
    
    2017.04.16 08:46:02 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:46:06 5: MYSENSORS/RAW: /170;0;1;0;0;20.0
    
    2017.04.16 08:46:06 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '20.0'
    
    2017.04.16 08:46:07 5: MYSENSORS/RAW: /170;0;1;0;1;36.0
    
    2017.04.16 08:46:07 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:46:14 5: MYSENSORS/RAW: /160;0;1;0;0;24.0
    
    2017.04.16 08:46:14 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '24.0'
    
    2017.04.16 08:46:15 5: MYSENSORS/RAW: /160;0;1;0;1;35.0
    
    2017.04.16 08:46:15 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:46:22 5: MYSENSORS/RAW: /190;0;1;0;0;25.0
    
    2017.04.16 08:46:22 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '25.0'
    
    2017.04.16 08:46:22 5: MYSENSORS/RAW: /190;0;1;0;1;39.0
    
    2017.04.16 08:46:22 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '39.0'
    
    2017.04.16 08:46:31 5: MYSENSORS/RAW: /120;0;1;0;0;23.0
    
    2017.04.16 08:46:31 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '23.0'
    
    2017.04.16 08:46:31 5: MYSENSORS/RAW: /120;0;1;0;1;35.0
    
    2017.04.16 08:46:31 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:46:33 5: MYSENSORS/RAW: /130;0;1;0;0;21.0
    
    2017.04.16 08:46:33 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '21.0'
    
    2017.04.16 08:46:34 5: MYSENSORS/RAW: /130;0;1;0;1;36.0
    
    2017.04.16 08:46:34 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:46:39 5: MYSENSORS/RAW: /70;0;1;0;0;18.0
    
    2017.04.16 08:46:39 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:46:39 5: MYSENSORS/RAW: /70;0;1;0;1;38.0
    
    2017.04.16 08:46:39 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:47:14 5: MYSENSORS/RAW: /170;0;1;0;0;20.0
    
    2017.04.16 08:47:14 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '20.0'
    
    2017.04.16 08:47:15 5: MYSENSORS/RAW: /170;0;1;0;1;36.0
    
    2017.04.16 08:47:15 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:47:16 5: MYSENSORS/RAW: /70;0;1;0;0;18.0
    
    2017.04.16 08:47:16 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:47:16 5: MYSENSORS/RAW: /70;0;1;0;1;38.0
    
    2017.04.16 08:47:16 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:47:22 5: MYSENSORS/RAW: /160;0;1;0;0;24.0
    
    2017.04.16 08:47:22 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '24.0'
    
    2017.04.16 08:47:22 5: MYSENSORS/RAW: /160;0;1;0;1;35.0
    
    2017.04.16 08:47:22 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:47:27 5: MYSENSORS/RAW: /190;0;1;0;0;25.0
    
    2017.04.16 08:47:27 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '25.0'
    
    2017.04.16 08:47:27 5: MYSENSORS/RAW: /190;0;1;0;1;39.0
    
    2017.04.16 08:47:27 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '39.0'
    
    2017.04.16 08:47:35 5: MYSENSORS/RAW: /120;0;1;0;0;23.0
    
    2017.04.16 08:47:35 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '23.0'
    
    2017.04.16 08:47:35 5: MYSENSORS/RAW: /120;0;1;0;1;35.0
    
    2017.04.16 08:47:35 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:47:42 5: MYSENSORS/RAW: /130;0;1;0;0;21.0
    
    2017.04.16 08:47:42 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '21.0'
    
    2017.04.16 08:47:42 5: MYSENSORS/RAW: /130;0;1;0;1;36.0
    
    2017.04.16 08:47:42 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:47:53 5: MYSENSORS/RAW: /70;0;1;0;0;18.0
    
    2017.04.16 08:47:53 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:47:54 5: MYSENSORS/RAW: /70;0;1;0;1;38.0
    
    2017.04.16 08:47:54 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:48:23 5: MYSENSORS/RAW: /170;0;1;0;0;20.0
    
    2017.04.16 08:48:23 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '20.0'
    
    2017.04.16 08:48:23 5: MYSENSORS/RAW: /170;0;1;0;1;36.0
    
    2017.04.16 08:48:23 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:48:29 5: MYSENSORS/RAW: /160;0;1;0;0;24.0
    
    2017.04.16 08:48:29 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '24.0'
    
    2017.04.16 08:48:29 5: MYSENSORS/RAW: /160;0;1;0;1;35.0
    
    2017.04.16 08:48:29 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:48:31 5: MYSENSORS/RAW: /70;0;1;0;0;18.0
    
    2017.04.16 08:48:31 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:48:31 5: MYSENSORS/RAW: /70;0;1;0;1;38.0
    
    2017.04.16 08:48:31 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:48:32 5: MYSENSORS/RAW: /190;0;1;0;0;25.0
    
    2017.04.16 08:48:32 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '25.0'
    
    2017.04.16 08:48:33 5: MYSENSORS/RAW: /190;0;1;0;1;39.0
    
    2017.04.16 08:48:33 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '39.0'
    
    2017.04.16 08:48:39 5: MYSENSORS/RAW: /120;0;1;0;0;23.0
    
    2017.04.16 08:48:39 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '23.0'
    
    2017.04.16 08:48:39 5: MYSENSORS/RAW: /120;0;1;0;1;35.0
    
    2017.04.16 08:48:39 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:48:50 5: MYSENSORS/RAW: /130;0;1;0;0;21.0
    
    2017.04.16 08:48:50 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '21.0'
    
    2017.04.16 08:48:50 5: MYSENSORS/RAW: /130;0;1;0;1;36.0
    
    2017.04.16 08:48:50 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:49:08 5: MYSENSORS/RAW: /70;0;1;0;0;18.0
    
    2017.04.16 08:49:08 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:49:09 5: MYSENSORS/RAW: /70;0;1;0;1;38.0
    
    2017.04.16 08:49:09 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:49:31 5: MYSENSORS/RAW: /170;0;1;0;0;20.0
    
    2017.04.16 08:49:31 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '20.0'
    
    2017.04.16 08:49:32 5: MYSENSORS/RAW: /170;0;1;0;1;36.0
    
    2017.04.16 08:49:32 5: MYSENSORS Read: Rx: fr=170 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    
    2017.04.16 08:49:36 5: MYSENSORS/RAW: /160;0;1;0;0;24.0
    
    2017.04.16 08:49:36 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '24.0'
    
    2017.04.16 08:49:36 5: MYSENSORS/RAW: /160;0;1;0;1;35.0
    
    2017.04.16 08:49:36 5: MYSENSORS Read: Rx: fr=160 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:49:37 5: MYSENSORS/RAW: /190;0;1;0;0;25.0
    
    2017.04.16 08:49:37 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '25.0'
    
    2017.04.16 08:49:38 5: MYSENSORS/RAW: /190;0;1;0;1;39.0
    
    2017.04.16 08:49:38 5: MYSENSORS Read: Rx: fr=190 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '39.0'
    
    2017.04.16 08:49:43 5: MYSENSORS/RAW: /120;0;1;0;0;23.0
    
    2017.04.16 08:49:43 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '23.0'
    
    2017.04.16 08:49:43 5: MYSENSORS/RAW: /120;0;1;0;1;35.0
    
    2017.04.16 08:49:43 5: MYSENSORS Read: Rx: fr=120 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '35.0'
    
    2017.04.16 08:49:45 5: MYSENSORS/RAW: /70;0;1;0;0;18.0
    
    2017.04.16 08:49:45 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '18.0'
    
    2017.04.16 08:49:46 5: MYSENSORS/RAW: /70;0;1;0;1;38.0
    
    2017.04.16 08:49:46 5: MYSENSORS Read: Rx: fr=070 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '38.0'
    
    2017.04.16 08:49:58 5: MYSENSORS/RAW: /130;0;1;0;0;21.0
    
    2017.04.16 08:49:58 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=000(V_TEMP          ) ack=0 '21.0'
    
    2017.04.16 08:49:58 5: MYSENSORS/RAW: /130;0;1;0;1;36.0
    
    2017.04.16 08:49:58 5: MYSENSORS Read: Rx: fr=130 ci=000 c=001(C_SET         ) st=001(V_HUM           ) ack=0 '36.0'
    

  • Mini Pro + DHT12 + NRF24L01+ SMD
    michlb1982M michlb1982
    Hardware

    Hi
    I ordered the new DHT12 and the NRF24L01+ SMD and tried to build an Humidity sensor but it istn't working..
    i'm not a programmer so i don't no where the problem is...

    i testet the DHT12 with this code and it works...

    //Test library for DHT12 sensors.
    //Write by Bobadas.
    
    #include <DHT12.h>
    #include <Wire.h>     //The DHT12 uses I2C comunication.
    DHT12 dht12;          //Preset scale CELSIUS and ID 0x5c.
    /*
    For configuration library:
    DHT12 dht12("Scale temperature","ID device for I2C");
    On "Scale temperature" you can select the preset scale:
    CELSIUS, FAHRENHEIT or KELVIN.
    And on "ID device", you can put ID sensor, on DHT12
    normally is 0x5c.
    Examples:
      DHT12 dht12;
    The preset scale is CELSIUS and ID is 0x5c.
      DHT12 dht12(KELVIN);
    the preset scale is KELVIN and ID is 0x5c.
      DHT12 dht12(FAHRENHEIT,0x53);
    The preset scale is FAHRENHEIT and ID is 0x53.
    */
    
    void setup() {
      Wire.begin();
      Serial.begin(9600);
      Serial.println("Prueba de libreria DHT12:");
    }
    
    void loop() {
      Serial.print("Temperatura: ");
      Serial.print(dht12.readTemperature());
    //Read temperature with preset scale.
      Serial.print("*C  Humedad: ");
      Serial.print(dht12.readHumidity());
    //Read humidity.
      Serial.println("%RH");
      Serial.print("Temperatura: ");
      Serial.print(dht12.readTemperature(FAHRENHEIT));
    //Read temperature as forced fahrenheit.
      Serial.println("*F");
      Serial.print("Temperatura: ");
      Serial.print(dht12.readTemperature(KELVIN));
    //Read termperature as forced kelvin.
      Serial.println("*K");
    
      delay(5000);
    }
    
    /*
    if it delivers the values 0.01, 0.02 or 0.03, you are
    giving us the error that has had in reading:
    0.01: DHT12 is not connected or the ID does not exist.
    0.02: There have been a problem with communication.
    0.03: Checksum error (bad connections, check the wires). 
    */
    

    and i wired the nrf like in the tutorial but i think there is something wrong... i used this for the wireing
    alt text

    and i used the 3,3V regulator..

    then i changed the code like this:

    /*
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0: Michael Berger
     * Version 1.1 - 2017-03-31: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
     * 
     * DESCRIPTION
     * This sketch provides an example of how to implement a humidity/temperature
     * sensor using a DHT12
     *  
     * For more information, please visit:
     * http://www.mysensors.org/build/humidity
     * 
     */
    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached 
    #define MY_RADIO_NRF24
    
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT12.h>
    #include <Wire.h>     //The DHT12 uses I2C comunication.
    DHT12 dht12;          //Preset scale CELSIUS and ID 0x5c.
    
    
    // Sleep time between sensor updates (in milliseconds)
    // Must be >1000ms for DHT22 and >2000ms for DHT11
    static const uint64_t UPDATE_INTERVAL = 60000;
    
    // Force sending an update of the temperature after n sensor reads, so a controller showing the
    // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
    // the value didn't change since;
    // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
    static const uint8_t FORCE_UPDATE_N_READS = 10;
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    
    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = true;
    
    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("TemperatureAndHumidity", "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;
    }
    
    
    void setup()
    {
      Wire.begin();
      Serial.begin(9600);
      Serial.println("Prueba de libreria DHT12:");
    }
    
    
    void loop()      
    {  
      // Force reading sensor, so it works also after sleep()
    //  dht12.readSensor(true);
    
      // Get temperature from DHT library
      float temperature = dht12.readTemperature();
      Serial.print("Temp: ");
      Serial.print(dht12.readTemperature());
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT!");
      } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
        // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
        lastTemp = temperature;
    //    if (!metric) {
    //      temperature = dht12.toFahrenheit(temperature);
    //    }
        // Reset no updates counter
        nNoUpdatesTemp = 0;
    //    temperature += SENSOR_TEMP_OFFSET;
        send(msgTemp.set(temperature, 1));
    
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      } else {
        // Increase no update counter if the temperature stayed the same
        nNoUpdatesTemp++;
      }
    
      // Get humidity from DHT library
      float humidity = dht12.readHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
        // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
        lastHum = humidity;
        // Reset no updates counter
        nNoUpdatesHum = 0;
        send(msgHum.set(humidity, 1));
    
        #ifdef MY_DEBUG
        Serial.print("H: ");
        Serial.println(humidity);
        #endif
      } else {
        // Increase no update counter if the humidity stayed the same
        nNoUpdatesHum++;
      }
    
      // Sleep for a while to save energy
      sleep(UPDATE_INTERVAL); 
    }
    

    now i get these lines in the serial monitor:

    222794 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    224802 !TSM:FPAR:NO REPLY
    224804 TSM:FPAR
    226404 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    228412 !TSM:FPAR:NO REPLY
    228414 TSM:FPAR
    230013 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    232022 !TSM:FPAR:NO REPLY
    232024 TSM:FPAR
    233623 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:

    can anybody tell me where the problem is.????

    thanks a lot!

    ps i use a RPi-Gateway with about 15 older Arduino Nano with DHT11 sensors..... they are working fine but too big...


  • Mysensort mit DHT12 (i2C)
    michlb1982M michlb1982
    Hardware

    Hello

    Does anyone built up an Mysenors Humidity Node with an DHT12 it is an I2C sensor...

    but I2C is needet for the NRF24+ or?

    Thanks


  • 💬 Building a Raspberry Pi Gateway
    michlb1982M michlb1982
    Announcements

    hi
    yesterday i tried to build a rpi-gateway but i had trouble to access, after changeing the rights on the port to 777 and group to dialout i could access via
    fhem. and i didn't use the symlink, i used the port directly /dev/pts/0@115200 andthen it works perfectly!

    thanks...

    p.s.: i uses always sudo while make and the other installation commands.

    greets mike


  • Magnetic field detection
    michlb1982M michlb1982
    Feature Requests

    well, the promised curcuit...Windrichtung-AS5040-Mysensor.pdf Windrichtung_Steckplatine.jpg Windrichtung.fzz


  • Magnetic field detection
    michlb1982M michlb1982
    Feature Requests

    here some pics
    Foto 06.12.15, 13 06 18.jpg Foto 06.12.15, 13 06 27.jpg Foto 06.12.15, 13 06 08.jpg Foto 06.12.15, 13 06 00.jpg


  • Magnetic field detection
    michlb1982M michlb1982
    Feature Requests

    Hello

    thanks for the input...
    well i did it...
    i was able to build an Wind-direction-MYSENSOR... well i'm sure, its a little bit
    awkward and much to complicated but it works quite OK...
    the next step is to build a windspeed - sensor.. with the AS5040..

    here the Arduino nano Code...:

    #include <SPI.h>
    #include <MySensor.h>
    
    const int ledPin = 13; //LED connected to digital pin 13
    const int clockPin = 5; //output to clock
    const int CSnPin = 4; //output to chip select
    const int inputPin = 6; //read AS5040
    
    int inputstream = 0; //one bit read from pin
    long packeddata = 0; //two bytes concatenated from inputstream
    long angle = 0; //holds processed angle value
    long anglemask = 65472; //0x1111111111000000: mask to obtain first 10 digits with position info
    long statusmask = 63; //0x000000000111111; mask to obtain last 6 digits containing status info
    long statusbits; //holds status/error information
    int DECn; //bit holding decreasing magnet field error data
    int INCn; //bit holding increasing magnet field error data
    int OCF; //bit holding startup-valid bit
    int COF; //bit holding cordic DSP processing error data
    int LIN; //bit holding magnet field displacement error data
    int debug = 0; //SET THIS TO 0 TO DISABLE PRINTING OF ERROR CODES
    int shortdelay = 1000; // this is the microseconds of delay in the data clock
    int longdelay =1000; // this is the milliseconds between readings
    #define CHILD_ID_DIR 0
    //#define INTERRUPT inputPin
    MySensor gw;
    MyMessage msgDIR(CHILD_ID_DIR, V_DIRECTION);
    
    void setup()
    {
      gw.begin(NULL, AUTO, true, AUTO);
      Serial.begin(250000);
      pinMode(ledPin, OUTPUT); // visual signal of I/O to chip
      pinMode(clockPin, OUTPUT); // SCK
      pinMode(CSnPin, OUTPUT); // CSn -- has to toggle high and low to signal chip to start data transfer
      pinMode(inputPin, INPUT); // SDA
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Winddirection", "1.0");
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_DIR, S_WIND);
    }
    
    void loop()
    {
    // CSn needs to cycle from high to low to initiate transfer. Then clock cycles. As it goes high
    // again, data will appear on sda
      digitalWrite(CSnPin, HIGH); // CSn high
      digitalWrite(clockPin, HIGH); // CLK high
      delay(longdelay);// time between readings
      digitalWrite(ledPin, HIGH); // signal start of transfer with LED
      digitalWrite(CSnPin, LOW); // CSn low: start of transfer
      delayMicroseconds(shortdelay); // delay for chip initialization
      digitalWrite(clockPin, LOW); // CLK goes low: start clocking
      delayMicroseconds(shortdelay); // hold low
      for (int x=0; x <16; x++) // clock signal, 16 transitions, output to clock pin
      {
        digitalWrite(clockPin, HIGH); //clock goes high
        delayMicroseconds(shortdelay); // 
        inputstream =digitalRead(inputPin); // read one bit of data from pin
    //Serial.print(inputstream, DEC);
        packeddata = ((packeddata << 1) + inputstream);// left-shift summing variable, add pin value
        digitalWrite(clockPin, LOW);
        delayMicroseconds(shortdelay); // end of one clock cycle
      }
    // end of entire clock cycle
    //Serial.println(" ");
      digitalWrite(ledPin, LOW); // signal end of transmission
    // lots of diagnostics for verifying bitwise operations
    //Serial.print("packed:");
    //Serial.println(packeddata,DEC);
    //Serial.print("pack bin: ");
    //Serial.println(packeddata,BIN);
      angle = packeddata & anglemask; // mask rightmost 6 digits of packeddata to zero, into angle.
    //Serial.print("mask: ");
    //Serial.println(anglemask, BIN);
    //Serial.print("bin angle:");
    //Serial.println(angle, BIN);
    //Serial.print("angle: ");
    //Serial.println(angle, DEC);
      angle = (angle >> 6); // shift 16-digit angle right 6 digits to form 10-digit value
    //Serial.print("angleshft:");
    //Serial.println(angle, BIN);
    //Serial.print("angledec: ");
    //Serial.println(angle, DEC);
      angle = angle * 0.3515; // angle * (360/1024) == actual degrees
      Serial.print("angle: "); // and, finally, print it.
      Serial.println(angle, DEC);
    //Serial.println("--------------------");
    //Serial.print("raw: "); // this was the prefix for the bit-by-bit diag output inside the loop.
      if (debug)
      {
        statusbits = packeddata & statusmask;
        DECn = statusbits & 2; // goes high if magnet moved away from IC
        INCn = statusbits & 4; // goes high if magnet moved towards IC
        LIN = statusbits & 8; // goes high for linearity alarm
        COF = statusbits & 16; // goes high for cordic overflow: data invalid
        OCF = statusbits & 32; // this is 1 when the chip startup is finished.
        if (DECn && INCn) { Serial.println("magnet moved out of range"); }
        else
        {
          if (DECn) { Serial.println("magnet moved away from chip"); }
          if (INCn) { Serial.println("magnet moved towards chip"); }
        }
        if (LIN) { Serial.println("linearity alarm: magnet misaligned? Data questionable."); }
        if (COF) { Serial.println("cordic overflow: magnet misaligned? Data invalid."); }
      }
      float V_DIRECTION = angle;
      gw.send(msgDIR.set(V_DIRECTION, DEC));
      packeddata = 0; // reset both variables to zero so they don't just accumulate
      angle = 0;
      gw.process();
      //gw.sleep(INTERRUPT,CHANGE);
      gw.sleep(longdelay);
    }
    
    

    the code for FHEM:

    define MYSENSOR_111 MYSENSORS_DEVICE 111
    attr MYSENSOR_111 IODev SerialGate
    attr MYSENSOR_111 alias Windrichtung
    attr MYSENSOR_111 group Sensoren
    attr MYSENSOR_111 mapReading_direction 0 direction
    attr MYSENSOR_111 mapReading_gust 0 gust
    attr MYSENSOR_111 mapReading_wind 0 wind
    attr MYSENSOR_111 mode repeater
    attr MYSENSOR_111 room 03_Umwelt
    attr MYSENSOR_111 stateFormat {sprintf("%.0f",ReadingsVal("MYSENSOR_111","direction",0))."°"}
    

    a curcuit will follow in the next days...

    greets..
    Mike


  • Compiling Problems since Update to 1.5
    michlb1982M michlb1982
    Troubleshooting compiling problems release 1.5

    Hi
    today i updated to Release 1.5 but now i cant't compile any more...
    i Use Arduino 1.6.5 on my Win10 and Arduino 1.6.4 on my Mac...
    i always get the message:
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp: In constructor 'MyGateway::MyGateway(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)':
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp:27:167: error: no matching function for call to 'MySensor::MySensor(uint8_t&, uint8_t&)'
    MyGateway::MyGateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_t _inclusion_pin, uint8_t _rx, uint8_t _tx, uint8_t _er) : MySensor(_cepin, _cspin) {
    ^
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp:27:167: note: candidates are:
    In file included from /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.h:15:0,
    from /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp:12:
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MySensor.h:153:2: note: MySensor::MySensor(MyTransport&, MyHw&)
    MySensor(MyTransport &radio =new MyTransportNRF24(), MyHw &hw=new MyHwDriver()
    ^
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MySensor.h:153:2: note: no known conversion for argument 1 from 'uint8_t {aka unsigned char}' to 'MyTransport&'
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MySensor.h:144:7: note: MySensor::MySensor(const MySensor&)
    class MySensor
    ^
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MySensor.h:144:7: note: candidate expects 1 argument, 2 provided
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp: In member function 'void MyGateway::begin(rf24_pa_dbm_e, uint8_t, rf24_datarate_e, void (
    )(char
    ))':
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp:41:20: error: 'setupRepeaterMode' was not declared in this scope
    setupRepeaterMode();
    ^
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp:78:39: error: 'setupRadio' was not declared in this scope
    setupRadio(paLevel, channel, dataRate);
    ^
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp:79:36: error: 'BASE_RADIO_ID' was not declared in this scope
    RF24::openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
    ^
    /Users/michaelberger/Dropbox/Arduino/libraries/MySensors/MyGateway.cpp:81:23: error: cannot call member function 'void RF24::startListening()' without object
    RF24::startListening();

    I'm not a programmer just a little tinker... ;-) so please can anyone help me?

    thanks


  • Magnetic field detection
    michlb1982M michlb1982
    Feature Requests

    Hello everyone...

    i try to build a Anemometer with an AS5040-Chip.... so it would be great to use mysensors with an Anemometer...
    does anyone have a similar project? maybe there are wiring-plans for the as5040 and arduinos?

    thanks for help..


  • 2 or more DHT11 - Sensors on one Arduino NANO MYSENSOR
    michlb1982M michlb1982
    Development dht11 mysensors

    well it works but not 100% and it needs a lot of time that the relay switches....
    is there a way to speed up the time between giving the order and the switching of the relay?...

    here the code

    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>  
    
    //Definition der Sensoren
    #define CHILD_ID1_HUM 1
    #define CHILD_ID1_TEMP 1
    #define CHILD_ID2_HUM 2
    #define CHILD_ID2_TEMP 2
    #define CHILD_ID3_HUM 3
    #define CHILD_ID3_TEMP 3
    const int HUMIDITY_SENSOR1_DIGITAL_PIN = 8;
    const int HUMIDITY_SENSOR2_DIGITAL_PIN = 7;
    const int HUMIDITY_SENSOR3_DIGITAL_PIN = 6;
    
    //Definition der Relays
    const int RELAY[] = {A0, A1, A2, A3};// Arduio Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 4 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    unsigned long SLEEP_TIME = 15*1000; // Sleep time between reads (in milliseconds)
    
    MySensor gw;
    DHT dht1;
    DHT dht2;
    DHT dht3;
    float lastTemp1;
    float lastHum1;
    float lastTemp2;
    float lastHum2;
    float lastTemp3;
    float lastHum3;
    boolean metric = true; 
    MyMessage msgHum1(CHILD_ID1_HUM, V_HUM);
    MyMessage msgTemp1(CHILD_ID1_TEMP, V_TEMP);
    MyMessage msgHum2(CHILD_ID2_HUM, V_HUM);
    MyMessage msgTemp2(CHILD_ID2_TEMP, V_TEMP);
    MyMessage msgHum3(CHILD_ID3_HUM, V_HUM);
    MyMessage msgTemp3(CHILD_ID3_TEMP, V_TEMP);
    
    void setup()  
    { 
      gw.begin();
      dht1.setup(HUMIDITY_SENSOR1_DIGITAL_PIN); 
      dht2.setup(HUMIDITY_SENSOR2_DIGITAL_PIN); 
      dht3.setup(HUMIDITY_SENSOR3_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_ID1_HUM, S_HUM);
      gw.present(CHILD_ID1_TEMP, S_TEMP);
      gw.present(CHILD_ID2_HUM, S_HUM);
      gw.present(CHILD_ID2_TEMP, S_TEMP);
      gw.present(CHILD_ID3_HUM, S_HUM);
      gw.present(CHILD_ID3_TEMP, S_TEMP);
      
      metric = gw.getConfig().isMetric;
        // Initialize library and add callback for incoming messages
      gw.begin(incomingMessage, AUTO, true);
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Relay", "1.4");
    
      // Fetch relay status
      for (int sensor=1, pin=0; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        gw.present(sensor, S_LIGHT);
        // Then set relay pins in output mode
        pinMode(RELAY[pin], OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(RELAY[pin], gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        //digitalWrite(RELAY[pin], 0);  //schaltet standardmaessig aus
    }
    
    }
    
    void loop()      
    
    {
      // Alway process incoming messages whenever possible
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
       if (message.type==V_LIGHT) {
         // Change relay state
         digitalWrite(RELAY[message.sensor-1], message.getBool()?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         gw.saveState(message.sensor, message.getBool());
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
       }  
      
    //DHT 11 Sensor 1
      delay(dht1.getMinimumSamplingPeriod());
    
      float temperature1 = dht1.getTemperature();
      if (isnan(temperature1)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature1 != lastTemp1) {
        lastTemp1 = temperature1;
        if (!metric) {
          temperature1 = dht1.toFahrenheit(temperature1);
        }
        gw.send(msgTemp1.set(temperature1, 1));
        Serial.print("T1: ");
        Serial.println(temperature1);
      }
      
      float humidity1 = dht1.getHumidity();
      if (isnan(humidity1)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity1 != lastHum1) {
          lastHum1 = humidity1;
          gw.send(msgHum1.set(humidity1, 1));
          Serial.print("H1: ");
          Serial.println(humidity1);
      }
    
    // DHT11 Sensor 2
      delay(dht2.getMinimumSamplingPeriod());
    
      float temperature2 = dht2.getTemperature();
      if (isnan(temperature2)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature2 != lastTemp2) {
        lastTemp2 = temperature2;
        if (!metric) {
          temperature2 = dht2.toFahrenheit(temperature2);
        }
        gw.send(msgTemp2.set(temperature2, 1));
        Serial.print("T2: ");
        Serial.println(temperature2);
      }
      
      float humidity2 = dht2.getHumidity();
      if (isnan(humidity2)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity2 != lastHum2) {
          lastHum2 = humidity2;
          gw.send(msgHum2.set(humidity2, 1));
          Serial.print("H2: ");
          Serial.println(humidity2);
      }
      
    //DHT11 Sensor 3 
      delay(dht3.getMinimumSamplingPeriod());
    
      float temperature3 = dht3.getTemperature();
      if (isnan(temperature3)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature3 != lastTemp3) {
        lastTemp3 = temperature3;
        if (!metric) {
          temperature3 = dht3.toFahrenheit(temperature3);
        }
        gw.send(msgTemp3.set(temperature3, 1));
        Serial.print("T3: ");
        Serial.println(temperature3);
      }
      
      float humidity3 = dht3.getHumidity();
      if (isnan(humidity3)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity3 != lastHum3) {
          lastHum3 = humidity3;
          gw.send(msgHum3.set(humidity3, 1));
          Serial.print("H3: ");
          Serial.println(humidity3);
      }
    
      gw.sleep(SLEEP_TIME); //sleep a bit
    }
    

    maybe someone has an idea?

    the next problem, when i unplug the power and replug it, the relay gets into the last status, i want the relay always off only when i give the order... in case of "off-plowering " it shall be off after replug...
    did i explained understandable??

    short: relay = off , order to switch on => relay on , cut off power and replug Relay => still off...

  • Login

  • Don't have an account? Register

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