I increased the capacity to 100uF and replaced delay() for wait() but no difference. Thanks for the hint about sender in receive() method, I will fix the functionality when the communication works. Any other idea?
Ivosch
@Ivosch
Best posts made by Ivosch
-
RE: [SOLVED] Ethernet gateway and node communication issue, 8221 !TSM:UPL:FAIL
-
RE: [SOLVED] Ethernet gateway and node communication issue, 8221 !TSM:UPL:FAIL
hello,
my bad. The second capacitor has not been properly attached, now the node is communicating!
Thank you for the help.note: 10uF wasn't enough, 110uF works fine for me
Latest posts made by Ivosch
-
ethernet gateway on OpenHAB 2.4.0 + mysensors 2.4.0
Hello,
I'm running OpenHAB 2.4.0 on Windows 7 and I followed the instructions to install mysensors (org.openhab.binding.mysensors-2.4.0-SNAPSHOT.jar) Now I not able to connect the gateway to the controller. I think the gateway code is fine. When I check the ports on the controller, there is no service listening on port 5003.Installed bundles:
Launching the openHAB runtime... Listening for transport dt_socket at address: 5005 __ _____ ____ ____ ____ ___ ____ / / / / | / __ ) / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __ | / /_/ / /_/ / __/ / / / __ / ___ |/ /_/ / \____/ .___/\___/_/ /_/_/ /_/_/ |_/_____/ /_/ 2.4.0 Release Build Hit '<tab>' for a list of available commands and '[cmd] --help' for help on a specific command. Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown openHAB. openhab> bundle:list START LEVEL 100 , List Threshold: 50 ID | State | Lvl | Version | Name ----+----------+-----+------------------------+-------------------------------- 20 | Active | 80 | 5.3.1.201602281253 | OSGi JAX-RS Connector 21 | Active | 80 | 2.7.0.v20170129-0911 | Gson: Google Json Library for 22 | Active | 80 | 18.0.0 | Guava: Google Core Libraries f 23 | Active | 80 | 3.0.0.v201312141243 | Google Guice (No AOP) 24 | Active | 80 | 3.18.1.GA | Javassist 26 | Active | 80 | 3.5.5 | JmDNS 28 | Active | 80 | 1.0.0 | Units of Measurement API 30 | Active | 80 | 1.1.0.Final | Bean Validation API 31 | Active | 80 | 2.0.1 | javax.ws.rs-api 32 | Active | 80 | 3.2.0.v201101311130 | ANTLR Runtime 35 | Active | 80 | 3.2.1 | Commons Collections 36 | Active | 80 | 1.1 | Commons Exec 37 | Active | 80 | 2.2.0 | Commons IO 38 | Active | 80 | 2.6 | Commons Lang 47 | Active | 80 | 4.2.1 | Apache Karaf :: OSGi Services 63 | Active | 80 | 4.6.0 | Apache XBean OSGI Bundle Utili 64 | Active | 80 | 4.6.0 | Apache XBean :: Classpath Reso 65 | Active | 80 | 2.12.0.v20160420-0247 | EMF Common 66 | Active | 80 | 2.12.0.v20160420-0247 | EMF Ecore 67 | Active | 80 | 2.11.0.v20160420-0247 | EMF Change Model 68 | Active | 80 | 2.12.0.v20160420-0247 | EMF XML/XMI Persistence 69 | Active | 80 | 3.8.0.v20160509-1230 | Common Eclipse Runtime 70 | Active | 80 | 3.6.100.v20160223-2218 | Extension Registry Support 80 | Active | 80 | 9.4.11.v20180605 | Jetty :: Proxy 94 | Active | 80 | 0.4.1.v20180515-1321 | org.eclipse.lsp4j 95 | Active | 80 | 0.4.1.v20180515-1321 | org.eclipse.lsp4j.jsonrpc 96 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome OAuth2Client 97 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Config Core 98 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Configuratio 99 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Configuratio 100 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Config Dispa 101 | Active | 75 | 0.10.0.oh240 | Eclipse SmartHome Config XML 102 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core 103 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core Audio 104 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core Binding 105 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core ID 106 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core Persist 107 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Scheduler Se 108 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core Semanti 109 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core Thing 110 | Active | 75 | 0.10.0.oh240 | Eclipse SmartHome Core Thing X 111 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Transformati 112 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core Voice 113 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Console 114 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Console for 115 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome HTTP Interfa 116 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome JavaSound I/ 117 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Monitor 118 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Net I/O Bund 119 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome REST Interfa 120 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Core REST API 121 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome REST mDNS An 122 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome REST Interfa 123 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Sitemap REST 124 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome SSE REST API 125 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Voice REST A 126 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Bonjour/MDS 127 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Web Audio Su 128 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Model Core 129 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Item Model 130 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Item Model I 131 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Item Model R 132 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Language Ser 133 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Persistence 134 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Persistence 135 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Persistence 136 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Rule Model 137 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Rule Model I 138 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Rule Runtime 139 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Script 140 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Script Model 141 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Script Runti 142 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Sitemap Model 143 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Sitemap Mode 144 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Sitemap Runt 145 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Thing Model 146 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Thing Model 147 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Thing Model 148 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Json Storage 149 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome UI 150 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome UI Icons 151 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Classic Icon 152 | Active | 80 | 2.14.0.v20180522-1629 | Xtend Runtime Library 153 | Active | 80 | 2.14.0.v20180522-1629 | Xtend Macro Interfaces 154 | Active | 80 | 2.14.0.v20180522-1821 | Xtext 155 | Active | 80 | 2.14.0.v20180522-1833 | Xtext Common Types 156 | Active | 80 | 2.14.0.v20180522-1821 | Xtext IDE Core 157 | Active | 80 | 2.14.0.v20180522-1821 | Xtext Utility 158 | Active | 80 | 2.14.0.v20180522-1833 | Xbase Model 159 | Active | 80 | 2.14.0.v20180522-1833 | Xbase Generic IDE Services 160 | Active | 80 | 2.14.0.v20180522-1629 | Xbase Runtime Library 175 | Active | 80 | 1.9.6 | MIME streaming extension 177 | Active | 80 | 6.2.0 | org.objectweb.asm 178 | Active | 80 | 6.2.0 | org.objectweb.asm.commons 179 | Active | 80 | 6.2.0 | org.objectweb.asm.tree 180 | Active | 90 | 2.4.0 | openHAB Core 181 | Active | 80 | 2.4.0 | openHAB Karaf Integration 183 | Resolved | 80 | 2.4.0 | openHAB Sound Support, Hosts: 184 | Active | 80 | 2.4.0 | openHAB Dashboard UI 189 | Active | 80 | 1.0.2 | Units of Measurement Common Li 190 | Active | 80 | 1.0.8 | Units of Measurement Implement 192 | Active | 80 | 3.3.0 | Commons Net 193 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Basic UI, Fr 194 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Paper UI, Fr 195 | Resolved | 75 | 2.4.0 | openHAB Basic UI Fragment, Hos 196 | Active | 80 | 2.4.0 | HABPanel User Interface 197 | Active | 80 | 2.4.0 | HomeBuilder User Interface 198 | Resolved | 75 | 2.4.0 | openHAB Paper UI Theme Fragmen 199 | Active | 80 | 1.2.0 | Paho MQTT Client 203 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome MQTT Transpo 205 | Active | 80 | 3.14.0 | nrjavaserial 206 | Active | 80 | 3.15.0.OH2 | nrjavaserial 207 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Configuratio 208 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Configuratio 209 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Config Serial 210 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Serial Trans 211 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Serial Trans 212 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Serial Trans 239 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Automation A 240 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome MQTT Binding 241 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome MQTT Thing B 243 | Active | 80 | 0.10.0.oh240 | Eclipse SmartHome Embedded MQT 244 | Active | 80 | 2.4.0.201812040738 | MySensors Binding openhab>
DEBUG OpenHAB output
openhab> log:set DEBUG org.openhab.binding.mysensors openhab> log:tail 19:20:43.607 [INFO ] [e.core.internal.i18n.I18nProviderImpl] - Location set to '49.1911985,16.6012874'. 19:20:45.120 [INFO ] [bpanel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel 19:20:45.557 [INFO ] [mebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder 19:20:53.685 [INFO ] [rthome.model.lsp.internal.ModelServer] - Started LanguageServer Protocol (LSP) service on port 5007 19:20:55.198 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'MySensorsDevice011_Status-mqtt:topic:424a9ca3:1' has been added. 19:20:55.198 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'MySensorsDevice011_Status-mysensors:light:3802127b:light_0_11:status' has been added. 19:20:55.214 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'GenericMQTTThing_Rele-mqtt:topic:cf69ffbc:2' has been added. 19:20:55.214 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'MySensorsDevice011_Status-mqtt:topic:3444e4d0:1' has been added. 19:20:55.214 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'MySensorsDevice011_Status-mysensors:light:022d5309:light_0_1:status' has been added. 19:20:55.214 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'GenericMQTTThing_-mqtt:topic:3444e4d0:2' has been added. 19:20:55.214 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'GenericMQTTThing_-mqtt:topic:cf69ffbc:1' has been added. 19:20:55.214 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'MySensorsDevice02_Level-mysensors:dust:022d5309:dust_0_2:level' has been added. 19:20:55.214 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'GenericMQTTThing_Rele-mqtt:topic:310e7267:iddd' has been added. 19:20:55.214 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'MySensorsDevice011_Statussssssssssssssssssss-mqtt:topic:3444e4d0:1' has been added. 19:20:55.292 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mqtt:topic:310e7267' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED) 19:20:55.900 [INFO ] [i.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.0.50:8080 19:20:56.056 [INFO ] [i.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.0.50:8443 19:20:56.867 [INFO ] [marthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui 19:20:57.694 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mqtt:systemBroker:embedded-mqtt-broker' changed from UNINITIALIZED to INITIALIZING 19:20:57.741 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mqtt:systemBroker:embedded-mqtt-broker' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): The system connection with the name embedded-mqtt-broker doesnt exist anymore. 19:20:57.756 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mqtt:topic:310e7267' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING 19:20:57.819 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mqtt:topic:310e7267' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE) 19:20:58.380 [WARN ] [er.internal.EmbeddedBrokerServiceImpl] - Embedded broker offline - Reason unknown 19:20:58.396 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mqtt:systemBroker:embedded-mqtt-broker' changed from OFFLINE (CONFIGURATION_ERROR): The system connection with the name embedded-mqtt-broker doesnt exist anymore. to OFFLINE 19:20:58.474 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '127.0.0.1' with clientid embedded-mqtt-broker and file store 'C:\openhab\userdata\mqtt\127.0.0.1' 19:20:58.552 [WARN ] [.moquette.spi.impl.SessionsRepository] - Session does notexist. CId=embedded-mqtt-broker 19:20:58.552 [WARN ] [.moquette.spi.impl.SessionsRepository] - Session does notexist. CId=embedded-mqtt-broker 19:20:58.614 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mqtt:systemBroker:embedded-mqtt-broker' changed from OFFLINE to ONLINE 19:20:58.614 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mqtt:topic:310e7267' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
Gateway output:
0 MCO:BGN:INIT GW,CP=R-NGA---,REL=255,VER=2.3.1 1004 GWT:TIN:IP=192.168.0.33 2009 !GWT:TIN:ETH FAIL 2011 MCO:BGN:STP MY_NODE_ID: 2552013 MCO:REG:NOT NEEDED 2016 MCO:BGN:INIT OK,TSP=NA 2020 !GWT:TSA:ETH FAIL 2023 !GWT:TSA:ETH FAIL 2027 !GWT:TSA:ETH FAIL 2030 !GWT:TSA:ETH FAIL 2033 !GWT:TSA:ETH FAIL 2037 !GWT:TSA:ETH FAIL
The gateway works fine as MQTT client and it is able to connect to MQTT broker at port 1883 but I would like to make it work as regular mysensor ethernet gateway.
-
RE: [SOLVED] Ethernet gateway and node communication issue, 8221 !TSM:UPL:FAIL
hello,
my bad. The second capacitor has not been properly attached, now the node is communicating!
Thank you for the help.note: 10uF wasn't enough, 110uF works fine for me
-
RE: [SOLVED] Ethernet gateway and node communication issue, 8221 !TSM:UPL:FAIL
I increased the capacity to 100uF and replaced delay() for wait() but no difference. Thanks for the hint about sender in receive() method, I will fix the functionality when the communication works. Any other idea?
-
RE: [SOLVED] Ethernet gateway and node communication issue, 8221 !TSM:UPL:FAIL
I use USB 3.0 HUB power with 10uF attached capacitors for gateway and node
-
[SOLVED] Ethernet gateway and node communication issue, 8221 !TSM:UPL:FAIL
Hello,
I have MQTT ethernet gateway based on W5500 with attached relay connected to OpenHAB. I am able to control the relay and it works fine. The code of the gateway:// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_NRF5_ESB //#define MY_RADIO_RFM69 //#define MY_RADIO_RFM95 // Enable gateway ethernet module type //#define MY_GATEWAY_W5100 #define MY_GATEWAY_ENC28J60 #define MY_GATEWAY_MQTT_CLIENT // Set this nodes subscripe and publish topic prefix #define MY_MQTT_PUBLISH_TOPIC_PREFIX "P" #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "S" #define MY_CONTROLLER_IP_ADDRESS 192,168,0,50 #define MY_PORT 1883 // Set MQTT client id #define MY_MQTT_CLIENT_ID "M1" // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4 // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16 #define MY_SOFT_SPI_MOSI_PIN 15 #endif // When W5100 is connected we have to move CE/CSN pins for NRF radio #ifndef MY_RF24_CE_PIN #define MY_RF24_CE_PIN 5 #endif #ifndef MY_RF24_CS_PIN #define MY_RF24_CS_PIN 6 #endif // Enable UDP communication //#define MY_USE_UDP // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,0,33 // If using static ip you can define Gateway and Subnet address as well //#define MY_IP_GATEWAY_ADDRESS 192,168,0,100 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // Renewal period if using DHCP //#define MY_IP_RENEWAL_INTERVAL 60000 // The port to keep open on node server mode / or port to contact in client mode //#define MY_PORT 5003 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254 // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Arduino examples use "DEAD BEEF FEED" for the MAC address. #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway //#define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button //#define MY_INCLUSION_MODE_BUTTON_PIN 3 // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Flash leds on rx/tx/err // Uncomment to override default HW configurations //#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 9 // Transmit led pin #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet2.h> #include <MySensors.h> #include <Bounce2.h> #define RELAY_PIN 4 // Arduino Digital I/O pin number for relay #define BUTTON_PIN 3 // Arduino Digital I/O pin number for button #define CHILD_ID 1 // Id of the sensor child #define CHILD_ID_SWITCH 2 #define RELAY_ON 1 #define RELAY_OFF 0 //DeviceAddress addrTemp1 = { 0x28, 0xFF, 0x57, 0x98, 0x80, 0x15, 0x42, 0x17 }; //Bounce debouncer = Bounce(); int oldValue=0; bool state; unsigned long t0; MyMessage msgButton(CHILD_ID_SWITCH, V_VAR1); MyMessage msg(CHILD_ID,V_STATUS); void setup() { // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // After setting up the button, setup debouncer //debouncer.attach(BUTTON_PIN); //debouncer.interval(5); // 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 = loadState(CHILD_ID); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); Serial.println("MY_NODE_ID: "); Serial.print(MY_NODE_ID); t0=millis(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Relay & Button", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, V_STATUS); present(CHILD_ID_SWITCH, V_VAR1); } void loop() { //debouncer.update(); //Get the update value //int value = debouncer.read(); //if (value != oldValue && value==0) { //send(msg.set(state?false:true), true); // Send new state and request ack back //} //oldValue = value; if ((millis()-t0) > 5000) ServerUpdate(); delay(100); } void receive(const MyMessage &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_LIGHT) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); // Store state in eeprom 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()); } } void ServerUpdate() { send(msgButton.set(133)); send(msg.set(133)); t0=millis(); }
Now I'm trying to connect the node through NRF24L01+. Just for test with another relay and switch. The code:
#define MY_DEBUG #define MY_NODE_ID 6 #define MY_PARENT_NODE_ID 0 #define MY_PARENT_NODE_IS_STATIC // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 // Enabled repeater feature for this node //#define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <Bounce2.h> #define RELAY_PIN 4 // Arduino Digital I/O pin number for relay #define BUTTON_PIN 3 // Arduino Digital I/O pin number for button #define CHILD_ID 22 // Id of the sensor child #define RELAY_ON 1 #define RELAY_OFF 0 Bounce debouncer = Bounce(); int oldValue=0; bool state; unsigned long t0; MyMessage msg(CHILD_ID,V_LIGHT); MyMessage msg2(CHILD_ID,V_STATUS); void setup() { // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); // 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 = loadState(CHILD_ID); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); t0=millis(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Relay & Button", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_LIGHT); present(CHILD_ID, V_STATUS); } /* * Example on how to asynchronously check for new messages from gw */ void loop() { debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue && value==0) { send(msg.set(state?false:true), true); // Send new state and request ack back } oldValue = value; if ((millis()-t0) > 5000) ServerUpdate(); delay(100); } void receive(const MyMessage &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_LIGHT) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); // Store state in eeprom 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()); } } void ServerUpdate() { send(msg2.set(122)); t0=millis(); }
But the messages are not going to MQTT broker, I use MQTT.fx, only when the node is started, there are only initiation messages:
P/0/255/0/0/18 2.3.1 P/0/255/3/0/11 Relay & Button P/0/255/3/0/12 1.0
There are some debug errors in gateway output:
0 MCO:BGN:INIT GW,CP=RNNGA---,REL=255,VER=2.3.1 4 TSM:INIT 5 TSF:WUR:MS=0 11 TSM:INIT:TSP OK 13 TSM:INIT:GW MODE 15 TSM:READY:ID=0,PAR=0,DIS=0 17 MCO:REG:NOT NEEDED 1019 GWT:TPC:IP=192.168.0.33 2023 MCO:BGN:STP MY_NODE_ID: 72024 MCO:BGN:INIT OK,TSP=1 3028 GWT:TPC:IP=192.168.0.33 4031 GWT:RMQ:MQTT RECONNECT 4287 GWT:RMQ:MQTT CONNECTED 4289 GWT:TPS:TOPIC=P/0/255/0/0/18,MSG SENT 4294 GWT:TPS:TOPIC=P/0/255/3/0/11,MSG SENT 4298 GWT:TPS:TOPIC=P/0/255/3/0/12,MSG SENT 4303 GWT:TPS:TOPIC=P/0/1/0/0/2,MSG SENT 4307 GWT:TPS:TOPIC=P/0/2/0/0/24,MSG SENT 4312 TSM:READY:NWD REQ 4349 TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: 4356 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 4361 TSF:MSG:PINGED,ID=6,HP=1 4399 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 4406 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 4411 TSF:MSG:PINGED,ID=6,HP=1 4449 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 6161 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 6166 TSF:MSG:PINGED,ID=6,HP=1 6204 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 7112 GWT:TPS:TOPIC=P/0/2/1/0/24,MSG SENT 7116 GWT:TPS:TOPIC=P/0/1/1/0/2,MSG SENT 8222 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 8227 TSF:MSG:PINGED,ID=6,HP=1 8266 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 10276 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 10281 TSF:MSG:PINGED,ID=6,HP=1 10319 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 12130 GWT:TPS:TOPIC=P/0/2/1/0/24,MSG SENT 12134 GWT:TPS:TOPIC=P/0/1/1/0/2,MSG SENT 12339 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 12344 TSF:MSG:PINGED,ID=6,HP=1 12382 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 14392 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 14397 TSF:MSG:PINGED,ID=6,HP=1 14436 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 16446 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 16451 TSF:MSG:PINGED,ID=6,HP=1 16489 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 17198 GWT:TPS:TOPIC=P/0/2/1/0/24,MSG SENT 17202 GWT:TPS:TOPIC=P/0/1/1/0/2,MSG SENT 18508 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 18513 TSF:MSG:PINGED,ID=6,HP=1 18551 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 20563 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 20568 TSF:MSG:PINGED,ID=6,HP=1 20606 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 22216 GWT:TPS:TOPIC=P/0/2/1/0/24,MSG SENT 22220 GWT:TPS:TOPIC=P/0/1/1/0/2,MSG SENT 22726 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 22730 TSF:MSG:PINGED,ID=6,HP=1 22769 !TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1
And the node output:
__ __ ____ | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ |___/ 2.3.1 16 MCO:BGN:INIT NODE,CP=RNNNA---,REL=255,VER=2.3.1 26 TSM:INIT 27 TSF:WUR:MS=0 33 TSM:INIT:TSP OK 35 TSM:INIT:STATID=6 37 TSF:SID:OK,ID=6 39 TSM:FPAR 40 TSM:FPAR:STATP=0 43 TSM:ID 44 TSM:ID:OK 45 TSM:UPL 80 !TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1 2089 TSM:UPL 2125 !TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=NACK:1 4133 TSM:UPL 4169 !TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=2,st=NACK:1 6177 TSM:UPL 6213 !TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=3,st=NACK:1 8221 !TSM:UPL:FAIL 8222 TSM:FPAR 8224 TSM:FPAR:STATP=0 8226 TSM:ID 8227 TSM:ID:OK 8228 TSM:UPL 8265 !TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=4,st=NACK:1 10272 TSM:UPL 10308 !TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=5,st=NACK:1 12316 TSM:UPL 12352 !TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=6,st=NACK:1 14360 TSM:UPL 14396 !TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=7,st=NACK:1
I'm not sure what 8221 !TSM:UPL:FAIL means. An "Uplink check failed, i.e. GW could not be pinged" ? Any ideas ?