Solved the re-connection problem by giving the MQTT broker a different and seperate IP-address, it was running on unraid´s main IP-address.
Now testing for repeating relay activation, keeping fingers crossed.
@Yveaux thx for your help.
Solved the re-connection problem by giving the MQTT broker a different and seperate IP-address, it was running on unraid´s main IP-address.
Now testing for repeating relay activation, keeping fingers crossed.
@Yveaux thx for your help.
Hi All,
This is bugging me for days now and i cant find a source.
This node measures temp and has a relais to reboot the connected device if it hangs or goes off-line.
But the relais gets activated about every minute because the node receives a command to activate the relais.
I can not figure out where that command is coming from.
I even tried running without a active controler (Home-assistant) but still the relais gets activated.
I use a MQTT gateway on a Arduino Uno with NRF24 radio and ethernet to the network.
I use Mosquitto, in a docker on unraid, as the broker.
below is the sketch i have build, tried several other sketches, same result. And the serial output from my gateway and node.
I hope there is someone who can help me getting this node working right.
/*
* MySensors Custom Door/Window Sensor, with temperature sensor
* and battery level reporting Version 2.2
*
* D.B******* 7/13/2018
*
* Version 1 - Initial concept code
* Version 2 - adds Temp/humidity/ and battery monintoring
*
* The Mysensors libraries will handle all the radio protocols
* and create the network.
*
* DO NOT USE REPEATER MODE if this is battery powered
*
* Connect one button or door/window reed switch between
* digital I/O pin 3 (BUTTON_PIN below) and GND and the other
* one in similar fashion on digital I/O pin 2.
* This example is designed to fit Arduino Nano/Pro Mini
*/
//Enble serial monitoring
#define MY_DEBUG
#define MY_MSG
//Enable radio (Im using NRLF24A)
#define MY_RADIO_NRF24
// Set manual node ID
#define MY_NODE_ID 23
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Inverses the behavior of leds
#define MY_WITH_LEDS_BLINKING_INVERSE
// Flash leds on rx/tx/err
// Uncomment to override default HW configurations
//#define MY_DEFAULT_TX_LED_PIN 6 // tramsmit led pin
#include <MyConfig.h>
#include <MySensors.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define SKETCH_NAME "Anova"
#define SKETCH_VERSION "2.0"
// Add child IDs
#define CHILD_ID_TEMP 1
#define CHILD_ID_RELAY 2
//==================================================
// RELAY - SETUP
//==================================================
#define RELAY_PIN 2 // Digital I/O pin number for the relay
#define RELAY_ON 1 // GPIO value to write to turn on attached relay
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
#define RELAY_DELAY 3000 // Time relay stays ON
//==================================================
// TEMPERATURE SENSOR - SETUP
//==================================================
#define ONE_WIRE_BUS 5 // Pin where dallase sensor is connected
#define MAX_ATTACHED_DS18B20 16 // Maximun number of atachable temperature sensors
#define NUM_TEMP_SENS 1 // Number of attached temperature sensors
#define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
// Sensor 1
float curTemp = 0;
float lastTemp = 0;
float OffsetTemp = 0; // allows for small corrections to sensor innacuracies
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
//==================================================
// GENERAL PROCESSING SETTING
//==================================================
bool curState = false;
bool newState = false;
bool initialValueSent = false;
unsigned long SLEEP_TIME = 15 * 1000; // Sleep time in sec
const int audioOut = 3; // (Digital 2) for using the peizo as an output device. (Thing that goes beep.)
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgRelay(CHILD_ID_RELAY, V_STATUS);
void before()
{
// Startup up the OneWire library
sensors.begin();
}
void setup()
{
// requestTemperatures() will not block current thread
sensors.setWaitForConversion(false);
// Set relay pins in output mode, and turn relay OFF
pinMode(RELAY_PIN, OUTPUT);
// Set relay to OFF)
digitalWrite(RELAY_PIN, RELAY_OFF);
curState = RELAY_OFF;
initialValueSent = false;
}
void presentation()
{
sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
present(CHILD_ID_TEMP, S_TEMP, "Temperature");
present(CHILD_ID_RELAY, S_BINARY, "Relay");
}
void loop()
{
/*
*==================================================
* This is the MAIN program loop
*==================================================
*/
debugMsg("Loop - Start");
if (!initialValueSent) {
debugMsg("Sending initial value");
send(msgRelay.set(curState?RELAY_ON:RELAY_OFF));
debugMsg("Requesting initial value from controller");
request(CHILD_ID_RELAY, V_STATUS);
//wait(2000, C_SET, V_STATUS);
}
debugMsg("curState / newState - " + String(curState) + " / " + String(newState));
if (newState != curState) {
curState = RELAY_ON;
digitalWrite(RELAY_PIN, curState);
send(msgRelay.set(curState));
wait(RELAY_DELAY);
curState = RELAY_OFF;
digitalWrite(RELAY_PIN, RELAY_OFF);
send(msgRelay.set(curState));
newState=curState;
}
//==================================================
// Read temp sensor and send them to controller
//==================================================
sensors.requestTemperatures();
// query conversion time and sleep until conversion completed
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
//debugMsg("conversionTime: " + String(conversionTime) + " mSec");
wait(conversionTime);
// Fetch and round temperature to one decimal
curTemp = static_cast<float>(static_cast<int>((sensors.getTempCByIndex(0)) * 10.)) / 10.;
// Only send data if temperature sensor has changed and no error
if (curTemp!= lastTemp) {
debugMsg("Sending: Temerature: "+ String(curTemp));
send(msgTemp.set(curTemp,1));
lastTemp = curTemp;
}
//==================================================
// Sleep until something happens with the sensor
//==================================================
debugMsg("Sleep - Start");
wait(SLEEP_TIME);
}
void receive(const MyMessage &message) {
debugMsg("Received: type / payload / ack : " + String(message.type) + " / " + String(message.getInt()) + " / " + String(message.isAck()));
if (message.isAck()) {
debugMsg("This is an ack from gateway");
}
if (message.type == V_STATUS) {
if (!initialValueSent) {
debugMsg("Receiving initial value from controller");
initialValueSent = true;
curState = (bool)message.getInt();
}
// Change relay state
chirp(500, 1000);
chirp(500, 1500);
newState = (bool)message.getInt();
if (newState == RELAY_ON) {
debugMsg("Changing relay state to: ON");
}
}
}
/*
*==================================================
*
* Room for various FUNCTIONS
*
*==================================================
*/
//=========================
// Send Debug message - FUNCTION
//=========================
void debugMsg(String message)
{
#ifdef MY_MSG
Serial.println(message);
#endif
}
//=========================
// Plays a non-musical tone on the piezo.
// playTime = milliseconds to play the tone
// delayTime = time in microseconds between ticks. (smaller=higher pitch tone.)
//=========================
void chirp(int playTime, int delayTime)
{
long loopTime = (playTime * 1000L) / delayTime;
pinMode(audioOut, OUTPUT);
for(int i=0; i < loopTime; i++) {
digitalWrite(audioOut, HIGH);
delayMicroseconds(delayTime);
digitalWrite(audioOut, LOW);
}
pinMode(audioOut, INPUT);
}
This is the serial output of my MQTT Gateway
11:49:45.192 -> 0 MCO:BGN:INIT GW,CP=RNNGA---,FQ=16,REL=255,VER=2.3.2
11:49:45.192 -> 4 MCO:BGN:BFR
11:49:45.192 -> 6 TSM:INIT
11:49:45.192 -> 7 TSF:WUR:MS=0
11:49:45.192 -> 13 TSM:INIT:TSP OK
11:49:45.192 -> 15 TSM:INIT:GW MODE
11:49:45.192 -> 16 TSM:READY:ID=0,PAR=0,DIS=0
11:49:45.230 -> 19 MCO:REG:NOT NEEDED
11:49:49.894 -> 4698 GWT:TPC:IP=192.168.28.111
11:49:50.921 -> 5701 MCO:BGN:STP
11:49:50.921 -> 5702 MCO:BGN:INIT OK,TSP=1
11:49:51.029 -> 5814 GWT:TPC:IP=192.168.28.111
11:49:52.021 -> 6816 GWT:RMQ:CONNECTING...
11:49:52.021 -> 6821 GWT:RMQ:OK
11:49:52.021 -> 6823 GWT:TPS:TOPIC=mysgw-out/0/255/0/0/18,MSG SENT
11:49:52.021 -> 6829 TSM:READY:NWD REQ
11:49:52.021 -> 6834 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
11:49:52.054 -> 6841 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:0
11:49:52.054 -> 6846 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:49:52.054 -> 6852 GWT:IMQ:TOPIC=mysgw-in/23/255/3/0/6, MSG RECEIVED
11:49:52.054 -> 6859 TSF:MSG:SEND,0-0-23-23,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
11:49:52.054 -> 6866 GWT:IMQ:TOPIC=mysgw-in/23/2/1/0/2, MSG RECEIVED
11:49:52.089 -> 6874 TSF:MSG:SEND,0-0-23-23,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:0
11:49:52.089 -> 6881 GWT:IMQ:TOPIC=mysgw-in/23/2/1/1/2, MSG RECEIVED
11:49:52.089 -> 6887 TSF:MSG:SEND,0-0-23-23,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:1
11:49:52.089 -> 6895 GWT:IMQ:TOPIC=mysgw-in/31/255/3/0/6, MSG RECEIVED
11:49:52.122 -> 6935 !TSF:MSG:SEND,0-0-31-31,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M
11:49:52.158 -> 6943 GWT:IMQ:TOPIC=mysgw-in/31/2/1/1/2, MSG RECEIVED
11:49:52.192 -> 6983 !TSF:MSG:SEND,0-0-31-31,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:1
11:49:53.123 -> 7914 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=0,l=1,sg=0:1
11:49:53.123 -> 7919 TSF:MSG:ECHO
11:49:53.123 -> 7921 GWT:TPS:TOPIC=mysgw-out/23/2/1/1/2,MSG SENT
11:50:02.263 -> 17032 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:1
11:50:02.263 -> 17037 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:50:05.254 -> 20047 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:0
11:50:05.287 -> 20052 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:50:11.877 -> 26659 TSF:MSG:READ,23-23-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
11:50:11.915 -> 26665 TSF:MSG:BC
11:50:11.915 -> 26667 TSF:MSG:FPAR REQ,ID=23
11:50:11.915 -> 26670 TSF:PNG:SEND,TO=0
11:50:11.915 -> 26672 TSF:CKU:OK
11:50:11.915 -> 26674 TSF:MSG:GWL OK
11:50:11.953 -> 26729 TSF:MSG:SEND,0-0-23-23,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
11:50:13.906 -> 28682 TSF:MSG:READ,23-23-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
<<< I DID RESTART NODE 23 HERE >>>
11:50:13.906 -> 28687 TSF:MSG:PINGED,ID=23,HP=1
11:50:13.939 -> 28692 TSF:MSG:SEND,0-0-23-23,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
11:50:13.939 -> 28707 TSF:MSG:READ,23-23-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
11:50:13.939 -> 28715 TSF:MSG:SEND,0-0-23-23,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
11:50:13.972 -> 28724 TSF:MSG:READ,23-23-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.2
11:50:13.972 -> 28730 GWT:TPS:TOPIC=mysgw-out/23/255/0/0/17,MSG SENT
11:50:13.972 -> 28735 TSF:MSG:READ,23-23-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
11:50:13.972 -> 28741 GWT:TPS:TOPIC=mysgw-out/23/255/3/0/6,MSG SENT
11:50:15.969 -> 30748 TSF:MSG:READ,23-23-0,s=255,c=3,t=11,pt=0,l=5,sg=0:Anova
11:50:16.005 -> 30754 GWT:TPS:TOPIC=mysgw-out/23/255/3/0/11,MSG SENT
11:50:16.005 -> 30759 TSF:MSG:READ,23-23-0,s=255,c=3,t=12,pt=0,l=3,sg=0:2.0
11:50:16.005 -> 30766 GWT:TPS:TOPIC=mysgw-out/23/255/3/0/12,MSG SENT
11:50:16.005 -> 30771 TSF:MSG:READ,23-23-0,s=1,c=0,t=6,pt=0,l=11,sg=0:Temperature
11:50:16.005 -> 30777 GWT:TPS:TOPIC=mysgw-out/23/1/0/0/6,MSG SENT
11:50:16.005 -> 30782 TSF:MSG:READ,23-23-0,s=2,c=0,t=3,pt=0,l=5,sg=0:Relay
11:50:16.043 -> 30788 GWT:TPS:TOPIC=mysgw-out/23/2/0/0/3,MSG SENT
11:50:16.043 -> 30793 TSF:MSG:READ,23-23-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
11:50:16.043 -> 30800 TSF:MSG:SEND,0-0-23-23,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
11:50:16.043 -> 30816 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=2,l=2,sg=0:0
11:50:16.043 -> 30821 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:50:16.081 -> 30826 TSF:MSG:READ,23-23-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
11:50:16.081 -> 30831 GWT:TPS:TOPIC=mysgw-out/23/2/2/0/2,MSG SENT
11:50:16.188 -> 30936 TSF:MSG:READ,23-23-0,s=1,c=1,t=0,pt=7,l=5,sg=0:-127.0
11:50:16.188 -> 30941 GWT:TPS:TOPIC=mysgw-out/23/1/1/0/0,MSG SENT
11:50:31.227 -> 45982 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=2,l=2,sg=0:0
11:50:31.264 -> 45988 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:50:31.264 -> 45992 TSF:MSG:READ,23-23-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
11:50:31.264 -> 45998 GWT:TPS:TOPIC=mysgw-out/23/2/2/0/2,MSG SENT
11:51:10.160 -> 84851 GWT:TPC:IP=192.168.28.111
11:51:11.161 -> 85855 GWT:RMQ:CONNECTING...
11:51:11.199 -> 85860 GWT:RMQ:OK
11:51:11.199 -> 85862 GWT:TPS:TOPIC=mysgw-out/0/255/0/0/18,MSG SENT
11:51:11.199 -> 85867 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=2,l=2,sg=0:0
11:51:11.199 -> 85872 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:51:11.199 -> 85877 TSF:MSG:READ,23-23-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
11:51:11.199 -> 85882 GWT:TPS:TOPIC=mysgw-out/23/2/2/0/2,MSG SENT
11:51:11.199 -> 85888 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=2,l=2,sg=0:0
11:51:11.199 -> 85893 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:51:11.235 -> 85900 GWT:IMQ:TOPIC=mysgw-in/23/255/3/0/6, MSG RECEIVED
11:51:11.235 -> 85906 TSF:MSG:SEND,0-0-23-23,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
11:51:11.235 -> 85914 GWT:IMQ:TOPIC=mysgw-in/23/2/1/0/2, MSG RECEIVED
11:51:11.235 -> 85920 TSF:MSG:SEND,0-0-23-23,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:0
11:51:11.235 -> 85928 GWT:IMQ:TOPIC=mysgw-in/23/2/1/1/2, MSG RECEIVED
11:51:11.272 -> 85935 TSF:MSG:SEND,0-0-23-23,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:1
11:51:11.272 -> 85942 GWT:IMQ:TOPIC=mysgw-in/31/255/3/0/6, MSG RECEIVED
11:51:11.307 -> 85983 !TSF:MSG:SEND,0-0-31-31,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M
11:51:11.307 -> 85991 GWT:IMQ:TOPIC=mysgw-in/31/2/1/1/2, MSG RECEIVED
11:51:11.342 -> 86032 !TSF:MSG:SEND,0-0-31-31,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:1
11:51:12.294 -> 86963 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=0,l=1,sg=0:1
11:51:12.294 -> 86968 TSF:MSG:ECHO
11:51:12.294 -> 86970 GWT:TPS:TOPIC=mysgw-out/23/2/1/1/2,MSG SENT
11:51:16.807 -> 91473 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:1
11:51:16.807 -> 91479 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:51:19.821 -> 94490 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:0
11:51:19.821 -> 94495 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:52:38.781 -> 163580 GWT:TPC:IP=192.168.28.111
11:52:38.781 -> 164583 GWT:RMQ:CONNECTING...
11:52:38.781 -> 164588 GWT:RMQ:OK
11:52:38.781 -> 164590 GWT:TPS:TOPIC=mysgw-out/0/255/0/0/18,MSG SENT
11:52:38.781 -> 164598 GWT:IMQ:TOPIC=mysgw-in/23/255/3/0/6, MSG RECEIVED
11:52:38.781 -> 164605 TSF:MSG:SEND,0-0-23-23,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
11:52:38.781 -> 164614 GWT:IMQ:TOPIC=mysgw-in/23/2/1/0/2, MSG RECEIVED
11:52:38.781 -> 164620 TSF:MSG:SEND,0-0-23-23,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:0
11:52:38.781 -> 164628 GWT:IMQ:TOPIC=mysgw-in/23/2/1/1/2, MSG RECEIVED
11:52:38.781 -> 164634 TSF:MSG:SEND,0-0-23-23,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:1
11:52:38.781 -> 164642 GWT:IMQ:TOPIC=mysgw-in/31/255/3/0/6, MSG RECEIVED
11:52:38.781 -> 164683 !TSF:MSG:SEND,0-0-31-31,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M
11:52:38.781 -> 164691 GWT:IMQ:TOPIC=mysgw-in/31/2/1/1/2, MSG RECEIVED
11:52:38.781 -> 164731 !TSF:MSG:SEND,0-0-31-31,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:1
11:52:38.781 -> 165661 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=0,l=1,sg=0:1
11:52:38.781 -> 165666 TSF:MSG:ECHO
11:52:38.781 -> 165668 GWT:TPS:TOPIC=mysgw-out/23/2/1/1/2,MSG SENT
11:52:38.781 -> 170158 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:1
11:52:38.781 -> 170163 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:52:38.781 -> 173173 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:0
11:52:38.814 -> 173178 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:53:48.684 -> 242311 GWT:TPC:IP=192.168.28.111
11:53:48.861 -> 243313 GWT:RMQ:CONNECTING...
11:53:48.861 -> 243318 GWT:RMQ:OK
11:53:48.897 -> 243320 GWT:TPS:TOPIC=mysgw-out/0/255/0/0/18,MSG SENT
11:53:48.897 -> 243329 GWT:IMQ:TOPIC=mysgw-in/23/255/3/0/6, MSG RECEIVED
11:53:48.897 -> 243338 TSF:MSG:SEND,0-0-23-23,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
11:53:48.897 -> 243345 GWT:IMQ:TOPIC=mysgw-in/23/2/1/0/2, MSG RECEIVED
11:53:48.897 -> 243352 TSF:MSG:SEND,0-0-23-23,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:0
11:53:48.932 -> 243359 GWT:IMQ:TOPIC=mysgw-in/23/2/1/1/2, MSG RECEIVED
11:53:48.932 -> 243373 TSF:MSG:SEND,0-0-23-23,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:1
11:53:48.932 -> 243381 GWT:IMQ:TOPIC=mysgw-in/31/255/3/0/6, MSG RECEIVED
11:53:48.968 -> 243422 !TSF:MSG:SEND,0-0-31-31,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M
11:53:49.003 -> 243430 GWT:IMQ:TOPIC=mysgw-in/31/2/1/1/2, MSG RECEIVED
11:53:49.040 -> 243470 !TSF:MSG:SEND,0-0-31-31,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:1
11:53:49.966 -> 244392 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=0,l=1,sg=0:1
11:53:49.966 -> 244398 TSF:MSG:ECHO
11:53:49.966 -> 244400 GWT:TPS:TOPIC=mysgw-out/23/2/1/1/2,MSG SENT
11:53:54.413 -> 248843 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:1
11:53:54.413 -> 248848 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
11:53:57.431 -> 251873 TSF:MSG:READ,23-23-0,s=2,c=1,t=2,pt=1,l=1,sg=0:0
11:53:57.465 -> 251878 GWT:TPS:TOPIC=mysgw-out/23/2/1/0/2,MSG SENT
This is the serial output of my node
11:56:52.249 ->
11:56:52.249 -> __ __ ____
11:56:52.249 -> | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___
11:56:52.249 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
11:56:52.249 -> | | | | |_| |___| | __/ | | \__ \ _ | | \__ \
11:56:52.249 -> |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/
11:56:52.249 -> |___/ 2.3.2
11:56:52.249 ->
11:56:52.249 -> 16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=8,REL=255,VER=2.3.2
11:56:52.285 -> 28 MCO:BGN:BFR
11:56:52.285 -> 30 TSM:INIT
11:56:52.285 -> 32 TSF:WUR:MS=0
11:56:52.285 -> 38 TSM:INIT:TSP OK
11:56:52.285 -> 40 TSM:INIT:STATID=23
11:56:52.285 -> 43 TSF:SID:OK,ID=23
11:56:52.285 -> 45 TSM:FPAR
11:56:52.285 -> 49 ?TSF:MSG:SEND,23-23-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
11:56:54.288 -> 2058 !TSM:FPAR:NO REPLY
11:56:54.288 -> 2060 TSM:FPAR
11:56:54.324 -> 2064 ?TSF:MSG:SEND,23-23-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
11:56:54.776 -> 2533 TSF:MSG:READ,0-0-23,s=255,c=3,t=8,pt=1,l=1,sg=0:0
11:56:54.776 -> 2539 TSF:MSG:FPAR OK,ID=0,D=1
11:56:56.331 -> 4073 TSM:FPAR:OK
11:56:56.331 -> 4073 TSM:ID
11:56:56.331 -> 4075 TSM:ID:OK
11:56:56.331 -> 4077 TSM:UPL
11:56:56.331 -> 4081 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
11:56:56.331 -> 4089 TSF:MSG:READ,0-0-23,s=255,c=3,t=25,pt=1,l=1,sg=0:1
11:56:56.331 -> 4096 TSF:MSG:PONG RECV,HP=1
11:56:56.364 -> 4100 TSM:UPL:OK
11:56:56.364 -> 4102 TSM:READY:ID=23,PAR=0,DIS=1
11:56:56.364 -> 4106 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
11:56:56.364 -> 4114 TSF:MSG:READ,0-0-23,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
11:56:56.364 -> 4122 TSF:MSG:SEND,23-23-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
11:56:56.399 -> 4132 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
11:56:58.414 -> 6141 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=11,pt=0,l=5,sg=0,ft=0,st=OK:Anova
11:56:58.414 -> 6152 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:2.0
11:56:58.414 -> 6162 TSF:MSG:SEND,23-23-0-0,s=1,c=0,t=6,pt=0,l=11,sg=0,ft=0,st=OK:Temperature
11:56:58.451 -> 6174 TSF:MSG:SEND,23-23-0-0,s=2,c=0,t=3,pt=0,l=5,sg=0,ft=0,st=OK:Relay
11:56:58.451 -> 6180 MCO:REG:REQ
11:56:58.451 -> 6184 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
11:56:58.451 -> 6195 TSF:MSG:READ,0-0-23,s=255,c=3,t=27,pt=1,l=1,sg=0:1
11:56:58.451 -> 6201 MCO:PIM:NODE REG=1
11:56:58.451 -> 6203 MCO:BGN:STP
11:56:58.451 -> 6205 MCO:BGN:INIT OK,TSP=1
11:56:58.489 -> Loop - Start
11:56:58.489 -> Sending initial value
11:56:58.489 -> 6211 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
11:56:58.489 -> Requesting initial value from controller
11:56:58.489 -> 6221 TSF:MSG:SEND,23-23-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
11:56:58.489 -> curState / newState - 0 / 0
11:56:58.589 -> Sending: Temerature: -127.00
11:56:58.589 -> 6330 TSF:MSG:SEND,23-23-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:-127.0
11:56:58.589 -> Sleep - Start
11:57:13.672 -> Loop - Start
11:57:13.672 -> Sending initial value
11:57:13.672 -> 21340 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
11:57:13.672 -> Requesting initial value from controller
11:57:13.672 -> 21350 TSF:MSG:SEND,23-23-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
11:57:13.672 -> curState / newState - 0 / 0
11:57:13.781 -> Sleep - Start
11:57:28.841 -> Loop - Start
11:57:28.841 -> Sending initial value
11:57:28.841 -> 36456 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
11:57:28.841 -> Requesting initial value from controller
11:57:28.841 -> 36466 TSF:MSG:SEND,23-23-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
11:57:28.877 -> curState / newState - 0 / 0
11:57:28.948 -> Sleep - Start
11:57:44.011 -> Loop - Start
11:57:44.011 -> Sending initial value
11:57:44.011 -> 51574 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
11:57:44.011 -> Requesting initial value from controller
11:57:44.049 -> 51617 !TSF:MSG:SEND,23-23-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=NACK:
11:57:44.086 -> curState / newState - 0 / 0
11:57:44.155 -> Sleep - Start
11:57:48.013 -> 55564 TSF:MSG:READ,0-0-23,s=255,c=3,t=6,pt=0,l=1,sg=0:M
11:57:48.013 -> 55580 TSF:MSG:READ,0-0-23,s=2,c=1,t=2,pt=0,l=1,sg=0:0
11:57:48.046 -> Received: type / payload / ack : 2 / 0 / 0
11:57:48.046 -> Receiving initial value from controller
11:57:49.049 -> 56608 TSF:MSG:READ,0-0-23,s=2,c=1,t=2,pt=0,l=1,sg=0:1
11:57:49.049 -> 56614 TSF:MSG:ECHO REQ
11:57:49.086 -> 56619 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=1,st=OK:1
11:57:49.086 -> Received: type / payload / ack : 2 / 1 / 0
11:57:50.107 -> Changing relay state to: ON
11:57:59.204 -> Loop - Start
11:57:59.204 -> curState / newState - 0 / 1
11:57:59.204 -> 66727 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1
11:58:02.235 -> 69736 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
11:58:02.344 -> Sleep - Start
11:58:17.408 -> Loop - Start
11:58:17.408 -> curState / newState - 0 / 0
11:58:17.511 -> Sleep - Start
11:58:32.565 -> Loop - Start
11:58:32.565 -> curState / newState - 0 / 0
11:58:32.672 -> Sleep - Start
11:58:47.726 -> Loop - Start
11:58:47.726 -> curState / newState - 0 / 0
11:58:47.831 -> Sleep - Start
11:59:02.870 -> Loop - Start
11:59:02.870 -> curState / newState - 0 / 0
11:59:02.975 -> Sleep - Start
11:59:06.834 -> 134098 TSF:MSG:READ,0-0-23,s=255,c=3,t=6,pt=0,l=1,sg=0:M
11:59:06.872 -> 134113 TSF:MSG:READ,0-0-23,s=2,c=1,t=2,pt=0,l=1,sg=0:0
11:59:06.872 -> Received: type / payload / ack : 2 / 0 / 0
11:59:07.891 -> 135141 TSF:MSG:READ,0-0-23,s=2,c=1,t=2,pt=0,l=1,sg=0:1
11:59:07.891 -> 135147 TSF:MSG:ECHO REQ
11:59:07.891 -> 135151 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:1
11:59:07.926 -> Received: type / payload / ack : 2 / 1 / 0
11:59:08.946 -> Changing relay state to: ON
11:59:18.033 -> Loop - Start
11:59:18.033 -> curState / newState - 0 / 1
11:59:18.033 -> 145229 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1
11:59:21.052 -> 148238 TSF:MSG:SEND,23-23-0-0,s=2,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
11:59:21.160 -> Sleep - Start
Hi all,
I am trying to get a MRKZero and a W5100 Ethernet module working as a gateway, but its not working.
Tried as a first step to get a web-server running on this combo, but the sketch reports "Ethernet shield not found".
If i get the web-server running i should be able to get the Ethernet gateway running too.
I seen lots of samples and instructions for the Arduino UNO, but am not able to translate these to the MKRZero.
I hope there is someone who can help me with this.
Connections between the Arduino and the Ethernet modul:
W5100 MKRZero
1 GND GND
2 5V 5V
3 Reset
4 SS ???
5 SCK SCK
6 MOSI MOSI
7 MISO MISO
8 GND
9 POE+
10 POE-
Code:
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
modified 02 Sept 2015
by Arturo Guadalupi
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 28, 177);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup() {
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(7); // Most Arduino shields
//Ethernet.init(5); // MKR ETH shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Ethernet WebServer Example");
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
// start the server
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("<br />");
}
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
For future reference,
I was checking the myconfig.h file and found some variable definition regarding the NRF24 radio.
There were two variables referencing the CE and CS pin.
/**
* @def MY_RF24_CE_PIN
* @brief Define this to change the chip enable pin from the default.
*/
#ifndef MY_RF24_CE_PIN
#define MY_RF24_CE_PIN (DEFAULT_RF24_CE_PIN)
#endif
/**
* @def MY_RF24_CS_PIN
* @brief Define this to change the chip select pin from the default.
*/
#ifndef MY_RF24_CS_PIN
#define MY_RF24_CS_PIN (DEFAULT_RF24_CS_PIN)
#endif
I have set these two variables in my sketch for my MRKZERO and got the radio working.
Problem Solved
Hi All,
I can not figure out how to connect the nrf24 radio to my Arduino mrknano.
nrf24 mrkNano
GND gnd
VCC vcc
CE ?
CSN/CS ?
SCK 7
COPI/MOSI 8
CIPO/MISO 10
IRQ 2
Where do i connect the CE and CSN pins to ??
Thx.
Rob.