<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Duplicate Child ID 0]]></title><description><![CDATA[<p dir="auto">Im hoping there is a simple fix, ive gone through the forum for over a week and cant believe no-one else has experienced the same issue.<br />
I have multiple sensors on a node that all report as Child ID 0, not what i'd like. We are supposed to have different child id for each sensor.<br />
There are different types of sensors (so topics are different) so the readings go through MQTT ok and even read and sent by openhab ok, but i know its not how its meant to be.</p>
<p dir="auto">This is from serial monitor (with added sensor type comment)<br />
TSP:MSG:SEND 9-9-0-0 s=0,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=ok:1 SWITCHES<br />
TSP:MSG:SEND 9-9-0-0 s=1,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=ok:1 SWITCHES<br />
TSP:MSG:SEND 9-9-0-0 s=2,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=ok:1 SWITCHES<br />
TSP:MSG:SEND 9-9-0-0 s=3,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=ok:1 SWITCHES<br />
TSP:MSG:SEND 9-9-0-0 s=4,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=ok:1 SWITCHES</p>
<p dir="auto">TSP:MSG:SEND 9-9-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:18.4 DALLAS<br />
TSP:MSG:SEND 9-9-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:18.2 DALLAS</p>
<p dir="auto">TSP:MSG:SEND 9-9-0-0 s=10,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=ok:64.7 DHT HUMID<br />
TSP:MSG:SEND 9-9-0-0 s=11,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:21.5 DHT TEMP</p>
<p dir="auto">TSP:MSG:SEND 9-9-0-0 s=40,c=0,t=16,pt=0,l=0,sg=0,ft=0,st=ok: LIGHT LEVEL<br />
TSP:MSG:SEND 9-9-0-0 s=45,c=0,t=16,pt=0,l=0,sg=0,ft=0,st=ok: UV FLAME LIGHT<br />
TSP:MSG:SEND 9-9-0-0 s=50,c=0,t=13,pt=0,l=0,sg=0,ft=0,st=ok: POWER WATT</p>
<p dir="auto">TSP:MSG:SEND 9-9-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok: RELAYS x8<br />
TSP:MSG:SEND 9-9-0-0 s=2,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:<br />
TSP:MSG:SEND 9-9-0-0 s=3,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:<br />
TSP:MSG:SEND 9-9-0-0 s=4,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:<br />
TSP:MSG:SEND 9-9-0-0 s=5,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:<br />
TSP:MSG:SEND 9-9-0-0 s=6,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:<br />
TSP:MSG:SEND 9-9-0-0 s=7,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:<br />
TSP:MSG:SEND 9-9-0-0 s=8,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:</p>
<p dir="auto">As you can see, for example there are duplicates of s=0, s-1 etc<br />
I have used sketches that allow multiple relays/dallas/swicthes and the first child id of each set of sensors is 0, so i have many id 0, 1, 2, 3 etc as its seems the child id is being auto generated.<br />
I think its something to do with these lines but i have changed i=0 or sensors=0 to say =60 and when i upload child id 60 isnt showing in serial monitor.</p>
<p dir="auto">for (int sensor=1, pin=RELAY_1; sensor&lt;=NUMBER_OF_RELAYS;sensor++, pin++) {<br />
for (int i=0; i&lt;numSensors &amp;&amp; i&lt;MAX_ATTACHED_DS18B20; i++) {<br />
for (int i = 0; i &lt; NUMBER_OF_SWITCHES; i++)</p>
<p dir="auto">Anyone have any ideas?</p>
]]></description><link>https://forum.mysensors.org/topic/4493/duplicate-child-id-0</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 04:45:48 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/4493.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Aug 2016 02:11:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Duplicate Child ID 0 on Mon, 08 Aug 2016 16:51:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tris" aria-label="Profile: Tris">@<bdi>Tris</bdi></a> I think this would work:</p>
<pre><code>present(sensor + MAX_ATTACHED_DS18B2 + NUMBER_OF_SWITCHES, S_LIGHT);
</code></pre>
]]></description><link>https://forum.mysensors.org/post/44916</link><guid isPermaLink="true">https://forum.mysensors.org/post/44916</guid><dc:creator><![CDATA[mfalkvidd]]></dc:creator><pubDate>Mon, 08 Aug 2016 16:51:03 GMT</pubDate></item><item><title><![CDATA[Reply to Duplicate Child ID 0 on Mon, 08 Aug 2016 13:21:49 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/user/mfalkvidd" aria-label="Profile: mfalkvidd">@<bdi>mfalkvidd</bdi></a>, im very grateful!</p>
<p dir="auto">I am confident handling the hardware of that many sensors on a Mega, and I cut and paste all the code in small increments, and by doing so, learnt how most of it works - so its reasonably manageable....</p>
<p dir="auto">I have another Mega handling the more intricate code/sensors like gas/smoke so i would really like to keep this Arduino to the big amount of simple sensors.</p>
<p dir="auto">Im now stuck on adding the relays, to the switches and dallas that you combined -which resulted in unique, sequential sensors ID's..</p>
<p dir="auto">How do i add</p>
<pre><code>for (int i=0; i&lt;numSensors &amp;&amp; i&lt;MAX_ATTACHED_DS18B20; i++) {
present(NUMBER_OF_SWITCHES + i, S_TEMP);
}
</code></pre>
<p dir="auto">to this</p>
<pre><code>for (int sensor=1, pin=RELAY_1; sensor&lt;=NUMBER_OF_RELAYS;sensor++, pin++) 
present(sensor, S_LIGHT);
</code></pre>
<p dir="auto">Ive tried every combination i can think of, but everything ive done either duplicates sets of sensors or ignores them!<br />
Any pointers would be great</p>
]]></description><link>https://forum.mysensors.org/post/44894</link><guid isPermaLink="true">https://forum.mysensors.org/post/44894</guid><dc:creator><![CDATA[Tris]]></dc:creator><pubDate>Mon, 08 Aug 2016 13:21:49 GMT</pubDate></item><item><title><![CDATA[Reply to Duplicate Child ID 0 on Sat, 06 Aug 2016 08:19:18 GMT]]></title><description><![CDATA[<p dir="auto">Welcome to the MySensors community <a class="plugin-mentions-user plugin-mentions-a" href="/user/tris" aria-label="Profile: Tris">@<bdi>Tris</bdi></a> !</p>
<p dir="auto">Code is marked as code by three backticks (`) or just press the code button (&lt;/&gt;) on the toolbar. It is possible to edit previous posts by clicking on the three dots in the lower right corner of the post.</p>
<p dir="auto">You are on the right track with solving the problem. Each loop starts over at 0 and that makes it re-use the same IDs. You need to do something like this for the second and third loop, change</p>
<pre><code>for (int i=0; i&lt;numSensors &amp;&amp; i&lt;MAX_ATTACHED_DS18B20; i++) {
present(i, S_TEMP);
}
</code></pre>
<p dir="auto">to</p>
<pre><code>for (int i=0; i&lt;numSensors &amp;&amp; i&lt;MAX_ATTACHED_DS18B20; i++) {
present(NUMBER_OF_SWITCHES + i, S_TEMP);
}
</code></pre>
<p dir="auto">You will also have to define all CHILD_ID_xxx to be outside of the numbers used by the for loops.</p>
<p dir="auto">I would not want to manage so many sensors on a single node though. The wires and the code will be a mess. If you can, consider using a few different Arduinos to make each sketch simpler. A complex sketch will be harder to troubleshoot.</p>
]]></description><link>https://forum.mysensors.org/post/44655</link><guid isPermaLink="true">https://forum.mysensors.org/post/44655</guid><dc:creator><![CDATA[mfalkvidd]]></dc:creator><pubDate>Sat, 06 Aug 2016 08:19:18 GMT</pubDate></item><item><title><![CDATA[Reply to Duplicate Child ID 0 on Sat, 06 Aug 2016 02:20:33 GMT]]></title><description><![CDATA[<p dir="auto">[code]<br />
/**</p>
<ul>
<li>Mysensors node talks to mqtt ethernet gateway client</li>
<li>dht 1 (2 VALUES)</li>
<li>relays 8</li>
<li>light level 1</li>
<li>uv flame level 1</li>
<li>energy 1</li>
<li>servo speed 4</li>
<li>dallas 2</li>
<li>switches 4<br />
*/</li>
</ul>
<p dir="auto">#define MY_NODE_ID 9<br />
// Enable debug prints<br />
#define MY_DEBUG</p>
<p dir="auto">// Enable and select radio type attached<br />
#define MY_RADIO_NRF24<br />
//#define MY_RADIO_RFM69</p>
<p dir="auto">#include &lt;VarSpeedServo.h&gt;<br />
#include &lt;SPI.h&gt;<br />
#include &lt;MySensors.h&gt;<br />
#include &lt;DHT.h&gt;<br />
#include &lt;DallasTemperature.h&gt;    // For Dallas temp sensor<br />
#include &lt;OneWire.h&gt;              // For Dallas temp sensor<br />
#include &lt;Bounce2.h&gt;</p>
<p dir="auto">#define CHILD_ID_HUM 10<br />
#define CHILD_ID_TEMP 11<br />
#define HUMIDITY_SENSOR_DIGITAL_PIN 48<br />
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321</p>
<p dir="auto">unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)<br />
unsigned long lastRefreshTime = 0; // Use this to implement a non-blocking delay function<br />
#define RELAY_1  22  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)<br />
#define NUMBER_OF_RELAYS 8 // Total number of attached relays<br />
#define RELAY_ON 0  // GPIO value to write to turn on attached relay<br />
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay</p>
<p dir="auto">#define CHILD_ID_LIGHT 40<br />
#define LIGHT_SENSOR_ANALOG_PIN 0</p>
<p dir="auto">#define CHILD_ID_FLAME 45<br />
#define FLAME_SENSOR_ANALOG_PIN 1</p>
<p dir="auto">#define ONE_WIRE_BUS 49               // DALLAS pin<br />
#define MAX_ATTACHED_DS18B20 2      // DALLAS max nr. of sensors</p>
<p dir="auto">#include &lt;EmonLib.h&gt;             // Include Emon Library<br />
EnergyMonitor emon1;             // Create an instance<br />
#define CHILD_ID_ENERGY 50         //Current Sense Pin</p>
<p dir="auto">#define NUMBER_OF_SWITCHES 5<br />
Bounce debouncer[NUMBER_OF_SWITCHES];<br />
int oldValue[NUMBER_OF_SWITCHES];<br />
byte switchPin[NUMBER_OF_SWITCHES] = {34,35,36,37,38}; //&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; set your switch pins here</p>
<p dir="auto">unsigned long lastSend;<br />
unsigned long SEND_FREQUENCY = 10000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.</p>
<p dir="auto">// Store variables<br />
//long previousMillis = 0;        // last time the sensors are updated<br />
long sensorInterval = 20000;     // interval at which we will take a measurement ( 5 seconds)<br />
int lastLightLevel;             // Holds last light level<br />
int lastFlameLevel;              // Holds last FLAME level<br />
float lastTemperature[MAX_ATTACHED_DS18B20]; // Holds DALLAS temperatures<br />
int numSensors=0;               // Holds number of sensors<br />
//boolean metric = true;          // Celcius or fahrenheid<br />
int calibrationTime = 30;       // the time we give the sensor to calibrate (10-60 secs according to the datasheet)</p>
<p dir="auto">const int NBR_SERVOS = 4;       // the number of servos</p>
<p dir="auto">VarSpeedServo Servos[NBR_SERVOS];        // servo objects<br />
int servoPins[NBR_SERVOS]        = {44,     45,  6,  5}; // servo pins<br />
int servoSpeeds[NBR_SERVOS]      = {5,    10, 100, 255}; // sweep speed, 1 is slowest, 255 fastest)<br />
int servoMinPosition[NBR_SERVOS] = {45,   20,  30,  40}; // the minumum servo angle<br />
int servoMaxPosition[NBR_SERVOS] = {135, 130, 140, 150};</p>
<p dir="auto">// Initialize dallas<br />
OneWire oneWire(ONE_WIRE_BUS);<br />
DallasTemperature sensors(&amp;oneWire);</p>
<p dir="auto">DHT dht(HUMIDITY_SENSOR_DIGITAL_PIN, DHTTYPE);<br />
float lastTemp;<br />
float lastHum;<br />
boolean metric = true;<br />
MyMessage msgHum(CHILD_ID_HUM, V_HUM);<br />
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);<br />
MyMessage msgLLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL);<br />
MyMessage msgFLight(CHILD_ID_FLAME, V_LIGHT_LEVEL);<br />
MyMessage msgDallas(ONE_WIRE_BUS,V_TEMP);<br />
MyMessage IrmsMsg(CHILD_ID_ENERGY,V_WATT);<br />
MyMessage msgDoor(0,V_TRIPPED);</p>
<p dir="auto">void setup()<br />
{<br />
for (int i = 0; i &lt; NUMBER_OF_SWITCHES; i++)<br />
{<br />
pinMode(switchPin[i],INPUT_PULLUP);<br />
debouncer[i] = Bounce();<br />
debouncer[i].attach(switchPin[i]);<br />
debouncer[i].interval(5);<br />
}<br />
for (int i = 0; i &lt; NUMBER_OF_SWITCHES; i++)<br />
{<br />
present(i, S_DOOR);<br />
delay(250);<br />
}</p>
<p dir="auto">for(int i=0; i &lt; NBR_SERVOS; i++)<br />
{<br />
Servos[i].attach(servoPins[i]);<br />
Servos[i].slowmove(servoMinPosition[i],servoSpeeds[i]) ; // start sweeping from min position<br />
}</p>
<p dir="auto">dht.begin();</p>
<p dir="auto">metric = getConfig().isMetric;</p>
<pre><code>for (int sensor=1, pin=RELAY_1; sensor&lt;=NUMBER_OF_RELAYS;sensor++, pin++) {
// Then set relay pins in output mode
pinMode(pin, OUTPUT);   
// Set relay to last known state (using eeprom storage) 
digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">sensors.begin();</p>
<pre><code> numSensors = sensors.getDeviceCount();
</code></pre>
<p dir="auto">// Present all sensors to controller<br />
for (int i=0; i&lt;numSensors &amp;&amp; i&lt;MAX_ATTACHED_DS18B20; i++) {<br />
present(i, S_TEMP);<br />
}</p>
<p dir="auto">}</p>
<p dir="auto">void presentation()<br />
{</p>
<p dir="auto">// Send the Sketch Version Information to the Gateway<br />
sendSketchInfo("Terrace", "Garden");</p>
<p dir="auto">// Register all sensors to gw (they will be created as child devices)<br />
present(CHILD_ID_HUM, S_HUM);<br />
present(CHILD_ID_TEMP, S_TEMP);<br />
present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);<br />
present(CHILD_ID_FLAME, S_LIGHT_LEVEL);<br />
present(CHILD_ID_ENERGY, S_POWER);</p>
<p dir="auto">for (int sensor=1, pin=RELAY_1; sensor&lt;=NUMBER_OF_RELAYS;sensor++, pin++) {<br />
// Register all sensors to gw (they will be created as child devices)<br />
present(sensor, S_LIGHT);<br />
}</p>
<p dir="auto">emon1.current(A2, 29.0);       // Current: input pin, calibration.</p>
<p dir="auto">}</p>
<p dir="auto">void loop()<br />
{<br />
/////////////<br />
///INSTANST READINGS/COMMANDS SECTION<br />
////////////<br />
for (int i = 0; i &lt; NUMBER_OF_SWITCHES; i++)<br />
{<br />
debouncer[i].update();<br />
int value = debouncer[i].read();<br />
if (value != oldValue[i])<br />
{<br />
send(msgDoor.setSensor(i).set(value == HIGH? true : false), false);<br />
}<br />
oldValue[i] = value;<br />
}</p>
<p dir="auto">// sweep the servos<br />
for(int i=0; i &lt; NBR_SERVOS; i++)<br />
{<br />
if( Servos[i].read() == servoMinPosition[i])<br />
Servos[i].slowmove(servoMaxPosition[i],servoSpeeds[i]) ;<br />
else if( Servos[i].read() == servoMaxPosition[i])<br />
Servos[i].slowmove(servoMinPosition[i],servoSpeeds[i]) ;<br />
}</p>
<p dir="auto">////////////////<br />
///START LONG INTERVAL READINGS ONLY<br />
///////////////<br />
boolean needRefresh = (millis() - lastRefreshTime) &gt; SLEEP_TIME;<br />
if (needRefresh)<br />
{<br />
lastRefreshTime = millis();</p>
<pre><code>      float temperature = dht.readTemperature();
      if (isnan(temperature)) {
      Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
      lastTemp = temperature;
      if (!metric) {
      }
      send(msgTemp.set(temperature, 1));
      Serial.print("Temperature: ");
      Serial.println(temperature);
      }
      
   // dht readings
      float humidity = dht.readHumidity();
      if (isnan(humidity)) {
      Serial.println("Failed reading humidity from DHT");
      } 
      else if (humidity != lastHum) {
      lastHum = humidity;
      send(msgHum.set(humidity, 1));
      Serial.print("Humidity: ");
      Serial.println(humidity);
      }
      
   // light level
      int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; 
      Serial.print("Light Percentage: ");
      Serial.println(lightLevel);
      if (lightLevel != lastLightLevel) {
      send(msgLLight.set(lightLevel));
      lastLightLevel = lightLevel;
      }
      
   // flame level
      int flameLevel = (1023-analogRead(FLAME_SENSOR_ANALOG_PIN))/10.23; 
      Serial.print("Flame Percentage: ");
      Serial.println(flameLevel);
      if (flameLevel != lastFlameLevel) {
      send(msgFLight.set(flameLevel));
      lastFlameLevel = flameLevel;
      }

      unsigned long now = millis();
      double Irms = emon1.calcIrms(1480);  // Calculate Irms only
      bool sendTime = now - lastSend &gt; SEND_FREQUENCY;
      if (sendTime) { 
      send(IrmsMsg.set((Irms*232.0), 1));
      Serial.print("Watt: ");
      Serial.println(Irms*232.0);
   // send(kWhMsg.set((Irms*232.0)/1000, 1));
   // Serial.print("kWH: ");
   // Serial.println((Irms*232.0)/1000);
      lastSend = now;
      }

   // Begin dallas temperature
   // Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
   // Read temperatures and send them to controller 
      for (int i=0; i&lt;numSensors &amp;&amp; i&lt;MAX_ATTACHED_DS18B20; i++) {
   // Fetch and round temperature to one decimal
      float temperature = static_cast&lt;float&gt;(static_cast&lt;int&gt;((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
      Serial.print("Dallas ");
      Serial.print(i);
      Serial.print(" ");
      Serial.println(temperature);
   // Only send data if temperature has changed and no error
      if (lastTemperature[i] != temperature &amp;&amp; temperature != -127.00) {
   // Send in the new temperature
      send(msgDallas.setSensor(i).set(temperature,1));
      lastTemperature[i]=temperature;
      }
    } 
    // End dallas temperarures
}
// END LONG READ/SAMPLE INTERVAL
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void receive(const MyMessage &amp;message)<br />
{<br />
// We only expect one type of message from controller. But we better check anyway.<br />
if (message.type==V_STATUS) {<br />
// Change relay state<br />
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);<br />
// Store state in eeprom<br />
saveState(message.sensor, message.getBool());<br />
// Write some debug info<br />
Serial.print("Incoming change for sensor:");<br />
Serial.print(message.sensor);<br />
Serial.print(", New status: ");<br />
Serial.println(message.getBool());<br />
}<br />
}</p>
<p dir="auto">[/code]</p>
]]></description><link>https://forum.mysensors.org/post/44646</link><guid isPermaLink="true">https://forum.mysensors.org/post/44646</guid><dc:creator><![CDATA[Tris]]></dc:creator><pubDate>Sat, 06 Aug 2016 02:20:33 GMT</pubDate></item></channel></rss>