<?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[RelayWithButtonActuator problem after toggling with pushbutton]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm struggling with the example RelayWithButtonActuator.ino sketch.<br />
After uploading the sketch to my Arduino Nano, I get the following scenario :<br />
At first, when I toggle the relay from Openhab via MQTT, then all seems to work fine, but after I toggle the relay with the local_button pin3, then I get the problem that the state always remains 1 for subsequent toggles (either from openhab, either from local button).<br />
The serial monitor shows this (see below) : you can, at the last lines, see that indeed status remains 1.<br />
I'm guessing it has to do with the gw.saveState.<br />
Any hints ?<br />
Or is this hardware related ?<br />
I've loaded to different arduino's &amp; radio's with the same result ...<br />
Thanks for any help.</p>
<p dir="auto">Incoming change for sensor:28, New status: 0<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:1D004113<br />
Incoming change for sensor:28, New status: 1<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:0D004113<br />
Incoming change for sensor:28, New status: 0<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:1D004113<br />
Incoming change for sensor:28, New status: 1<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:0D004113<br />
Incoming change for sensor:28, New status: 0<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:1D004113<br />
Incoming change for sensor:28, New status: 1<br />
send: 28-28-0-0 s=28,c=1,t=2,pt=2,l=2,sg=0,st=ok:0<br />
read: 0-0-28 s=28,c=1,t=2,pt=2,l=2,sg=0:0<br />
This is an ack from gateway<br />
Incoming change for sensor:28, New status: 0<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:07204113<br />
Incoming change for sensor:28, New status: 1<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:17204113<br />
Incoming change for sensor:28, New status: 1<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:07204113<br />
Incoming change for sensor:28, New status: 1<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:17204113<br />
Incoming change for sensor:28, New status: 1<br />
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8,sg=0:07204113<br />
Incoming change for sensor:28, New status: 1</p>
]]></description><link>https://forum.mysensors.org/topic/2216/relaywithbuttonactuator-problem-after-toggling-with-pushbutton</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 23:54:53 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/2216.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Oct 2015 20:17:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to RelayWithButtonActuator problem after toggling with pushbutton on Fri, 06 Nov 2015 13:24:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi, I still haven't found the cause of the problem.<br />
But I have found a workaround :)</p>
<p dir="auto">The problem is captured in the serial output of  my previous post.<br />
As you can see the payload ? of the  incomming message is for some reason messed up.<br />
I still suspect the mqtt-cllient-gateway to be responsible for this, but i can not prove this.</p>
<p dir="auto">So the workaround is to filter out only the good info from  the messedup payload. The good info seems to be found in the first bytes of the payload, while the last part acts up randomly.<br />
I filtered using substring as follows :+1:</p>
<pre><code>String hexstring = message.getString();
String String3 = hexstring.substring(0,1); // Filter out unwanted additional characters = workaround bug
</code></pre>
]]></description><link>https://forum.mysensors.org/post/24009</link><guid isPermaLink="true">https://forum.mysensors.org/post/24009</guid><dc:creator><![CDATA[DirkB19]]></dc:creator><pubDate>Fri, 06 Nov 2015 13:24:57 GMT</pubDate></item><item><title><![CDATA[Reply to RelayWithButtonActuator problem after toggling with pushbutton on Tue, 27 Oct 2015 22:14:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/theol" aria-label="Profile: TheoL">@<bdi>TheoL</bdi></a>, thanks again for looking at my problem.</p>
<p dir="auto">You could be right about the mqtt-client-gateway being the problem.<br />
I'm waiting for a new Arduino UNO to arrive to test the mqtt gateway based on 1.5 lib.</p>
<p dir="auto">Meanwhile if assembled another Arduino Nano + nRF24L01 node and uploaded the sketch to it.</p>
<p dir="auto">Below is a dump of the serial monitor.<br />
From the serial monitor dump, could somebody please explain to me the meaning of "l=8:03606113 " ?<br />
Because when this comes up it is where things go wrong ...</p>
<pre><code>send: 28-28-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
read: 0-0-28 s=255,c=3,t=8,pt=1,l=1:0
new parent=0, d=1
sensor started, id 28
send: 28-28-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.2
send: 28-28-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
read: 0-0-28 s=255,c=3,t=6,pt=0,l=1:M
send: 28-28-0-0 s=255,c=3,t=11,pt=0,l=5,st=ok:RELAY
send: 28-28-0-0 s=255,c=3,t=12,pt=0,l=6,st=ok:node28
send: 28-28-0-0 s=28,c=0,t=3,pt=0,l=0,st=ok:
 Loaded  status from gw: 1
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:0D096113
Incoming change for sensor:28, New status: 0
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:1D096113
Incoming change for sensor:28, New status: 1
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:0D096113
Incoming change for sensor:28, New status: 0
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:1D096113
Incoming change for sensor:28, New status: 1
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:03606113   &lt;==== what is the meaning of this ?
Incoming change for sensor:28, New status: 1  &lt;==== the result is that New status = 1 when it should be 0 !!
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:1D006113
Incoming change for sensor:28, New status: 1
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:0D006113
Incoming change for sensor:28, New status: 0
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:1D006113
Incoming change for sensor:28, New status: 1
read: 0-0-28 s=28,c=1,t=2,pt=0,l=8:0D006113
Incoming change for sensor:28, New status: 0

</code></pre>
<p dir="auto">Thanks,<br />
DirkB</p>
]]></description><link>https://forum.mysensors.org/post/23582</link><guid isPermaLink="true">https://forum.mysensors.org/post/23582</guid><dc:creator><![CDATA[DirkB19]]></dc:creator><pubDate>Tue, 27 Oct 2015 22:14:53 GMT</pubDate></item><item><title><![CDATA[Reply to RelayWithButtonActuator problem after toggling with pushbutton on Tue, 27 Oct 2015 18:37:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dirkb19" aria-label="Profile: DirkB19">@<bdi>DirkB19</bdi></a> To me it looks like MQTT keeps sending 1 to your node.</p>
<pre><code> // Write some debug info
     Serial.print("Incoming change for sensor:");
     Serial.print(message.sensor);
     Serial.print(", New status: ");
     Serial.println(message.getBool()); &lt;---- this value remains '1' acording to your debug info
</code></pre>
<p dir="auto">You Sketch keep printing ",New status: 1" which means it receives 1 is the new value from MQTT??? Maybe the problem is within MQTT?</p>
]]></description><link>https://forum.mysensors.org/post/23565</link><guid isPermaLink="true">https://forum.mysensors.org/post/23565</guid><dc:creator><![CDATA[TheoL]]></dc:creator><pubDate>Tue, 27 Oct 2015 18:37:44 GMT</pubDate></item><item><title><![CDATA[Reply to RelayWithButtonActuator problem after toggling with pushbutton on Tue, 27 Oct 2015 18:16:38 GMT]]></title><description><![CDATA[<p dir="auto">Hi TheoL,</p>
<p dir="auto">Thanks for your reply.<br />
I tried it as you suggested but still the same problem.</p>
<p dir="auto">I've posted serial monitor from the sensor in my first post.<br />
Is it the serial output from the mqtt-client-gateway you want to see ?<br />
In the first post you see in the beginning a few lines like :+1:<br />
"Incoming change for sensor 28, New status :1"<br />
The first few lines like this is when it works, status toggles from 1 to 0 and back when receiving the according MQTT message.<br />
But then you notice that status remains 1 even if 0 was sent from MQTT.</p>
<p dir="auto">Anyway thanks for replying.<br />
Grts,<br />
DirkB</p>
]]></description><link>https://forum.mysensors.org/post/23563</link><guid isPermaLink="true">https://forum.mysensors.org/post/23563</guid><dc:creator><![CDATA[DirkB19]]></dc:creator><pubDate>Tue, 27 Oct 2015 18:16:38 GMT</pubDate></item><item><title><![CDATA[Reply to RelayWithButtonActuator problem after toggling with pushbutton on Sun, 25 Oct 2015 13:47:02 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/dirkb19" aria-label="Profile: DirkB19">@<bdi>DirkB19</bdi></a>,</p>
<p dir="auto">I don't know anything about MQTT. But I've noticed a couple of things. Don't think it'll solve your problem though. I'll put my comment's in your code</p>
<p dir="auto">setup()</p>
<pre><code>void setup()  
{ 
  gw.begin(incomingMessage, node_id, false);

  // Send the sketch version information to the gateway and Controller
  gw.sendSketchInfo("RELAY", "node28");

    // Register all sensors to gw (they will be created as child devices)
  gw.present(CHILD_ID, S_BINARY);        // No expert on this, but I use S_LIGHT

    // Make sure relays are off when starting up
  digitalWrite(RELAY_PIN, RELAY_OFF);          // Theo: put the pinMode declaration above the first write!
  // Then set relay pins in output mode
  pinMode(RELAY_PIN, OUTPUT);   
      
  // Set relay to last known state (using eeprom storage) 
  // state = gw.loadState(CHILD_ID);
  Serial.print(", Loaded  status from gw: ");
  Serial.println(state);
  digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); 
}
</code></pre>
<p dir="auto">To dig into it more, I'd like to see the results in the Serial monitor.</p>
]]></description><link>https://forum.mysensors.org/post/23425</link><guid isPermaLink="true">https://forum.mysensors.org/post/23425</guid><dc:creator><![CDATA[TheoL]]></dc:creator><pubDate>Sun, 25 Oct 2015 13:47:02 GMT</pubDate></item><item><title><![CDATA[Reply to RelayWithButtonActuator problem after toggling with pushbutton on Sun, 25 Oct 2015 13:26:48 GMT]]></title><description><![CDATA[<p dir="auto">Meanwhile, I re-compiled the skech with 1.4 Library. So the sensor-sketch and MQTT CLIENT GATEWAY now have compiled with the same library.<br />
Still same problem.<br />
I'm getting desperate here.<br />
I've build many sensors and know how to decouple radio etc. so I don't believe hardware is the problem.<br />
Thank you for any hint.</p>
]]></description><link>https://forum.mysensors.org/post/23424</link><guid isPermaLink="true">https://forum.mysensors.org/post/23424</guid><dc:creator><![CDATA[DirkB19]]></dc:creator><pubDate>Sun, 25 Oct 2015 13:26:48 GMT</pubDate></item><item><title><![CDATA[Reply to RelayWithButtonActuator problem after toggling with pushbutton on Wed, 21 Oct 2015 20:58:07 GMT]]></title><description><![CDATA[<p dir="auto">Ok,</p>
<p dir="auto">I've investigated further and now I suspect my MQTT Client gateway which is 1.4 based. While the relay sketch is 1.5 based ... could this be the problem ?<br />
What I did was strip-out the RelayWithButtonActuator sketch to the bare mimimum, keeping it as (see below)</p>
<p dir="auto">I can verify that OpenHAB sends correct MQTT messages to the Mosquito broker. (Via MQTT lens)<br />
I assume that the MQTT Client picks them up correctly via ethernet.<br />
But when the communication arrives at the sensor node, it oftenreads out state=1 when it should be 0.</p>
<p dir="auto">I'm reluctant to upgrade my MQTT Client to 1.5 because it has so far worked very well with about 8 sensornodes connected.</p>
<p dir="auto">Thanks for any advise.<br />
DirkB</p>
<pre><code>#include &lt;MySensor.h&gt;  
#include &lt;SPI.h&gt;
#define CHILD_ID 28   // Id of the sensor child
#define RELAY_PIN  4  // Arduino Digital I/O pin number for relay 
#define RELAY_ON 1
#define RELAY_OFF 0

int node_id = 28;
boolean state = false;
MySensor gw;
MyMessage msg(CHILD_ID,V_STATUS);

void setup()  
{ 
  gw.begin(incomingMessage, node_id, false);

  // Send the sketch version information to the gateway and Controller
  gw.sendSketchInfo("RELAY", "node28");

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

    // Make sure relays are off when starting up
  digitalWrite(RELAY_PIN, RELAY_OFF);
  // Then set relay pins in output mode
  pinMode(RELAY_PIN, OUTPUT);   
      
  // Set relay to last known state (using eeprom storage) 
  // state = gw.loadState(CHILD_ID);
  Serial.print(", Loaded  status from gw: ");
  Serial.println(state);
  digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
}


void loop()     
{     
  // Process incoming messages (like config from server)
  gw.process();
}


void incomingMessage(const MyMessage &amp;message) {
  // We only expect one type of message from controller. But we better check anyway.
  if (message.isAck()) {
     Serial.println("This is an ack from gateway");
  }

  if (message.type == V_STATUS) {
     // Change relay 
     state = message.getBool();
     digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
     // Store state in eeprom
     // gw.saveState(CHILD_ID, state);
    
     // Write some debug info
     Serial.print("Incoming change for sensor:");
     Serial.print(message.sensor);
     Serial.print(", New status: ");
     Serial.println(message.getBool());
   } 
}
</code></pre>
]]></description><link>https://forum.mysensors.org/post/23226</link><guid isPermaLink="true">https://forum.mysensors.org/post/23226</guid><dc:creator><![CDATA[DirkB19]]></dc:creator><pubDate>Wed, 21 Oct 2015 20:58:07 GMT</pubDate></item></channel></rss>