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

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. [Solved] Manually setting node-id does not work

[Solved] Manually setting node-id does not work

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

    Ok great!

    One more thing: I manually define Node ID´s like this:

    #define MY_NODE_ID 1
    

    But my serial gate way always receives ID 3 for this Node! Any idea why ??

    0;255;3;0;9;Sending message on topic: mygateway1-out/3/7/1/0/38
    

    still learning...

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #2

      That sounds strange.. please post the log from your node.

      (I'm moving this to a separate topic)

      1 Reply Last reply
      0
      • siodS Offline
        siodS Offline
        siod
        wrote on last edited by siod
        #3

        This is my Serial Monitor output of my MQTT Gateway:

        0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
        0;255;3;0;9;TSM:INIT
        0;255;3;0;9;TSM:RADIO:OK
        0;255;3;0;9;TSM:GW MODE
        0;255;3;0;9;TSM:READY
        IP: 192.168.1.51
        0;255;3;0;9;No registration required
        0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
        IP: 192.168.1.51
        0;255;3;0;9;Attempting MQTT connection...
        0;255;3;0;9;MQTT connected
        0;255;3;0;9;TSP:MSG:READ 3-3-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
        0;255;3;0;9;TSP:MSG:BC
        0;255;3;0;9;TSP:MSG:FPAR REQ (sender=3)
        0;255;3;0;9;TSP:CHKUPL:OK
        0;255;3;0;9;TSP:MSG:GWL OK
        0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=ok:0
        0;255;3;0;9;TSP:MSG:READ 3-3-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
        0;255;3;0;9;TSP:MSG:BC
        0;255;3;0;9;TSP:MSG:FPAR REQ (sender=3)
        0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
        0;255;3;0;9;TSP:MSG:GWL OK
        0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=ok:0
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=24,pt=1,l=1,sg=0:1
        0;255;3;0;9;TSP:MSG:PINGED (ID=3, hops=1)
        0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=ok:1
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
        0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=0,t=17,pt=0,l=5,sg=0:2.0.0
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/0/0/17
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/3/0/6
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=11,pt=0,l=24,sg=0:Schlafzimmer Messstation
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/3/0/11
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=12,pt=0,l=3,sg=0:2.0
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/3/0/12
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=1,c=0,t=0,pt=0,l=0,sg=0:
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/1/0/0/0
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=2,c=0,t=0,pt=0,l=0,sg=0:
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/2/0/0/0
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=3,c=0,t=7,pt=0,l=0,sg=0:
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/3/0/0/7
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=4,c=0,t=6,pt=0,l=0,sg=0:
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/4/0/0/6
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=7,c=0,t=38,pt=0,l=0,sg=0:
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/7/0/0/38
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=26,pt=1,l=1,sg=0:2
        0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=ok:1
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=0,pt=1,l=1,sg=0:102
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/3/0/0
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=7,c=1,t=38,pt=2,l=2,sg=0:102
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/7/1/0/38
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=1,c=1,t=16,pt=2,l=2,sg=0:1
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/1/1/0/16
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=2,c=1,t=16,pt=2,l=2,sg=0:1
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/2/1/0/16
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=4,c=1,t=0,pt=7,l=5,sg=0:24.0
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/4/1/0/0
        0;255;3;0;9;TSP:MSG:READ 3-3-0 s=3,c=1,t=1,pt=7,l=5,sg=0:60.7
        0;255;3;0;9;Sending message on topic: mygateway1-out/3/3/1/0/1
        

        And this is my Node´s code:

        // Sensor Node Schlafzimmer mit HTU21D Temp/Hum Sensor, Fensterkontakte an Interrupt PINS Digital 5&6. Sleep Time 15 Minutwn, wake up wenn Fenster geöffnet/geschlossen wird.
        #define MY_RADIO_NRF24 //MySensor Library auf NRF24 Funkmodul einstellen, muss vor MySensor.h Initialisierung geschehen
        
        #include <MySensors.h>
        #include <SPI.h>
        
        // Define Node ID
        #define MY_NODE_ID 1
        
        //Batterysensor
        int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
        int oldBatteryPcnt = 0;
        #define CHILD_ID_BATT 7
        
        //Kontaktschalter
        //#include <Bounce2.h>
        #define CHILD1_ID 1 // Kontaktschalter 1
        #define CHILD2_ID 2 // Kontaktschalter 2
        #define BUTTON1_PIN  5  // Kontaktschalter 1
        #define BUTTON2_PIN  6  // Kontaktschalter 2
        int oldValueReed1=-1;
        int oldValueReed2=-1;
        
        //Tempsensor
        #include <SparkFunHTU21D.h>
        #include <Wire.h>
        #define CHILD_ID_HUM 3
        #define CHILD_ID_TEMP 4
        unsigned long SLEEP_TIME = 900000; // Sleep time between reads (in milliseconds)
        
        //tempsensor
        HTU21D myHumidity;
        float lastTemp;
        float lastHum;
        //boolean metric = true; 
        
        //Messages
        //Battery
        MyMessage msgbatt(CHILD_ID_BATT,V_VOLTAGE);
        // Kontaktschalter
        MyMessage msgReed1(CHILD1_ID,V_TRIPPED); // Kontaktschalter 1
        MyMessage msgReed2(CHILD2_ID,V_TRIPPED); // Kontaktschalter 2
        //TempMessage
        MyMessage msgHum(CHILD_ID_HUM, V_HUM);
        MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
        
        //Presentation; present sensors to gateway!
        void presentation(){
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo("Schlafzimmer Messstation", "2.0");
            
          // Register binary input sensor to gw (they will be created as child devices)
          // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
          // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
          present(CHILD1_ID, S_DOOR); 
          present(CHILD2_ID, S_DOOR); 
            
          //Tempsensor
          present(CHILD_ID_HUM, S_HUM);
          present(CHILD_ID_TEMP, S_TEMP); 
          //metric = getConfig().isMetric;
        
          //Battery
          present(CHILD_ID_BATT,V_VOLTAGE);
        }
        
        //Setup
        void setup()  
        {  
          //Serial.begin(9600);
          Serial.println("Hello!");
          //Batterysensor
             // use the 1.1 V internal reference
        #if defined(__AVR_ATmega2560__)
           analogReference(INTERNAL1V1);
        #else
           analogReference(INTERNAL);
        #endif
        
        //Tempsensor
          Serial.println("Setting up TempSensor...");
          myHumidity.begin();
          Serial.println("...done!");
        
        // Setup Kontaktschalter 1
          pinMode(BUTTON1_PIN,INPUT);
            // Activate internal pull-up
          digitalWrite(BUTTON1_PIN,HIGH);
        // Setup Kontaktschalter 2
          pinMode(BUTTON2_PIN,INPUT);
          // Activate internal pull-up
          digitalWrite(BUTTON2_PIN,HIGH);
        }
        
        //Starte den Loop
        void loop() 
        {
          //Batterysensor
          // get the battery Voltage
          delay(1000);
           int sensorValue = analogRead(BATTERY_SENSE_PIN);
           #ifdef DEBUG
           #endif
           
           // 1M, 470K divider across battery and using internal ADC ref of 1.1V
           // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
           // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
           // 3.44/1023 = Volts per bit = 0.003363075
           float batteryV  = sensorValue * 0.003363075;
           int batteryPcnt = sensorValue / 10;
        
           #ifdef DEBUG
           Serial.print("Battery Voltage: ");
           Serial.print(batteryV);
           Serial.println(" V");
        
           Serial.print("Battery percent: ");
           Serial.print(batteryPcnt);
           Serial.println(" %");
           #endif
        
           if (oldBatteryPcnt != batteryPcnt) {
             // Power up radio after sleep
             sendBatteryLevel(batteryPcnt);
             send(msgbatt.set(batteryPcnt));
             oldBatteryPcnt = batteryPcnt;
           }
           
          //Kontakstschalter 1
           // Short delay to allow buttons to properly settle
          sleep(10);
          // Get the update value
          int valueReed1 = digitalRead(BUTTON1_PIN);
         
          if (valueReed1 != oldValueReed1) {
             // Send in the new value
             send(msgReed1.set(valueReed1==HIGH ? 1 : 0));
             Serial.println("Button 1 geschaltet");
             oldValueReed1 = valueReed1;
          }
          //Kontakstschalter 2
          // Get the update value
          int valueReed2 = digitalRead(BUTTON2_PIN);
         
          if (valueReed2 != oldValueReed2) {
             // Send in the new value
             send(msgReed2.set(valueReed2==HIGH ? 1 : 0));
             Serial.println("Button 2 geschaltet");
             oldValueReed2 = valueReed2;
          }
         
         //Tempsensor
        Serial.println("Starte Messung...");
          
            float temp = myHumidity.readTemperature();
        
          if (isnan(temp)) {
              Serial.println("Failed reading temperature from DHT");
          } else if (temp != lastTemp) {
            lastTemp = temp;
            send(msgTemp.set(temp, 1));
            Serial.print("T: ");
            Serial.println(temp);
          }
          
         float humd = myHumidity.readHumidity();
          if (isnan(humd)) {
              Serial.println("Failed reading humidity from DHT");
          } else if (humd != lastHum) {
              lastHum = humd;
              send(msgHum.set(humd, 1));
              Serial.print("H: ");
              Serial.println(humd);
          }
        
         Serial.println("Sleep...");
         sleep(BUTTON1_PIN - 2, CHANGE, BUTTON2_PIN - 2, CHANGE, SLEEP_TIME); //sleep a bit 
          
        } 
        
        

        I have only this one Node powered right now...

        Using MySensors Library ver 2.0 on Gateway and Node

        still learning...

        tekkaT 1 Reply Last reply
        0
        • siodS siod

          This is my Serial Monitor output of my MQTT Gateway:

          0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
          0;255;3;0;9;TSM:INIT
          0;255;3;0;9;TSM:RADIO:OK
          0;255;3;0;9;TSM:GW MODE
          0;255;3;0;9;TSM:READY
          IP: 192.168.1.51
          0;255;3;0;9;No registration required
          0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
          IP: 192.168.1.51
          0;255;3;0;9;Attempting MQTT connection...
          0;255;3;0;9;MQTT connected
          0;255;3;0;9;TSP:MSG:READ 3-3-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
          0;255;3;0;9;TSP:MSG:BC
          0;255;3;0;9;TSP:MSG:FPAR REQ (sender=3)
          0;255;3;0;9;TSP:CHKUPL:OK
          0;255;3;0;9;TSP:MSG:GWL OK
          0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=ok:0
          0;255;3;0;9;TSP:MSG:READ 3-3-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
          0;255;3;0;9;TSP:MSG:BC
          0;255;3;0;9;TSP:MSG:FPAR REQ (sender=3)
          0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
          0;255;3;0;9;TSP:MSG:GWL OK
          0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=ok:0
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=24,pt=1,l=1,sg=0:1
          0;255;3;0;9;TSP:MSG:PINGED (ID=3, hops=1)
          0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=ok:1
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
          0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=0,t=17,pt=0,l=5,sg=0:2.0.0
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/0/0/17
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/3/0/6
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=11,pt=0,l=24,sg=0:Schlafzimmer Messstation
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/3/0/11
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=12,pt=0,l=3,sg=0:2.0
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/3/0/12
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=1,c=0,t=0,pt=0,l=0,sg=0:
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/1/0/0/0
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=2,c=0,t=0,pt=0,l=0,sg=0:
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/2/0/0/0
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=3,c=0,t=7,pt=0,l=0,sg=0:
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/3/0/0/7
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=4,c=0,t=6,pt=0,l=0,sg=0:
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/4/0/0/6
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=7,c=0,t=38,pt=0,l=0,sg=0:
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/7/0/0/38
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=26,pt=1,l=1,sg=0:2
          0;255;3;0;9;TSP:MSG:SEND 0-0-3-3 s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=ok:1
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=255,c=3,t=0,pt=1,l=1,sg=0:102
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/255/3/0/0
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=7,c=1,t=38,pt=2,l=2,sg=0:102
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/7/1/0/38
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=1,c=1,t=16,pt=2,l=2,sg=0:1
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/1/1/0/16
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=2,c=1,t=16,pt=2,l=2,sg=0:1
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/2/1/0/16
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=4,c=1,t=0,pt=7,l=5,sg=0:24.0
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/4/1/0/0
          0;255;3;0;9;TSP:MSG:READ 3-3-0 s=3,c=1,t=1,pt=7,l=5,sg=0:60.7
          0;255;3;0;9;Sending message on topic: mygateway1-out/3/3/1/0/1
          

          And this is my Node´s code:

          // Sensor Node Schlafzimmer mit HTU21D Temp/Hum Sensor, Fensterkontakte an Interrupt PINS Digital 5&6. Sleep Time 15 Minutwn, wake up wenn Fenster geöffnet/geschlossen wird.
          #define MY_RADIO_NRF24 //MySensor Library auf NRF24 Funkmodul einstellen, muss vor MySensor.h Initialisierung geschehen
          
          #include <MySensors.h>
          #include <SPI.h>
          
          // Define Node ID
          #define MY_NODE_ID 1
          
          //Batterysensor
          int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
          int oldBatteryPcnt = 0;
          #define CHILD_ID_BATT 7
          
          //Kontaktschalter
          //#include <Bounce2.h>
          #define CHILD1_ID 1 // Kontaktschalter 1
          #define CHILD2_ID 2 // Kontaktschalter 2
          #define BUTTON1_PIN  5  // Kontaktschalter 1
          #define BUTTON2_PIN  6  // Kontaktschalter 2
          int oldValueReed1=-1;
          int oldValueReed2=-1;
          
          //Tempsensor
          #include <SparkFunHTU21D.h>
          #include <Wire.h>
          #define CHILD_ID_HUM 3
          #define CHILD_ID_TEMP 4
          unsigned long SLEEP_TIME = 900000; // Sleep time between reads (in milliseconds)
          
          //tempsensor
          HTU21D myHumidity;
          float lastTemp;
          float lastHum;
          //boolean metric = true; 
          
          //Messages
          //Battery
          MyMessage msgbatt(CHILD_ID_BATT,V_VOLTAGE);
          // Kontaktschalter
          MyMessage msgReed1(CHILD1_ID,V_TRIPPED); // Kontaktschalter 1
          MyMessage msgReed2(CHILD2_ID,V_TRIPPED); // Kontaktschalter 2
          //TempMessage
          MyMessage msgHum(CHILD_ID_HUM, V_HUM);
          MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
          
          //Presentation; present sensors to gateway!
          void presentation(){
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo("Schlafzimmer Messstation", "2.0");
              
            // Register binary input sensor to gw (they will be created as child devices)
            // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
            // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
            present(CHILD1_ID, S_DOOR); 
            present(CHILD2_ID, S_DOOR); 
              
            //Tempsensor
            present(CHILD_ID_HUM, S_HUM);
            present(CHILD_ID_TEMP, S_TEMP); 
            //metric = getConfig().isMetric;
          
            //Battery
            present(CHILD_ID_BATT,V_VOLTAGE);
          }
          
          //Setup
          void setup()  
          {  
            //Serial.begin(9600);
            Serial.println("Hello!");
            //Batterysensor
               // use the 1.1 V internal reference
          #if defined(__AVR_ATmega2560__)
             analogReference(INTERNAL1V1);
          #else
             analogReference(INTERNAL);
          #endif
          
          //Tempsensor
            Serial.println("Setting up TempSensor...");
            myHumidity.begin();
            Serial.println("...done!");
          
          // Setup Kontaktschalter 1
            pinMode(BUTTON1_PIN,INPUT);
              // Activate internal pull-up
            digitalWrite(BUTTON1_PIN,HIGH);
          // Setup Kontaktschalter 2
            pinMode(BUTTON2_PIN,INPUT);
            // Activate internal pull-up
            digitalWrite(BUTTON2_PIN,HIGH);
          }
          
          //Starte den Loop
          void loop() 
          {
            //Batterysensor
            // get the battery Voltage
            delay(1000);
             int sensorValue = analogRead(BATTERY_SENSE_PIN);
             #ifdef DEBUG
             #endif
             
             // 1M, 470K divider across battery and using internal ADC ref of 1.1V
             // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
             // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
             // 3.44/1023 = Volts per bit = 0.003363075
             float batteryV  = sensorValue * 0.003363075;
             int batteryPcnt = sensorValue / 10;
          
             #ifdef DEBUG
             Serial.print("Battery Voltage: ");
             Serial.print(batteryV);
             Serial.println(" V");
          
             Serial.print("Battery percent: ");
             Serial.print(batteryPcnt);
             Serial.println(" %");
             #endif
          
             if (oldBatteryPcnt != batteryPcnt) {
               // Power up radio after sleep
               sendBatteryLevel(batteryPcnt);
               send(msgbatt.set(batteryPcnt));
               oldBatteryPcnt = batteryPcnt;
             }
             
            //Kontakstschalter 1
             // Short delay to allow buttons to properly settle
            sleep(10);
            // Get the update value
            int valueReed1 = digitalRead(BUTTON1_PIN);
           
            if (valueReed1 != oldValueReed1) {
               // Send in the new value
               send(msgReed1.set(valueReed1==HIGH ? 1 : 0));
               Serial.println("Button 1 geschaltet");
               oldValueReed1 = valueReed1;
            }
            //Kontakstschalter 2
            // Get the update value
            int valueReed2 = digitalRead(BUTTON2_PIN);
           
            if (valueReed2 != oldValueReed2) {
               // Send in the new value
               send(msgReed2.set(valueReed2==HIGH ? 1 : 0));
               Serial.println("Button 2 geschaltet");
               oldValueReed2 = valueReed2;
            }
           
           //Tempsensor
          Serial.println("Starte Messung...");
            
              float temp = myHumidity.readTemperature();
          
            if (isnan(temp)) {
                Serial.println("Failed reading temperature from DHT");
            } else if (temp != lastTemp) {
              lastTemp = temp;
              send(msgTemp.set(temp, 1));
              Serial.print("T: ");
              Serial.println(temp);
            }
            
           float humd = myHumidity.readHumidity();
            if (isnan(humd)) {
                Serial.println("Failed reading humidity from DHT");
            } else if (humd != lastHum) {
                lastHum = humd;
                send(msgHum.set(humd, 1));
                Serial.print("H: ");
                Serial.println(humd);
            }
          
           Serial.println("Sleep...");
           sleep(BUTTON1_PIN - 2, CHANGE, BUTTON2_PIN - 2, CHANGE, SLEEP_TIME); //sleep a bit 
            
          } 
          
          

          I have only this one Node powered right now...

          Using MySensors Library ver 2.0 on Gateway and Node

          tekkaT Offline
          tekkaT Offline
          tekka
          Admin
          wrote on last edited by tekka
          #4

          @siod you have to set

          #define MY_NODE_ID 1
          

          before

          #include <MySensors.h>
          

          That's it :)

          siodS 1 Reply Last reply
          1
          • tekkaT tekka

            @siod you have to set

            #define MY_NODE_ID 1
            

            before

            #include <MySensors.h>
            

            That's it :)

            siodS Offline
            siodS Offline
            siod
            wrote on last edited by
            #5

            @tekka said:

            That's it :)

            Nothing more to add, but Thank you! :bouquet:

            still learning...

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


            16

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


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

            • Don't have an account? Register

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