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. Moisture Sensor - Payload problem

Moisture Sensor - Payload problem

Scheduled Pinned Locked Moved Troubleshooting
7 Posts 2 Posters 2.3k Views 2 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.
  • vgaV Offline
    vgaV Offline
    vga
    wrote on last edited by vga
    #1

    Hi everyone,

    i want to use a Moisture-Sensor (YL69+YL39) to report the humidity-level (0-1023) to my serial-Gateway.
    All set-up well.
    My Serial-Gateway works fine, the Sensor-Node works also and is connected to the Gateway.
    Now, my problem is that the Sensor-Node doesn´t send the level data correctly, i think.

    The Sensor-Node should send the following Level:
    Humidity Level (0-1023): 19

    In the Serial Monitor from my Sensor-Node i always get this output, when a msg will be send:

    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
    

    And this is the Gateway Serial Monitor:

    0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    255;255;3;0;3;
    

    So to me, it looks like the msg has no content!?
    pl=0 and l=0 -> no data in the msg, doesn´t it?

    Here is my Sensor-Node Sketch:

    // MySensor Library hinzufügen
    #include <SPI.h>
    #include <MySensor.h> 
    
    #define CHILD_ID 0   // Id of the sensor child
    
    MySensor gw;
    
    //Definieren welche Sensor-ID die nachricht schickt 
    //und welcher Variablen-Typ übermittelt wird. (V_LEVEL ist in S_MOISTURE möglich)
    // Entsprechend der Sensor-Liste und Variablen-Liste
    MyMessage msg(CHILD_ID, V_LEVEL);
    int lastSoilValue = 0;
    
    // YL-39 + YL-69 humidity sensor
    byte humidity_sensor_pin = A1;
    byte humidity_sensor_vcc = 6;
    
    void setup() {
    
      // Start Gateway Kommunikation
      gw.begin();
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Soil Moisture Sensor", "1.0");     
      // Register all sensors to gw (they will be created as child devices)  
      gw.present(CHILD_ID, S_MOISTURE);
      
      // Init the humidity sensor board
      pinMode(humidity_sensor_vcc, OUTPUT);
      digitalWrite(humidity_sensor_vcc, LOW);
    
      // Setup Serial
    //while (!Serial);
    //delay(1000);
    //Serial.begin(9600);
    }
    
    int read_humidity_sensor() {
      digitalWrite(humidity_sensor_vcc, HIGH);
      delay(500);
      int value = analogRead(humidity_sensor_pin);
      digitalWrite(humidity_sensor_vcc, LOW);
      return 1023 - value;
    }
    
    void loop() {
      int soilValue = read_humidity_sensor();
      Serial.print("Humidity Level (0-1023): ");
      Serial.println(soilValue);
      delay(2000);
      if (soilValue != lastSoilValue) {
        Serial.println(soilValue);
        gw.send(msg.set(soilValue));  
        lastSoilValue = soilValue;
      }
    }
    

    So, can someone help my, finding the problem, why my Level-Value will not be transmitted?
    Thanks for help!

    AWIA 1 Reply Last reply
    0
    • vgaV vga

      Hi everyone,

      i want to use a Moisture-Sensor (YL69+YL39) to report the humidity-level (0-1023) to my serial-Gateway.
      All set-up well.
      My Serial-Gateway works fine, the Sensor-Node works also and is connected to the Gateway.
      Now, my problem is that the Sensor-Node doesn´t send the level data correctly, i think.

      The Sensor-Node should send the following Level:
      Humidity Level (0-1023): 19

      In the Serial Monitor from my Sensor-Node i always get this output, when a msg will be send:

      req id
      send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      

      And this is the Gateway Serial Monitor:

      0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
      255;255;3;0;3;
      

      So to me, it looks like the msg has no content!?
      pl=0 and l=0 -> no data in the msg, doesn´t it?

      Here is my Sensor-Node Sketch:

      // MySensor Library hinzufügen
      #include <SPI.h>
      #include <MySensor.h> 
      
      #define CHILD_ID 0   // Id of the sensor child
      
      MySensor gw;
      
      //Definieren welche Sensor-ID die nachricht schickt 
      //und welcher Variablen-Typ übermittelt wird. (V_LEVEL ist in S_MOISTURE möglich)
      // Entsprechend der Sensor-Liste und Variablen-Liste
      MyMessage msg(CHILD_ID, V_LEVEL);
      int lastSoilValue = 0;
      
      // YL-39 + YL-69 humidity sensor
      byte humidity_sensor_pin = A1;
      byte humidity_sensor_vcc = 6;
      
      void setup() {
      
        // Start Gateway Kommunikation
        gw.begin();
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Soil Moisture Sensor", "1.0");     
        // Register all sensors to gw (they will be created as child devices)  
        gw.present(CHILD_ID, S_MOISTURE);
        
        // Init the humidity sensor board
        pinMode(humidity_sensor_vcc, OUTPUT);
        digitalWrite(humidity_sensor_vcc, LOW);
      
        // Setup Serial
      //while (!Serial);
      //delay(1000);
      //Serial.begin(9600);
      }
      
      int read_humidity_sensor() {
        digitalWrite(humidity_sensor_vcc, HIGH);
        delay(500);
        int value = analogRead(humidity_sensor_pin);
        digitalWrite(humidity_sensor_vcc, LOW);
        return 1023 - value;
      }
      
      void loop() {
        int soilValue = read_humidity_sensor();
        Serial.print("Humidity Level (0-1023): ");
        Serial.println(soilValue);
        delay(2000);
        if (soilValue != lastSoilValue) {
          Serial.println(soilValue);
          gw.send(msg.set(soilValue));  
          lastSoilValue = soilValue;
        }
      }
      

      So, can someone help my, finding the problem, why my Level-Value will not be transmitted?
      Thanks for help!

      AWIA Offline
      AWIA Offline
      AWI
      Hero Member
      wrote on last edited by
      #2

      @vga It looks like your sensor is requesting an ID from the controller. As long as the ID is not received no message with content will be sent. Which controller are using? You can use a fixed node to test.

      1 Reply Last reply
      0
      • vgaV Offline
        vgaV Offline
        vga
        wrote on last edited by
        #3

        i´m a totally beginner with MySensors, so sorry for my questions:

        I have a FHEM-Controller working.
        But haven´t connected the Controller to the Gateway yet.
        I thought i can test the Communication between the Gateway and the Sensor-Node, without connect the Gateway to my Controller. Isn´t that possible?

        What do you mean with "fixed node"?

        AWIA 1 Reply Last reply
        0
        • vgaV vga

          i´m a totally beginner with MySensors, so sorry for my questions:

          I have a FHEM-Controller working.
          But haven´t connected the Controller to the Gateway yet.
          I thought i can test the Communication between the Gateway and the Sensor-Node, without connect the Gateway to my Controller. Isn´t that possible?

          What do you mean with "fixed node"?

          AWIA Offline
          AWIA Offline
          AWI
          Hero Member
          wrote on last edited by AWI
          #4

          @vga To indentify the node in the network a "Node Id" is needed. When you don't assign one yourself the sensor will ask the controller to issue one. As you have no controller connected it will never be issued and the node will keep asking. By assigning the node id yourself you will be able to use it without a controller attached. I modified your sketch to use a fixed node id (don't use 0 or 255)

          // MySensor Library hinzufügen
          #include <SPI.h>
          #include <MySensor.h> 
          
          #define CHILD_ID 0   // Id of the sensor child
          
          MySensor gw ;
          
          //Definieren welche Sensor-ID die nachricht schickt 
          //und welcher Variablen-Typ übermittelt wird. (V_LEVEL ist in S_MOISTURE möglich)
          // Entsprechend der Sensor-Liste und Variablen-Liste
          MyMessage msg(CHILD_ID, V_LEVEL);
          int lastSoilValue = 0;
          
          // YL-39 + YL-69 humidity sensor
          byte humidity_sensor_pin = A1;
          byte humidity_sensor_vcc = 6;
          
          void setup() {
          
            // Start Gateway Kommunikation
            gw.begin((NULL, 2);     // AWI: assign fixed node id 2  (use anything from 1..254);
            // Send the sketch version information to the gateway and Controller
            gw.sendSketchInfo("Soil Moisture Sensor", "1.0");     
            // Register all sensors to gw (they will be created as child devices)  
            gw.present(CHILD_ID, S_MOISTURE);
            
            // Init the humidity sensor board
            pinMode(humidity_sensor_vcc, OUTPUT);
            digitalWrite(humidity_sensor_vcc, LOW);
          
            // Setup Serial
          //while (!Serial);
          //delay(1000);
          //Serial.begin(9600);
          }
          
          int read_humidity_sensor() {
            digitalWrite(humidity_sensor_vcc, HIGH);
            delay(500);
            int value = analogRead(humidity_sensor_pin);
            digitalWrite(humidity_sensor_vcc, LOW);
            return 1023 - value;
          }
          
          void loop() {
            int soilValue = read_humidity_sensor();
            Serial.print("Humidity Level (0-1023): ");
            Serial.println(soilValue);
            delay(2000);
            if (soilValue != lastSoilValue) {
              Serial.println(soilValue);
              gw.send(msg.set(soilValue));  
              lastSoilValue = soilValue;
            }
          }
          1 Reply Last reply
          0
          • vgaV Offline
            vgaV Offline
            vga
            wrote on last edited by
            #5

            Thank you AWI,
            While compiling the modified sketch in Arduino App, i´m getting the following error:

            no matching function for call to 'MySensor::MySensor(NULL, int)'
            
            AWIA 1 Reply Last reply
            0
            • vgaV vga

              Thank you AWI,
              While compiling the modified sketch in Arduino App, i´m getting the following error:

              no matching function for call to 'MySensor::MySensor(NULL, int)'
              
              AWIA Offline
              AWIA Offline
              AWI
              Hero Member
              wrote on last edited by
              #6

              @vga oops, my mistake. I corrected the example :blush: (my excuse: I usually work in development branch). Let us know the results..

              1 Reply Last reply
              0
              • vgaV Offline
                vgaV Offline
                vga
                wrote on last edited by
                #7

                It is working! ;D ...thank you very much!
                Now i understand a little bit more with MySensors ;)

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


                24

                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