Hi
Here is my Log from fhem:
2019.04.16 11:29:42 4 : MYSENSORS/RAW: /0;255;3;0;9;316561201 TSF:MSG:RE
2019.04.16 11:29:42 4 : MYSENSORS/RAW: 0;255;3;0;9;316561201 TSF:MSG:RE/AD,100-100-0,s=1,c=2,t=2,pt=0,l=
2019.04.16 11:29:42 4 : MYSENSORS/RAW: 0;255;3;0;9;316561201 TSF:MSG:READ,100-100-0,s=1,c=2,t=2,pt=0,l=/0,sg=0: 100;1;2;0;2;
2019.04.16 11:29:42 4 : MYSENSORS Read: Rx: fr=000 ci=255 c=003(C_INTERNAL ) st=009(I_LOG_MESSAGE ) ack=0 '316561201 TSF:MSG:READ,100-100-0,s=1,c=2,t=2,pt=0,l=0,sg=0:'
2019.04.16 11:29:42 5 : MYSENSORS gateway MySensors_Serial: 316561201 TSF:MSG:READ,100-100-0,s=1,c=2,t=2,pt=0,l=0,sg=0:
2019.04.16 11:29:42 4 : MYSENSORS Read: Rx: fr=100 ci=001 c=002(C_REQ ) st=002(V_STATUS ) ack=0 ''
2019.04.16 11:29:42 5 : MYSENSORS **send: Rx: fr=100 ci=001 c=001(C_SET ) st=002(V_STATUS ) ack=1 'off'**
2019.04.16 11:29:42 5 : SW: 3130303b313b313b313b323b6f66660a
2019.04.16 11:29:42 1 : PERL WARNING: Use of uninitialized value in addition (+) at ./FHEM/00_MYSENSORS.pm line 542.
2019.04.16 11:29:42 4 : MYSENSORS/RAW: /0;255;3;0;9;316561860 !TSF:MSG:S
2019.04.16 11:29:42 4 : MYSENSORS/RAW: 0;255;3;0;9;316561860 !TSF:MSG:S/END,0-0-100-100,s=1,c=1,t=2,pt=0
2019.04.16 11:29:42 4 : MYSENSORS/RAW: 0;255;3;0;9;316561860 !TSF:MSG:SEND,0-0-100-100,s=1,c=1,t=2,pt=0/,l=3,sg=0,ft=0,st=NACK:off
2019.04.16 11:29:42 4 : MYSENSORS Read: Rx: fr=000 ci=255 c=003(C_INTERNAL ) st=009(I_LOG_MESSAGE ) ack=0 '316561860 !TSF:MSG:SEND,0-0-100-100,s=1,c=1,t=2,pt=0,l=3,sg=0,ft=0,st=NACK:off'
2019.04.16 11:29:42 5 : MYSENSORS gateway MySensors_Serial: 316561860 !TSF:MSG:SEND,0-0-100-100,s=1,c=1,t=2,pt=0,l=3,sg=0,ft=0,st=NACK:off
2019.04.16 11:29:42 4 : MYSENSORS/RAW: /0;255;3;0;9;316561871 TSF:MSG:RE
2019.04.16 11:29:42 4 : MYSENSORS/RAW: 0;255;3;0;9;316561871 TSF:MSG:RE/AD,100-100-0,s=2,c=2,t=2,pt=0,l=
2019.04.16 11:29:42 4 : MYSENSORS/RAW: 0;255;3;0;9;316561871 TSF:MSG:READ,100-100-0,s=2,c=2,t=2,pt=0,l=/0,sg=0: 100;2;2;0;2;
2019.04.16 11:29:42 4 : MYSENSORS Read: Rx: fr=000 ci=255 c=003(C_INTERNAL ) st=009(I_LOG_MESSAGE ) ack=0 '316561871 TSF:MSG:READ,100-100-0,s=2,c=2,t=2,pt=0,l=0,sg=0:'
2019.04.16 11:29:42 5 : MYSENSORS gateway MySensors_Serial: 316561871 TSF:MSG:READ,100-100-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
2019.04.16 11:29:42 4 : MYSENSORS Read: Rx: fr=100 ci=002 c=002(C_REQ ) st=002(V_STATUS ) ack=0 ''
2019.04.16 11:29:42 5 : **MYSENSORS send: Rx: fr=100 ci=002 c=001(C_SET ) st=002(V_STATUS ) ack=1 'off'**
2019.04.16 11:29:42 5 : SW: 3130303b323b313b313b323b6f66660a
And here from node:
37780 MCO:REG:REQ
38444 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
38659 TSF:MSG:READ,0-0-100,s=255,c=3,t=27,pt=1,l=1,sg=0:1
38664 MCO:PIM:NODE REG=1
38667 MCO:BGN:STP
38677 TSF:MSG:SEND,100-100-0-0,s=3,c=1,t=16,pt=4,l=4,sg=0,ft=0,st=OK:0
Relais 1 anfragen
39192 TSF:MSG:SEND,100-100-0-0,s=1,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
Relais 2 anfragen
39861 TSF:MSG:SEND,100-100-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
39867 MCO:BGN:INIT OK,TSP=1
Switched!
39879 TSF:MSG:SEND,100-100-0-0,s=3,c=1,t=16,pt=4,l=4,sg=0,ft=0,st=OK:0
40098 TSF:MSG:READ,0-0-100,s=3,c=1,t=16,pt=4,l=4,sg=0:0
40103 TSF:MSG:ACK
Sensor:3, Payload: 0
This is an ack from gateway
40115 TSF:MSG:READ,0-0-100,s=2,c=1,t=2,pt=0,l=3,sg=0:off
40120 TSF:MSG:ACK REQ
40331 TSF:MSG:SEND,100-100-0-0,s=2,c=1,t=2,pt=0,l=3,sg=0,ft=0,st=OK:off
Sensor:2, Payload: 0
Incoming change for relay:2, New status: 0
And to complete this post, my actual rubbish code
/*
* 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 <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2018 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 - Henrik Ekblad
*
* DESCRIPTION
* Example sketch showing how to control physical relays.
* This example will remember relay state after power failure.
* http://www.mysensors.org/build/relay
*/
#define SKETCH_NAME "Klingelmodul" // Change to a fancy name you like
#define SKETCH_VERSION "1.0" // Your version
// Enable debug prints to serial monitor
#define MY_DEBUG
#define MY_SPECIAL_DEBUG
// Enable and select radio type attached
//#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
#define MY_RADIO_RFM69
#define MY_RFM69_TX_POWER_DBM (12)
#define MY_RFM69_NEW_DRIVER
//#define MY_RADIO_RFM95
// Enable repeater functionality for this node
//#define MY_REPEATER_FEATURE
#include <Bounce2.h>
#include <MySensors.h>
#define RELAY1_PIN 2 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define RELAY2_PIN 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define INPUT1_PIN 16 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 2 // Total number of attached relays
#define RELAY_ON 0 // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay
#define CHILD_ID_Rel1 1 //Msg ID für Relais 1
#define CHILD_ID_Rel2 2 //Msg ID für Relais 1
#define CHILD_ID_Inp 3 //Msg ID für Klingelknopf
#define CHILD_ID_RSSI_HIGH 4 // RSSI received signal level
#define CHILD_ID_RSSI_LOW 5 // RSSI background noise level
Bounce debouncer = Bounce();
int Send_rssi, Rec_rssi; // Sende/Empfangslevel vomRSSI RFM69 chip
int oldValue=-1;
int rssi_send = 0; //Schleifenzähler für RSSI Level Senden
MyMessage msgRSSI1(CHILD_ID_RSSI_HIGH, V_LEVEL);
MyMessage msgRSSI2(CHILD_ID_RSSI_LOW, V_LEVEL);
MyMessage msgRel1 (CHILD_ID_Rel1, V_LIGHT);
MyMessage msgRel2 (CHILD_ID_Rel2, V_LIGHT);
MyMessage msgInp (CHILD_ID_Inp, V_TRIPPED);
//###############################################################################################
void before()
{
// Then set relay pins in output mode
pinMode(RELAY1_PIN, OUTPUT);
pinMode(RELAY2_PIN, OUTPUT);
pinMode(INPUT1_PIN,INPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(RELAY1_PIN, loadState(1)?RELAY_ON:RELAY_OFF);
digitalWrite(RELAY2_PIN, loadState(2)?RELAY_ON:RELAY_OFF);
digitalWrite(INPUT1_PIN,HIGH);
}
//###############################################################################################
void setup()
{
debouncer.attach(INPUT1_PIN);
debouncer.interval(5);
debouncer.update();
int value = debouncer.read();
send(msgInp.set(value==HIGH ? 1 : 0));
Serial.print("Relais 1 anfragen");
request(CHILD_ID_Rel1, V_LIGHT,0);
//wait(1000);
Serial.print("Relais 2 anfragen");
request(CHILD_ID_Rel2, V_LIGHT,0);
//wait(1000);
}
//###############################################################################################
void presentation()
{
// Send the Sketch Version Information to the Gateway
sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
present(CHILD_ID_Rel1,S_LIGHT, "Relais1", true);
present(CHILD_ID_Rel2,S_LIGHT, "Relais2", true);
present(CHILD_ID_Inp,S_DOOR, "Klingel", true);
present(CHILD_ID_RSSI_HIGH, S_SOUND,"RSSI_SendLevel", true);
present(CHILD_ID_RSSI_LOW, S_SOUND, "RSSI_ReceiveLevel", true);
}
//###############################################################################################
void loop()
{
//Alle 120Sekunden den RSSI Level schicken
if (rssi_send > 12000){
//Sende-Empfangsstaerke
Serial.print("RSSI Send");
wait(500); // Allow time for radio if power used as reset
Send_rssi = RFM69_getSendingRSSI(); // read RSSI in RFM69. Measure reception signal from gw
send(msgRSSI1.set(Send_rssi),true); // send RSSI level
wait(500); // wait to get idle
Rec_rssi = RFM69_getReceivingRSSI(); // read RSSI in RFM69. Wait and measure background noise
send(msgRSSI2.set(Rec_rssi),true); // send RSSI level
rssi_send = 0;
sendHeartbeat();
}
rssi_send +=1;
//Klingeltaster
debouncer.update();
// Get the update value
int value = debouncer.read();
if (value != oldValue) {
// Send in the new value
Serial.print("Switched!");
send(msgInp.set(value==HIGH ? 1 : 0),true);
oldValue = value;
}
wait(10);//10ms warten
}
//###############################################################################################
void receive(const MyMessage &message)
{
Serial.print("Sensor:");
Serial.print(message.sensor);
Serial.print(", Payload: ");
Serial.println(message.getBool());
// We only expect one type of message from controller. But we better check anyway.
if (message.isAck()) {
#ifdef MY_DEBUG
Serial.println("This is an ack from gateway");
#endif
return;
}
if (message.type==V_LIGHT) {
// Change relay state
int outputPin = (message.sensor == CHILD_ID_Rel1)?RELAY1_PIN:RELAY2_PIN;
digitalWrite(outputPin, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
//saveState(message.sensor, message.getBool());
#ifdef MY_DEBUG
// Write some debug info
Serial.print("Incoming change for relay:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
#endif
// Update the state variables
}
else {
#ifdef MY_DEBUG
// Write some debug info
Serial.print("Sensor:");
Serial.print(message.sensor);
Serial.print(", Payload: ");
Serial.println(message.getBool());
#endif
}
}```