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. Controllers
  3. Home Assistant
  4. 2nd sensor in sketch not showing up in HA

2nd sensor in sketch not showing up in HA

Scheduled Pinned Locked Moved Home Assistant
5 Posts 4 Posters 68 Views 4 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.
  • M Offline
    M Offline
    mrhutchinsonmn
    wrote on last edited by mrhutchinsonmn
    #1

    I am trying to modify my working moisture sensor sketch to present 2 child Ids instead of one. Arduino serial monitor shows the data from both sensors and HA sees it but the 2nd sensor does not show up in unused entities. I am confident I am erring in my sketch somehow but not sure where.

    /*
      AnalogReadSerial
    
      Reads an analog input on pin 0, prints the result to the Serial Monitor.
      Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
      Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
    
      This example code is in the public domain.
    
      http://www.arduino.cc/en/Tutorial/AnalogReadSerial
    */
    
    // Enable debug prints
    // #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_RF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    #define CHILD_ID_A0 0
    #define CHILD_ID_A1 1
    #include <MySensors.h>
    MyMessage msg(CHILD_ID_A0, V_LEVEL);
    MyMessage msg2(CHILD_ID_A1, V_LEVEL);
    // the setup routine runs once when you press reset:
    void setup() {
      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
    }
    void presentation()
    {
      sendSketchInfo("Analog Soil Moisture Sensor", "1c.0");
      present(CHILD_ID_A0, S_MOISTURE);
      present(CHILD_ID_A1, S_MOISTURE);
    }
    // the loop routine runs over and over again forever:
    void loop() {
      // read the input on analog pin 0:
      int sensorValue = analogRead(A0);
      int sensorValueA1 = analogRead(A1);
      // print out the value you read:
      Serial.println(sensorValue);
      Serial.println(sensorValueA1);
      send(msg.set(sensorValue));
      send(msg.set(sensorValueA1));
      delay(10000);        // delay in between reads for stability
    }
    

    HA logs:

    2020-03-16 15:56:04 WARNING (MainThread) [mysensors.sensor] child_id 0 already exists in children of node 105, cannot add child
    2020-03-16 15:56:04 WARNING (MainThread) [mysensors.sensor] child_id 1 already exists in children of node 105, cannot add child
    
    electrikE BearWithBeardB 2 Replies Last reply
    0
    • M mrhutchinsonmn

      I am trying to modify my working moisture sensor sketch to present 2 child Ids instead of one. Arduino serial monitor shows the data from both sensors and HA sees it but the 2nd sensor does not show up in unused entities. I am confident I am erring in my sketch somehow but not sure where.

      /*
        AnalogReadSerial
      
        Reads an analog input on pin 0, prints the result to the Serial Monitor.
        Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
        Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
      
        This example code is in the public domain.
      
        http://www.arduino.cc/en/Tutorial/AnalogReadSerial
      */
      
      // Enable debug prints
      // #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      #define CHILD_ID_A0 0
      #define CHILD_ID_A1 1
      #include <MySensors.h>
      MyMessage msg(CHILD_ID_A0, V_LEVEL);
      MyMessage msg2(CHILD_ID_A1, V_LEVEL);
      // the setup routine runs once when you press reset:
      void setup() {
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
      }
      void presentation()
      {
        sendSketchInfo("Analog Soil Moisture Sensor", "1c.0");
        present(CHILD_ID_A0, S_MOISTURE);
        present(CHILD_ID_A1, S_MOISTURE);
      }
      // the loop routine runs over and over again forever:
      void loop() {
        // read the input on analog pin 0:
        int sensorValue = analogRead(A0);
        int sensorValueA1 = analogRead(A1);
        // print out the value you read:
        Serial.println(sensorValue);
        Serial.println(sensorValueA1);
        send(msg.set(sensorValue));
        send(msg.set(sensorValueA1));
        delay(10000);        // delay in between reads for stability
      }
      

      HA logs:

      2020-03-16 15:56:04 WARNING (MainThread) [mysensors.sensor] child_id 0 already exists in children of node 105, cannot add child
      2020-03-16 15:56:04 WARNING (MainThread) [mysensors.sensor] child_id 1 already exists in children of node 105, cannot add child
      
      electrikE Offline
      electrikE Offline
      electrik
      wrote on last edited by
      #2

      @mrhutchinsonmn I think the error indicates the child already exist, so you could try to change the node id, or modify the persistence file manually:
      https://forum.mysensors.org/topic/10901/manual-adjust-the-persistence-file-instead-of-adjust-the-node-s/3

      1 Reply Last reply
      0
      • M mrhutchinsonmn

        I am trying to modify my working moisture sensor sketch to present 2 child Ids instead of one. Arduino serial monitor shows the data from both sensors and HA sees it but the 2nd sensor does not show up in unused entities. I am confident I am erring in my sketch somehow but not sure where.

        /*
          AnalogReadSerial
        
          Reads an analog input on pin 0, prints the result to the Serial Monitor.
          Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
          Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
        
          This example code is in the public domain.
        
          http://www.arduino.cc/en/Tutorial/AnalogReadSerial
        */
        
        // Enable debug prints
        // #define MY_DEBUG
        
        // Enable and select radio type attached
        #define MY_RADIO_RF24
        //#define MY_RADIO_NRF5_ESB
        //#define MY_RADIO_RFM69
        //#define MY_RADIO_RFM95
        #define CHILD_ID_A0 0
        #define CHILD_ID_A1 1
        #include <MySensors.h>
        MyMessage msg(CHILD_ID_A0, V_LEVEL);
        MyMessage msg2(CHILD_ID_A1, V_LEVEL);
        // the setup routine runs once when you press reset:
        void setup() {
          // initialize serial communication at 9600 bits per second:
          Serial.begin(9600);
        }
        void presentation()
        {
          sendSketchInfo("Analog Soil Moisture Sensor", "1c.0");
          present(CHILD_ID_A0, S_MOISTURE);
          present(CHILD_ID_A1, S_MOISTURE);
        }
        // the loop routine runs over and over again forever:
        void loop() {
          // read the input on analog pin 0:
          int sensorValue = analogRead(A0);
          int sensorValueA1 = analogRead(A1);
          // print out the value you read:
          Serial.println(sensorValue);
          Serial.println(sensorValueA1);
          send(msg.set(sensorValue));
          send(msg.set(sensorValueA1));
          delay(10000);        // delay in between reads for stability
        }
        

        HA logs:

        2020-03-16 15:56:04 WARNING (MainThread) [mysensors.sensor] child_id 0 already exists in children of node 105, cannot add child
        2020-03-16 15:56:04 WARNING (MainThread) [mysensors.sensor] child_id 1 already exists in children of node 105, cannot add child
        
        BearWithBeardB Offline
        BearWithBeardB Offline
        BearWithBeard
        wrote on last edited by
        #3

        @mrhutchinsonmn said in 2nd sensor in sketch not showing up in HA:

        MyMessage msg(CHILD_ID_A0, V_LEVEL);
        MyMessage msg2(CHILD_ID_A1, V_LEVEL);
        [...]
        void loop() {
          [...]
          send(msg.set(sensorValue));
          send(msg.set(sensorValueA1));
           [...]
        }
        

        You are sending both sensor values with the same message, so they both get reported to child ID 0 and child ID 1 will never show up.

        Change the second send function from
        send(msg.set(sensorValueA1));
        to
        send(msg2.set(sensorValueA1));

        skywatchS M 2 Replies Last reply
        2
        • BearWithBeardB BearWithBeard

          @mrhutchinsonmn said in 2nd sensor in sketch not showing up in HA:

          MyMessage msg(CHILD_ID_A0, V_LEVEL);
          MyMessage msg2(CHILD_ID_A1, V_LEVEL);
          [...]
          void loop() {
            [...]
            send(msg.set(sensorValue));
            send(msg.set(sensorValueA1));
             [...]
          }
          

          You are sending both sensor values with the same message, so they both get reported to child ID 0 and child ID 1 will never show up.

          Change the second send function from
          send(msg.set(sensorValueA1));
          to
          send(msg2.set(sensorValueA1));

          skywatchS Offline
          skywatchS Offline
          skywatch
          wrote on last edited by
          #4

          @BearWithBeard You beat me to it by a minute! ;)

          1 Reply Last reply
          2
          • BearWithBeardB BearWithBeard

            @mrhutchinsonmn said in 2nd sensor in sketch not showing up in HA:

            MyMessage msg(CHILD_ID_A0, V_LEVEL);
            MyMessage msg2(CHILD_ID_A1, V_LEVEL);
            [...]
            void loop() {
              [...]
              send(msg.set(sensorValue));
              send(msg.set(sensorValueA1));
               [...]
            }
            

            You are sending both sensor values with the same message, so they both get reported to child ID 0 and child ID 1 will never show up.

            Change the second send function from
            send(msg.set(sensorValueA1));
            to
            send(msg2.set(sensorValueA1));

            M Offline
            M Offline
            mrhutchinsonmn
            wrote on last edited by
            #5

            @BearWithBeard said in 2nd sensor in sketch not showing up in HA:

            send(msg2.set(sensorValueA1));

            Yes, that was it!! Thank you!!

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


            32

            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