MySensor Node ID troubles

I am running Home Assistant OS on a RPi-4 and using the Open-MQTT add-on along with MySensors to create a network of sensors I pan to install throughout an 80 acre property. I like the idea of the “self-healing” network topology of MySensors, but am having issues getting serial communication between devices back to the server. To be a bit more specific, I gave a serial gateway installed on the Pi (Sensebender) and this appears to be reporting incoming serial messages to the Overview Dashboard as you can see in the attached image:


The issue is that I am trying to add in PassiveNodes that will simply relay incoming sensor data to the Sensebender and then to the HA server and I am not able to make this happen. In fact, even trying to setup a simple sensor on a NodeMCU (v1.0) microcontroller with NRF25 radio attached and data coming from an Adafruit BME680 sensor, I am not able to get the data to be accepted by the HA server. I get the following error in the log when I compile the sketch:

Logger: mysensors.sensor
Source: components/mysensors/gateway.py:195
First occurred: 2:05:50 AM (1425 occurrences)
Last logged: 10:08:28 AM

child_id 0 already exists in children of node 0, cannot add child
child_id 1 already exists in children of node 0, cannot add child
child_id 2 already exists in children of node 0, cannot add child

I have tried changing the Node_ID and the Child IDs, but none of this works.

I think I am struggling to understand what values I must change and maintain as unique and what values can be duplicated between sensors, nodes, and gateways.

Any help you can provie would be greatly apprecaited! Thanks.

I just attempted to create a passive node using the example sketch in Arduino under MySnesors and made only a couple of small modifciations. First, I changed the baud rate to 9600 so that it is below the 38400 of the sensebender (this seems to be recommended online elsewhere). Second, I changed the Node_ID to 15 since this was a number I have not used before and wanted to make sure it was not interfering with some stored memory of another node and its attached sensors. Third, I was getting an error about int() log 10 having an error in the random number generator at the bottom of the example sketch, so I changed it to simplify and only send values between 25 and 30 with no decimals.

Here is the error I get in HA core log:

Source: runner.py:189
First occurred: 2:05:57 AM (3465 occurrences)
Last logged: 10:56:21 AM

Not a valid message: too many values to unpack (expected 5)
Node 15 is unknown
Not a valid message: invalid literal for int() with base 10: 'TSF:MSG:SEND,0-0-50-15,s=255,c=3,t=19,pt=0,l=0,sg=0,ft=0,st=OK:0'
Not a valid message: invalid literal for int() with base 10: 'TSF:MSG:SEND,0-0-50-15,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0'
Not a valid message: invalid literal for int() with base 10: 'TSF:MSG:SEND,0-0-50-50,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:0'

And here is the full sketch copied from Arduino IDE

 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad <[email protected]>
 * Copyright (C) 2013-2019 Sensnology AB
 * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - tekka
 *
 * DESCRIPTION
 * Passive node example: This is a passive & independent reporting node
 *
 */

// Enable debug prints
#define MY_DEBUG

// Establish serial communication at the following boad rate below that of the sensebender
#define MY_BAUD_RATE 9600

// Enable passive mode
#define MY_PASSIVE_NODE

// Passive mode requires static node ID
#define MY_NODE_ID 15

// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95

#include <MySensors.h>

#define CHILD_ID 0   // Id of the sensor child

// Initialize general message
MyMessage msg(CHILD_ID, V_TEMP);

void setup()
{
}

void presentation()
{
	// Send the sketch version information to the gateway and controller
	sendSketchInfo("Passive node", "1.0");

	// Register all sensors to gw (they will be created as child devices)
	present(CHILD_ID, S_TEMP);
}

void loop()
{
	// generate some random data
	send(msg.set(25.0+random(0,5),0));
	sleep(2000);
}

It does not appear to be sleeping since I get a serial output with many correct values being reported in just a few seconds.

414170 ?TSF:MSG:SEND,15-15-255-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=OK:Passive node
416991 ?TSF:MSG:SEND,15-15-255-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
419801 ?TSF:MSG:SEND,15-15-255-0,s=0,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=OK:
422605 ?TSF:MSG:SEND,15-15-255-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:26
422681 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255
422741 TSF:TDI:TSL
422761 MCO:SLP:WUP=-2
422784 TSF:TRI:TSB
422811 ?TSF:MSG:SEND,15-15-255-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:29
422887 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255
422947 TSF:TDI:TSL
422967 MCO:SLP:WUP=-2
422990 TSF:TRI:TSB
423017 ?TSF:MSG:SEND,15-15-255-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:28
423093 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255
423153 TSF:TDI:TSL
423173 MCO:SLP:WUP=-2
423196 TSF:TRI:TSB
423223 ?TSF:MSG:SEND,15-15-255-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:25
423299 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255

That was only a few out of what appears to be hundreds of values coming in a couple of seconds followed by:

438830 MCO:SLP:WUP=-2
438853 TSF:TRI:TSB
438878 TSF:MSG:READ,0-50-15,s=255,c=3,t=19,pt=0,l=0,sg=0:
438941 ?TSF:MSG:SEND,15-15-255-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
439022 !MCO:PRO:RC=1
439044 TSF:MSG:READ,0-0-15,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
441841 ?TSF:MSG:SEND,15-15-255-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
444653 ?TSF:MSG:SEND,15-15-255-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:255
444733 !MCO:PRO:RC=1
444755 !MCO:PRO:RC=1
444777 !MCO:PRO:RC=1
444799 !MCO:PRO:RC=1
444821 !MCO:PRO:RC=1
444843 !MCO:PRO:RC=1

This is way over my head.

UPDATE:
I have been able to make some progress, or so I think. Here is what I have:

I have created two nodes, one repeater and one passive, each with a BMEX80 sensor on it and they are sending data to the HA instance. It is not clear whether the passive node with the BME280 is relaying data through the RepeaterNode (with the BME680) or sending it directly to the SenseBender Serial gateway installed on the HA machine, but that’s for another day.

The PassiveNode sketch is here:

 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad <[email protected]>
 * Copyright (C) 2013-2019 Sensnology AB
 * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - tekka
 *
 * DESCRIPTION
 * Passive node example: This is a passive & independent reporting node
 *
 */

// Enable debug prints
#define MY_DEBUG

// Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
#define MY_BAUD_RATE 9600

// Enable passive mode
#define MY_PASSIVE_NODE

// Passive mode requires static node ID
#define MY_NODE_ID 100

// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95

//For NodeMCU boards with radio and I2C devices
#define MY_RF24_CE_PIN 2  // GPIO2 = D4 pin

// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
//#define MY_RF24_PA_LEVEL RF24_PA_HIGH

#include <MySensors.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME280.h"
#include <RH_NRF24.h>
#include <EEPROM.h>
#include <ESP8266WiFi.h>

//#define CHILD_ID 10   // Id of the sensor child
#define CHILD_ID_TEMP 3
#define CHILD_ID_HUM 4
#define CHILD_ID_BARO 5

//create BME sensor
Adafruit_BME280 bme; // I2C

//create mysensors varibles, send as V_custom not as a JSON 
MyMessage temperatureMSG(CHILD_ID_TEMP, V_TEMP);
MyMessage humidityMSG(CHILD_ID_HUM, V_HUM);
MyMessage pressureMSG(CHILD_ID_BARO, V_PRESSURE);

void setup()
{
  
 Wire.begin();
 Serial.begin(9600); 
if (!bme.begin()) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
    }else{
      Serial.print("BME found");
      }
  
}

void presentation()
{
	// Send the sketch version information to the gateway and controller
	sendSketchInfo("PassiveNode BME280", "2.3.2");

	// Register all sensors to gw (they will be created as child devices)
	present(CHILD_ID_TEMP, S_TEMP);
  present(CHILD_ID_HUM, S_HUM);
  present(CHILD_ID_BARO, S_BARO);
}

void loop()
{
bme.takeForcedMeasurement();

  Serial.print("Temperature = ");
  Serial.print(bme.readTemperature() * 1.8 + 32);
  Serial.println(" *F");
  send(temperatureMSG.set((bme.readTemperature() * 1.8 + 32), 1));
  Serial.print("Pressure = ");
  Serial.print(bme.readPressure() / 3386);
  Serial.println(" in. Hg");
  send(pressureMSG.set((bme.readPressure() / 3386), 1));
  Serial.print("Humidity = ");
  Serial.print(bme.readHumidity());
  Serial.println(" %");
  send(humidityMSG.set(bme.readHumidity(), 1));
  Serial.println();

  delay(5000);
}

and you can see it is almostly completely taken from the example sketch provided in with the MySensors library. I needed to change the CE pin for the radio since I am using I2C and I changed the node_ID because I am still working to sort out what values must be changed, what values can be changed, and what values must not be changed. (If you have any help or direction on this, I’d be very grateful).

As for the RepeaterNode, here is the sketch:

//Code including rain gauge sensor and radio communication

// Enable debug prints to serial monitor
#define MY_DEBUG

// Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
#define MY_BAUD_RATE 9600

#define MY_NODE_ID 7
#define MY_PARENT_NODE_ID 0
#define MY_PARENT_NODE_IS_STATIC

// Enables and select radio type (if attached)
#define MY_RADIO_RF24
#define MY_RF24_CE_PIN 2  // GPIO2 = D4 pin

// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
#define MY_RF24_PA_LEVEL RF24_PA_HIGH

// Enabled repeater feature for this node
#define MY_REPEATER_FEATURE

#define TEMP_CHILD_ID 0
#define HUM_CHILD_ID 1
#define BARO_CHILD_ID 2
//#define CHILD_ID_DUST_PM3 3    //.3 um
//#define CHILD_ID_DUST_PM5 4    //.5 um
//#define CHILD_ID_DUST_PM10 5   //1.0 um
//#define CHILD_ID_DUST_PM25 6   //2.5 um
//#define CHILD_ID_DUST_PM50 7   //5.0 um
//#define CHILD_ID_DUST_PM100 8  //10.0 um

// Libraries
#include <MySensors.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
#include "Adafruit_PM25AQI.h"
#include <RH_NRF24.h>
#include <EEPROM.h>
#include <ESP8266WiFi.h>

//create BME sensor
Adafruit_BME680 bme;  // I2C

//create aerosol particle sensor
//Adafruit_PM25AQI aqi = Adafruit_PM25AQI();

//create mysensors varibles, send as V_custom not as a JSON
MyMessage temperatureMSG(TEMP_CHILD_ID, V_TEMP);
MyMessage humidityMSG(HUM_CHILD_ID, V_HUM);
MyMessage pressureMSG(BARO_CHILD_ID, V_PRESSURE);
//MyMessage msgDust3(CHILD_ID_DUST_PM3, V_LEVEL);
//MyMessage msgDust3b(CHILD_ID_DUST_PM3, V_UNIT_PREFIX);
//MyMessage msgDust5(CHILD_ID_DUST_PM5, V_LEVEL);
//MyMessage msgDust5b(CHILD_ID_DUST_PM5, V_UNIT_PREFIX);
//MyMessage msgDust10(CHILD_ID_DUST_PM10, V_LEVEL);
//MyMessage msgDust10b(CHILD_ID_DUST_PM10, V_UNIT_PREFIX);
//MyMessage msgDust25(CHILD_ID_DUST_PM25, V_LEVEL);
//MyMessage msgDust25b(CHILD_ID_DUST_PM25, V_UNIT_PREFIX);
//MyMessage msgDust50(CHILD_ID_DUST_PM50, V_LEVEL);
//MyMessage msgDust50b(CHILD_ID_DUST_PM50, V_UNIT_PREFIX);
//MyMessage msgDust100(CHILD_ID_DUST_PM100, V_LEVEL);
//MyMessage msgDust100b(CHILD_ID_DUST_PM100, V_UNIT_PREFIX);


void setup() {
  Wire.begin();
  Serial.begin(9600);

  // // Setup for the air particle sensor
  // while (!aqi.begin_I2C()) {  // connect to the sensor over I2C
  //   Serial.println("Could not find PM 2.5 sensor!");
  //   wait(1000);
  // }

  // Setup for the BME280 sensor
  while (!bme.begin()) {
    Serial.println("Could not find a valid BME680 sensor, check wiring!");
    wait(1000);
  }

  // Set up oversampling and filter initialization
  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150);  // 320*C for 150 ms
}


void presentation() {
  sendSketchInfo("Radio BME Node", "2.3.2");

  /*present(CHILD_ID_DUST_PM3, S_DUST);
  send(msgDust3b.set("um/.1L"));
  present(CHILD_ID_DUST_PM5, S_DUST);
  send(msgDust5b.set("um/.1L"));
  present(CHILD_ID_DUST_PM10, S_DUST);
  send(msgDust10b.set("um/.1L"));
  present(CHILD_ID_DUST_PM25, S_DUST);
  send(msgDust25b.set("um/.1L"));
  present(CHILD_ID_DUST_PM50, S_DUST);
  send(msgDust50b.set("um/.1L"));
  present(CHILD_ID_DUST_PM100, S_DUST);
  send(msgDust100b.set("um/.1L"));*/
  //present(TEMP_CHILD_ID, S_TEMP);
  //present(HUM_CHILD_ID, S_HUM);
  //present(BARO_CHILD_ID, S_BARO);
}


void loop() {
  // // check connection to the sensor over I2C
  // if (!aqi.begin_I2C()) {  
  //   Serial.println("Could not find PM 2.5 sensor!");
  //   wait(1000);
  //   return;
  // }

  if (!bme.begin()) {
    Serial.println("Could not find a valid BME680 sensor, check wiring!");
    wait(1000);
    return;
  }

  bme.performReading();

  Serial.print("Temperature = ");
  Serial.print(bme.temperature);
  Serial.println(" *C");
  send(temperatureMSG.set((bme.temperature), 1));
  Serial.print("Pressure = ");
  Serial.print(float(bme.pressure) / 3386.0);
  Serial.println(" in. Hg");
  send(pressureMSG.set((float(bme.pressure) / 3386.0), 2));
  Serial.print("Humidity = ");
  Serial.print(bme.humidity);
  Serial.println(" %");
  send(humidityMSG.set(bme.humidity, 1));
  Serial.println();
  delay(5000);
}

As you can see, the two sketches are very similar, but this one has some lines commented out that will ultimately setup an I2C PM25 aerosol particle sensor (Adafruit version).

For me, the questions that remain are as follows:

  1. What parameters can and/or need to be changed for both MQTT gateways AND serial nodes? There seems to be some issue with the ways I have either named or numbered thse devices which is not allowing HA to add them when each microcontroller is up and running. For example, I have 4 MQTT gateways, but I am told they will all have a default node_ID of 0, does this mean that they cannot also serve as a radio serial repeater node and forward other sensor data?
  2. Since I have a sensebender serial gateway installed on my HA instance (on RPi-4) as the OS installed, how do I add the sensor entities that are coming in over serial? Can I do this in the MySensors integration or do I need a complimentary add-on such as Node-Red?
  3. Perhaps these relate to the questions above, but here are the three error codes I am currently getting in HA under System/Logs//Home Assistant Core:
Logger: mysensors.sensor
Source: components/mysensors/gateway.py:195
First occurred: 9:51:23 AM (297 occurrences)
Last logged: 10:05:40 AM

child_id 7 already exists in children of node 0, cannot add child
child_id 8 already exists in children of node 0, cannot add child
child_id 0 already exists in children of node 0, cannot add child
child_id 1 already exists in children of node 0, cannot add child
child_id 2 already exists in children of node 0, cannot add child
Logger: mysensors.message
Source: runner.py:189
First occurred: 9:50:36 AM (666 occurrences)
Last logged: 10:05:48 AM

Error decoding message from gateway, bad data received: 0;255;3;0;9;100;4;1;0;1;43.4
Error decoding message from gateway, bad data received: 0;255;3;0;9;7;1;1;0;1;49.1
Error decoding message from gateway, bad data received: 0;255;3;0;9;100;4;1;0;1;43.3
Error decoding message from gateway, bad data received: 0;255;3;0;9;7;2;1;0;4;21.49
Error decoding message from gateway, bad data received: 0;255;3;0;9;7;1;1;0;1;49.2
Logger: mysensors
Source: runner.py:189
First occurred: 9:50:30 AM (694 occurrences)
Last logged: 10:05:48 AM

Not a valid message: too many values to unpack (expected 5)
Child 2 is unknown
Child 5 is unknown
Child 4 is unknown
Child 3 is unknown

Any thoughts about what might be causing them would be appreciated.

I’ll keep looking into these things on my own and post updates as I have them, but you may already know the fix. Post if you’d like. Thanks!

UPDATE: I have been able to sort out a couple of things here and this clearly seems to be more of my own documentation than any sort of actual forum, but nonetheless it is allowing me to get my thoughts out and document my progress.

I would gladdly accept any thoguhts or feedback you have, but will continue to work toward resolution on my own too.

I am now seeing the data from one of the two radio nodes, the PassiveNode with BME280, reported to my HA dashboard. It took several days for all three of the entities (temperature, humidity, and pressure) to appear, but they are there now and appear to be updating data when the values change, which is the method they are supposed to work, I think.

I just plugged the RepeaterNode in again and can see that it is sending data to the Sensebender, like before, and it is still producing the same error codes.

Source: components/mysensors/gateway.py:195
First occurred: 12:07:58 AM (10725 occurrences)
Last logged: 8:57:25 AM

child_id 7 already exists in children of node 0, cannot add child
child_id 8 already exists in children of node 0, cannot add child
child_id 0 already exists in children of node 0, cannot add child
child_id 1 already exists in children of node 0, cannot add child
child_id 2 already exists in children of node 0, cannot add child

I’m wondering now if I need to keep better records of the child ID numbers I assign to my devises? In other words, does each entity that is produced from a node sensor need to have a different child ID across all sensors that attach to the same gateway? Since I only have one radio gateway, the Sensebender, maybe all of my other radio sensors and their respective entities must have unique child IDs?

Another question I am pondering is whether there is a concise list of node and child IDs that can be generated from HA? In otherwords, can HA produce a network topology map that will provide all of that data so that I can check it to verify the assignment of new Node or Child IDs?

I’m going to play a bit with Node and Child IDs now and see what I can come up with.