@JeeLet Hi. First, you probably should have started another thread rather than hijacking this one since the situation is barely related.
Looking here, I found that !MCO:PRO:RC=1 is caused mainly by calling send() or wait() inside the receive() function.
I have not completely understood how things are happening but I think at best you're receiving a message while processing the current one. From several sources on this forum, you should keep your receive() function small. Process the content of the message and do all the work in loop().
I would probably do something like that, but I didn't compile and test the code :
/*
* Alco_TL_Impuls_Light.ino
*
* https://forum.mysensors.org/topic/11263/domoticz-mysensors
*
*
* REVISION HISTORY
* Version 1.0 - Gateway Serial par Alco
* Version 0.0 - Node en RS485 par JeeLet
*
*LA DESCRIPTION
* TL :Commande Impulsionnelle de TeLerupteur d'Eclairage
* TS :Retour d'Etat par un contact auxiliaire du TL.
*
* L'installation Electrique n'est pas modifiee,
* les boutons poussoir de l'habitat Cmd aussi le TL.
*
*
*/
//#define MY_DEBUG
#define MY_NODE_ID 24 /*pour Node ID static*/
/* ----- Module RS485 ----*/
#define MY_RS485
#define MY_RS485_DE_PIN 2
#define MY_RS485_BAUD_RATE 9600
// #define MY_RS485_HWSERIAL Serial1 /* Mega2560, port Serial X? */
#include <MySensors.h>
#include <Bounce2.h>
#define STATE_CHILD_ID 0 /*Id du capteur (enfant)*/
#define RELAY_PIN 4 // pin Cmd Telerupteur "TL"
#define CONTROL_INPUT_PIN 3 // pin Contact Auxiliaire "TS"
#define RELAY_ON 1
#define RELAY_OFF 0
Bounce debouncer = Bounce(); // initialize debouncer
MyMessage msg(STATE_CHILD_ID,V_STATUS);
void setup()
{
pinMode(CONTROL_INPUT_PIN, INPUT_PULLUP);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, RELAY_OFF);
debouncer.attach(CONTROL_INPUT_PIN);
debouncer.interval(20); // minimum ?
}
bool currentState;
bool controllerState;
void presentation()
{
sendSketchInfo("Cmd TL", "1.a");
present(STATE_CHILD_ID, S_LIGHT);
}
void loop()
{
// Send impulse if controller changed state
if (controllerState != currentState)
{
currentState = controllerState;
digitalWrite(RELAY_PIN, RELAY_ON);
wait(200); //delai On-Off Impuls
digitalWrite(RELAY_PIN, RELAY_OFF);
}
// Inform controller if state change from input
if (debouncer.update())
{
bool newState = !digitalRead(CONTROL_INPUT_PIN);
if (newState != currentState)
{
currentState = newState;
if (currentState != controllerState)
{
send(msg.set(currentState));
}
}
}
}
void receive(const MyMessage &message)
{
if (message.isEcho()) // keep message.isAck() for older MySensors version
{
Serial.println("Ceci est un accusé de réception de la passerelle");
Serial.println("Cmd TL 1.a");
return;
}
if (message.type==V_STATUS) // V_STATUS pour MyS v2.0, annulé V_LIGHT.
{
controllerState = message.getBool();
}
// Write some debug info
Serial.print("Changement entrant pour le capteur:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
// ------------ fin Pgm -----------
You may have to tweak the conditions and tests so that your sensor is always in a consistent state, but that should resolve the recursion error message.