Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. michlb1982
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by michlb1982

    • RE: DHT12 + 2Relay + 2Button - Combining Problem

      @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());
        }
      }
      
      posted in Development
      michlb1982
      michlb1982
    • RE: DHT12 + 2Relay + 2Button - Combining Problem

      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?

      posted in Development
      michlb1982
      michlb1982
    • RE: DHT12 + 2Relay + 2Button - Combining Problem

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

      posted in Development
      michlb1982
      michlb1982
    • RE: DHT12 + 2Relay + 2Button - Combining Problem

      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());
        }
      }
      
      posted in Development
      michlb1982
      michlb1982
    • RE: Mysensort mit DHT12 (i2C)

      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

      posted in Hardware
      michlb1982
      michlb1982
    • RE: DHT12 + 2Relay + 2Button - Combining Problem

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

      posted in Development
      michlb1982
      michlb1982
    • DHT12 + 2Relay + 2Button - Combining Problem

      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!

      posted in Development
      michlb1982
      michlb1982
    • RE: Mini Pro + DHT12 + NRF24L01+ SMD

      @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?

      posted in Hardware
      michlb1982
      michlb1982
    • RE: Mini Pro + DHT12 + NRF24L01+ SMD

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

      posted in Hardware
      michlb1982
      michlb1982
    • RE: Mini Pro + DHT12 + NRF24L01+ SMD

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

      posted in Hardware
      michlb1982
      michlb1982
    • RE: Mini Pro + DHT12 + NRF24L01+ SMD

      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'
      
      posted in Hardware
      michlb1982
      michlb1982
    • Mini Pro + DHT12 + NRF24L01+ SMD

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

      posted in Hardware
      michlb1982
      michlb1982
    • Mysensort mit DHT12 (i2C)

      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

      posted in Hardware
      michlb1982
      michlb1982
    • RE: 💬 Building a Raspberry Pi Gateway

      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

      posted in Announcements
      michlb1982
      michlb1982
    • RE: Magnetic field detection

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

      posted in Feature Requests
      michlb1982
      michlb1982
    • RE: Magnetic field detection

      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

      posted in Feature Requests
      michlb1982
      michlb1982
    • RE: Magnetic field detection

      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

      posted in Feature Requests
      michlb1982
      michlb1982
    • Compiling Problems since Update to 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

      posted in Troubleshooting
      michlb1982
      michlb1982
    • Magnetic field detection

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

      posted in Feature Requests
      michlb1982
      michlb1982
    • RE: 2 or more DHT11 - Sensors on one Arduino NANO MYSENSOR

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

      posted in Development
      michlb1982
      michlb1982
    • RE: 2 or more DHT11 - Sensors on one Arduino NANO MYSENSOR

      @Sparkman said:

      #include <SPI.h>
      #include <MySensor.h>
      #include <DHT.h>

      #define CHILD_ID1_HUM 0
      #define CHILD_ID1_TEMP 1
      #define CHILD_ID2_HUM 2
      #define CHILD_ID2_TEMP 3
      const int HUMIDITY_SENSOR1_DIGITAL_PIN = 8;
      const int HUMIDITY_SENSOR2_DIGITAL_PIN = 9;

      unsigned long SLEEP_TIME = 15000; // Sleep time between reads (in milliseconds)

      MySensor gw;
      DHT dht1;
      DHT dht2;
      float lastTemp1;
      float lastHum1;
      float lastTemp2;
      float lastHum2;
      boolean metric = true;
      MyMessage msgHum1(CHILD1_ID_HUM, V_HUM);
      MyMessage msgTemp1(CHILD1_ID_TEMP, V_TEMP);
      MyMessage msgHum2(CHILD2_ID_HUM, V_HUM);
      MyMessage msgTemp2(CHILD2_ID_TEMP, V_TEMP);

      void setup()
      {
      gw.begin();
      dht1.setup(HUMIDITY_SENSOR1_DIGITAL_PIN);
      dht2.setup(HUMIDITY_SENSOR2_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);

      metric = gw.getConfig().isMetric;
      }

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

      float temperature = dht1.getTemperature();
      if (isnan(temperature)) {
      Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp1) {
      lastTemp1 = temperature;
      if (!metric) {
      temperature = dht1.toFahrenheit(temperature);
      }
      gw.send(msgTemp1.set(temperature, 1));
      Serial.print("T1: ");
      Serial.println(temperature);
      }

      float humidity = dht1.getHumidity();
      if (isnan(humidity)) {
      Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum1) {
      lastHum1 = humidity;
      gw.send(msgHum1.set(humidity, 1));
      Serial.print("H1: ");
      Serial.println(humidity);
      }

      delay(dht2.getMinimumSamplingPeriod());

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

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

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

      thanks for the help, you messed up a little with the number and the names of the nodes but after 5 min i could compile it... now the test starts...

      posted in Development
      michlb1982
      michlb1982
    • RE: 2 or more DHT11 - Sensors on one Arduino NANO MYSENSOR

      hello
      well, i tried to do it by my self but, as i said, I'm a programming newbee...
      here my code

      #include <SPI.h>
      #include <MySensor.h>  
      #include <DHT.h>  
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      const int HUMIDITY_SENSOR_DIGITAL_PIN[] = {8, 7};
      #define NUMBER_OF_SENSORS 2
      unsigned long SLEEP_TIME = 15000; // Sleep time between reads (in milliseconds)
      
      MySensor gw;
      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[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
      }
      
      
      

      i found a relaycode and i thought that could work for the DHT11 too... ?!

      // Example sketch showing how to control physical relays. 
      // This example will remember relay state even after power failure.
      
      #include <MySensor.h>
      #include <SPI.h>
      
      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 0  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 1 // GPIO value to write to turn off attached relay
      
      MySensor gw;
      
      void setup()  
      {   
        // 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);
        }
      }
      
      
      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());
         } 
      }
      
      

      the problem i have, is that i don't know how to "call" one pin after the other to readout the data and send them each to the gateway....

      maybe you have an idea....

      thank you !

      posted in Development
      michlb1982
      michlb1982
    • 2 or more DHT11 - Sensors on one Arduino NANO MYSENSOR

      Hello I'm a newby with programming and arduino but i like the things i can do with mysensors and the fhem on my raspberry... so i want to use a Humidity-MYSENSOR but i want to plut 2 or more of the DHT11 on one sensor...
      i tried to create a code based on the humidity-mysensor code but i failed...
      maybe someone can help me?
      is it possible to use more than one dht11 on one arduino???

      thanks for help
      mike

      posted in Development
      michlb1982
      michlb1982
    • RE: Gateway *and* sensor node on same Arduino - is it possible ?

      Hello...
      got a question, did you crushed it? could you make it work a sensor-Gateway on one arduino?
      I'm asking because i want to use my ethernet - gateway with a DHT22 and 4 Relays and as said before as a ethernet gateway... (hope there are enought pins for my plan)...

      if yes, maybe you could write a tiny tutorial or something like that, because i'm not a programmer and just starting with arduino-stuff... i'm a little newbeeeeeee...

      so please mybe you could help me a little...
      thanks
      mike

      posted in Development
      michlb1982
      michlb1982