Posts made by Mike Cayouette
-
RE: [SOLVED] Timers and Interrupts not being triggered
@Yveaux I solved the problem.
The issue was not my sketch, but rather my ESP8266 MQTT Gateway. I was using an older development version. After upgrading to version 2.0 everything started working. Thankfully my older nodes, using the older development version, are still working, I will upgrade them over time.
This is my final sketch:
#define MY_DEBUG #define MY_RADIO_NRF24 #define MY_NODE_ID 300 #define SN "ACDimmer" #define SV "1.0" #define AC1_ID 1 #define FADE_DELAY 18 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim) #include <TimerOne.h> #include <SPI.h> #include <MySensors.h> MyMessage dimmerMsg(AC1_ID, V_DIMMER); volatile int i=0; // Variable to use as a counter volatile as it is in an interrupt volatile boolean zero_cross=0; // Boolean to store a "switch" to tell us if we have crossed zero int AC_pin = 4; // Output to Opto Triac int intPin = 3; int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff int inc=1; // counting up or down, 1=up, -1=down int freqStep = 65; // This is the delay-per-brightness step in microseconds. unsigned long previousMillis = 0; // will store last time LED was updated unsigned long currentMillis = 0; int currentLevel = 0; int requestedLevel = 0; void before() { #ifdef MY_DEBUG Serial.println("Dimmer Node Starting"); #endif pinMode(AC_pin, OUTPUT); // Set the Triac pin as output attachInterrupt(digitalPinToInterrupt(intPin), zero_cross_detect, RISING); // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection Timer1.initialize(freqStep); // Initialize TimerOne library for the freq we need Timer1.attachInterrupt(dim_check, freqStep); } void setup() { // Begin setup } void presentation() { present( AC1_ID, S_DIMMER ); sendSketchInfo(SN, SV); } void zero_cross_detect() { zero_cross = true; // set the boolean to true to tell our dimming function that a zero cross has occured i=0; digitalWrite(AC_pin, LOW); // turn off TRIAC (and AC) } // Turn on the TRIAC at the appropriate time void dim_check() { if(zero_cross == true) { if(i>=currentLevel) { digitalWrite(AC_pin, HIGH); // turn on light i=0; // reset time step counter zero_cross = false; //reset zero cross detection } else { i++; // increment time step counter } } } void loop() { } void receive(const MyMessage &message) { #ifdef MY_DEBUG Serial.print("Message: "); Serial.println(message.type); Serial.print("Message Data: "); Serial.println(message.data); #endif if (message.type == 3) { int requestedLevel = map(atoi( message.data ), 0, 100, 128, 0); //128 = off | 0 = ON while (currentLevel != requestedLevel) { if(currentLevel<=requestedLevel) inc=1; if(currentLevel>=requestedLevel) inc=-1; currentLevel+=inc; #ifdef MY_DEBUG Serial.print("Current Level:"); Serial.println(String(currentLevel)); #endif //delay currentMillis = previousMillis = millis(); while (currentMillis - previousMillis < FADE_DELAY) { currentMillis = millis(); } } } }
There is still one error though. When I try to set my own node id using #define MY_NODE_ID 300, I get the following error:
In file included from /home/sketchbook/libraries/MySensors/MySensors.h:253:0, from /home/sketchbook/ACDimmer_Test/ACDimmer_Test.ino:11: /home/sketchbook/libraries/MySensors/core/MyTransport.cpp: In function 'void stInitTransition()': /home/sketchbook/libraries/MySensors/core/MyTransport.cpp:74:16: warning: large integer implicitly truncated to unsigned type [-Woverflow] _nc.nodeId = MY_NODE_ID; ^ In file included from /home/sketchbook/libraries/MySensors/core/MyHwATMega328.cpp:22:0, from /home/sketchbook/libraries/MySensors/MySensors.h:69, from /home/sketchbook/ACDimmer_Test/ACDimmer_Test.ino:11: /home/sketchbook/libraries/MySensors/core/MyHwATMega328.h:69:88: warning: large integer implicitly truncated to unsigned type [-Woverflow] #define hwWriteConfig(__pos, __value) (eeprom_update_byte((uint8_t*)(__pos), (__value))) ^ /home/sketchbook/libraries/MySensors/core/MyTransport.cpp:76:5: note: in expansion of macro 'hwWriteConfig' hwWriteConfig(EEPROM_NODE_ID_ADDRESS, MY_NODE_ID);
I was able to set my own node id's in the older development version but it does not seem to work now.
Thank you for all your help.
Mike
-
RE: [SOLVED] Timers and Interrupts not being triggered
@Yveaux I find it hard to believe that the radio is not initialized. My MQTT server receives the following when I have the node running:
mymqtt-out/44/255/3/0/24
I modified the sketch and add the following receive method
void receive(const MyMessage &message) { Serial.print("Message: "); Serial.println(message.type); Serial.print("Message Data: "); Serial.println(message.data); }
when I send a payload of 50 to mymqtt-in/44/1/1/0/3, the serial output shows the following:
Dim Sketch started Message: 3 Message Data: 50
I would think if the radio is not initialized this would not be possible.
My debug output is below:
Dim Sketch started Starting sensor (RNNNA-, 2.0.0) TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=44) TSM:FPAR TSP:MSG:SEND 44-44-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSP:MSG:READ 0-0-44 s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSP:MSG:FPAR RES (ID=0, dist=0) TSP:MSG:PAR OK (ID=0, dist=1) TSM:FPAR:OK TSM:ID TSM:CHKID:OK (ID=44) TSM:UPL TSP:PING:SEND (dest=0) TSP:MSG:SEND 44-44-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1 TSP:CHKUPL:FAIL (hops=255) !TSM:UPL:FAIL TSM:FPAR TSP:MSG:SEND 44-44-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSP:MSG:READ 0-0-44 s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSP:MSG:FPAR RES (ID=0, dist=0) TSP:MSG:PAR OK (ID=0, dist=1) TSM:FPAR:OK TSM:ID
I remember in the past when the radio would not initialize it said radio init failed or something like that.
Thank you,
Mike
-
RE: [SOLVED] Timers and Interrupts not being triggered
@Yveaux There is still something odd happening. This is now my basic sketch
//#define MY_DEBUG #define MY_RADIO_NRF24 //#define MY_NODE_ID 300 #define SN "ACDimmer" #define SV "1.0" #include <SPI.h> #include <MySensors.h> unsigned long previousMillis = 0; unsigned long currentMillis = 0; int AC1_ID = 1; int SET_DELAY = 300; MyMessage dimmerMsg(AC1_ID, V_DIMMER); void before() { Serial.begin( 115200 ); Serial.println("Dim Sketch started"); } void setup() { // Begin setup } void presentation() { // Register the LED Dimmable Light with the gateway present( AC1_ID, S_DIMMER ); sendSketchInfo(SN, SV); } void loop() { Serial.println("Loop"); if (currentMillis - previousMillis > SET_DELAY) { send( dimmerMsg.set("Message From Dimmer") ); previousMillis = millis(); } currentMillis = millis(); }
I get the output that is in the before() method, but what I have in the loop is not output at all. Its as if loop is not running at all.
Mike
-
RE: [SOLVED] Timers and Interrupts not being triggered
@TheoL I tried that also but I thought that was not needed if MY_DEBUG was defined. In any case, event with Serial.begin( 115200 ) it still does not work.
I did notice the following 2 errors in the debug output, one after the other.
TSP:CHKUPL:FAIL (hops=255) !TSM:UPL:FAIL
but I see my sensor registered on my MQTT server.
Thank you,
Mike
-
RE: [SOLVED] Timers and Interrupts not being triggered
@Yveaux There is something wrong with the Serial print command. I have the most basic of sketches below but I see none on the Serial.println() output, but I get all the debug output.
#define MY_DEBUG #define MY_RADIO_NRF24 #define SN "ACDimmer" #define SV "1.0" #include <SPI.h> #include <MySensors.h> int AC1_ID = 1; MyMessage dimmerMsg(AC1_ID, V_DIMMER); void setup() { // Begin setup Serial.println("Dim Sketch started"); } void presentation() { // Register the LED Dimmable Light with the gateway present( AC1_ID, S_DIMMER ); sendSketchInfo(SN, SV); } void loop() { Serial.println("Loop"); }
what am I doing wrong?
Mike
-
RE: [SOLVED] Timers and Interrupts not being triggered
@Yveaux How can I get Serial.println to work? I'm using the new 2.0 library and I have a few Serail.println() command in various places, including in void setup(), but I am not getting any output on the serial monitor except for all the debug data.
Sketch with serial output:
/*AC Light Control Updated by Robert Twomey Changed zero-crossing detection to look for RISING edge rather than falling. (originally it was only chopping the negative half of the AC wave form). Also changed the dim_check() to turn on the Triac, leaving it on until the zero_cross_detect() turn's it off. Adapted from sketch by Ryan McLaughlin http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230333861/30 */ #define MY_DEBUG #define MY_RADIO_NRF24 #define MY_NODE_ID 300 #define SN "ACDimmer" #define SV "1.0" #define AC1_ID 1 #include <MySensors.h> #include <SPI.h> #include <TimerOne.h> // Avaiable from http://www.arduino.cc/playground/Code/Timer1 volatile int i=0; // Variable to use as a counter volatile as it is in an interrupt volatile boolean zero_cross=0; // Boolean to store a "switch" to tell us if we have crossed zero int AC_pin = 4; // Output to Opto Triac int interruptPin = 3; int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff int inc=1; // counting up or down, 1=up, -1=down int freqStep = 65; // This is the delay-per-brightness step in microseconds. // For 60 Hz it should be 65 MyMessage dimmerMsg(AC1_ID, V_DIMMER); void setup() { // Begin setup Serial.println("Dim Sketch started"); pinMode(AC_pin, OUTPUT); // Set the Triac pin as output attachInterrupt(digitalPinToInterrupt(interruptPin), zero_cross_detect, RISING); // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection Timer1.initialize(freqStep); // Initialize TimerOne library for the freq we need Timer1.attachInterrupt(dim_check, freqStep); } void presentation() { // Register the LED Dimmable Light with the gateway present( AC1_ID, S_DIMMER ); sendSketchInfo(SN, SV); } void zero_cross_detect() { Serial.println("Zero Cross"); zero_cross = true; // set the boolean to true to tell our dimming function that a zero cross has occured i=0; digitalWrite(AC_pin, LOW); // turn off TRIAC (and AC) } // Turn on the TRIAC at the appropriate time void dim_check() { Serial.println("Dim Check"); if(zero_cross == true) { if(i>=dim) { digitalWrite(AC_pin, HIGH); // turn on light i=0; // reset time step counter zero_cross = false; //reset zero cross detection } else { i++; // increment time step counter } } } void loop() { Serial.print("Dim value: "); Serial.println(String(dim)); dim+=inc; if((dim>=128) || (dim<=0)) inc*=-1; delay(18); }
-
RE: [SOLVED] Timers and Interrupts not being triggered
Just to be clear, below is the exact sketch that I used, i added the digitalPinToInterrupt() to the sketch.
/*AC Light Control Updated by Robert Twomey Changed zero-crossing detection to look for RISING edge rather than falling. (originally it was only chopping the negative half of the AC wave form). Also changed the dim_check() to turn on the Triac, leaving it on until the zero_cross_detect() turn's it off. Adapted from sketch by Ryan McLaughlin http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230333861/30 */ #include <TimerOne.h> // Avaiable from http://www.arduino.cc/playground/Code/Timer1 volatile int i=0; // Variable to use as a counter volatile as it is in an interrupt volatile boolean zero_cross=0; // Boolean to store a "switch" to tell us if we have crossed zero int AC_pin = 4; // Output to Opto Triac int interruptPin = 3; int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff int inc=1; // counting up or down, 1=up, -1=down int freqStep = 65; // This is the delay-per-brightness step in microseconds. // For 60 Hz it should be 65 // It is calculated based on the frequency of your voltage supply (50Hz or 60Hz) // and the number of brightness steps you want. // // Realize that there are 2 zerocrossing per cycle. This means // zero crossing happens at 120Hz for a 60Hz supply or 100Hz for a 50Hz supply. // To calculate freqStep divide the length of one full half-wave of the power // cycle (in microseconds) by the number of brightness steps. // // (120 Hz=8333uS) / 128 brightness steps = 65 uS / brightness step // (100Hz=10000uS) / 128 steps = 75uS/step void setup() { // Begin setup pinMode(AC_pin, OUTPUT); // Set the Triac pin as output attachInterrupt(digitalPinToInterrupt(interruptPin), zero_cross_detect, RISING); // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection Timer1.initialize(freqStep); // Initialize TimerOne library for the freq we need Timer1.attachInterrupt(dim_check, freqStep); // Use the TimerOne Library to attach an interrupt // to the function we use to check to see if it is // the right time to fire the triac. This function // will now run every freqStep in microseconds. } void zero_cross_detect() { zero_cross = true; // set the boolean to true to tell our dimming function that a zero cross has occured i=0; digitalWrite(AC_pin, LOW); // turn off TRIAC (and AC) } // Turn on the TRIAC at the appropriate time void dim_check() { if(zero_cross == true) { if(i>=dim) { digitalWrite(AC_pin, HIGH); // turn on light i=0; // reset time step counter zero_cross = false; //reset zero cross detection } else { i++; // increment time step counter } } } void loop() { dim+=inc; if((dim>=128) || (dim<=0)) inc*=-1; delay(18); }
The above sketch works as intended. When I add the mysensors library to the sketch, as I did below, the triac never gets triggered.
/*AC Light Control Updated by Robert Twomey Changed zero-crossing detection to look for RISING edge rather than falling. (originally it was only chopping the negative half of the AC wave form). Also changed the dim_check() to turn on the Triac, leaving it on until the zero_cross_detect() turn's it off. Adapted from sketch by Ryan McLaughlin http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230333861/30 */ #define MY_DEBUG #define MY_RADIO_NRF24 #define MY_NODE_ID 300 #define SN "ACDimmer" #define SV "1.0" #define AC1_ID 1 #include <MySensors.h> #include <SPI.h> #include <TimerOne.h> // Avaiable from http://www.arduino.cc/playground/Code/Timer1 volatile int i=0; // Variable to use as a counter volatile as it is in an interrupt volatile boolean zero_cross=0; // Boolean to store a "switch" to tell us if we have crossed zero int AC_pin = 4; // Output to Opto Triac int interruptPin = 3; int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff int inc=1; // counting up or down, 1=up, -1=down int freqStep = 65; // This is the delay-per-brightness step in microseconds. // For 60 Hz it should be 65 MyMessage dimmerMsg(AC1_ID, V_DIMMER); void setup() { // Begin setup pinMode(AC_pin, OUTPUT); // Set the Triac pin as output attachInterrupt(digitalPinToInterrupt(interruptPin), zero_cross_detect, RISING); // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection Timer1.initialize(freqStep); // Initialize TimerOne library for the freq we need Timer1.attachInterrupt(dim_check, freqStep); } void presentation() { // Register the LED Dimmable Light with the gateway present( AC1_ID, S_DIMMER ); sendSketchInfo(SN, SV); } void zero_cross_detect() { zero_cross = true; // set the boolean to true to tell our dimming function that a zero cross has occured i=0; digitalWrite(AC_pin, LOW); // turn off TRIAC (and AC) } // Turn on the TRIAC at the appropriate time void dim_check() { if(zero_cross == true) { if(i>=dim) { digitalWrite(AC_pin, HIGH); // turn on light i=0; // reset time step counter zero_cross = false; //reset zero cross detection } else { i++; // increment time step counter } } } void loop() { dim+=inc; if((dim>=128) || (dim<=0)) inc*=-1; delay(18); }
What would be preventing the interrupt from triggering?
Thank you,
Mike
-
RE: [SOLVED] Timers and Interrupts not being triggered
@Yveaux Sorry for the confusion. In my testing I did in fact change the original sketch to use interrupt 1 as I have in my modified sketch and it worked. I did this knowing the radio was going to be connected to 0. I understand your comment about hard coding the interrupt and agree it is not best practice, however, that does not take away from the fact that the sketch did not work when I added the mysensors library in my changes. I believe, even with it hard coded, it should have worked or am I missing something?
Thank you,
Mike
-
[SOLVED] Timers and Interrupts not being triggered
Hi,
I'm making an AC (mains) dimmer using a circuit from this website https://arduinodiy.wordpress.com/2012/10/19/dimmer-arduino/. I basically uses interrupts to detect when the sine wave crosses zero and then triggers a triac. To achieve this I'm using this sketch:
/*AC Light Control Updated by Robert Twomey Changed zero-crossing detection to look for RISING edge rather than falling. (originally it was only chopping the negative half of the AC wave form). Also changed the dim_check() to turn on the Triac, leaving it on until the zero_cross_detect() turn's it off. Adapted from sketch by Ryan McLaughlin http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230333861/30 */ #include <TimerOne.h> // Avaiable from http://www.arduino.cc/playground/Code/Timer1 volatile int i=0; // Variable to use as a counter volatile as it is in an interrupt volatile boolean zero_cross=0; // Boolean to store a "switch" to tell us if we have crossed zero int AC_pin = 11; // Output to Opto Triac int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff int inc=1; // counting up or down, 1=up, -1=down int freqStep = 75; // This is the delay-per-brightness step in microseconds. // For 60 Hz it should be 65 // It is calculated based on the frequency of your voltage supply (50Hz or 60Hz) // and the number of brightness steps you want. // // Realize that there are 2 zerocrossing per cycle. This means // zero crossing happens at 120Hz for a 60Hz supply or 100Hz for a 50Hz supply. // To calculate freqStep divide the length of one full half-wave of the power // cycle (in microseconds) by the number of brightness steps. // // (120 Hz=8333uS) / 128 brightness steps = 65 uS / brightness step // (100Hz=10000uS) / 128 steps = 75uS/step void setup() { // Begin setup pinMode(AC_pin, OUTPUT); // Set the Triac pin as output attachInterrupt(0, zero_cross_detect, RISING); // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection Timer1.initialize(freqStep); // Initialize TimerOne library for the freq we need Timer1.attachInterrupt(dim_check, freqStep); // Use the TimerOne Library to attach an interrupt // to the function we use to check to see if it is // the right time to fire the triac. This function // will now run every freqStep in microseconds. } void zero_cross_detect() { zero_cross = true; // set the boolean to true to tell our dimming function that a zero cross has occured i=0; digitalWrite(AC_pin, LOW); // turn off TRIAC (and AC) } // Turn on the TRIAC at the appropriate time void dim_check() { if(zero_cross == true) { if(i>=dim) { digitalWrite(AC_pin, HIGH); // turn on light i=0; // reset time step counter zero_cross = false; //reset zero cross detection } else { i++; // increment time step counter } } } void loop() { dim+=inc; if((dim>=128) || (dim<=0)) inc*=-1; delay(18); }
The circuit and the sketch works fine until I introduce the mysensors library and a radio. When I do that the interrupt never detects the zero crossing and therefore the triac never triggers. I have not changed anything in my sketch except to include the mysensors library. My modified sketch looks like this:
/*AC Light Control Updated by Robert Twomey Changed zero-crossing detection to look for RISING edge rather than falling. (originally it was only chopping the negative half of the AC wave form). Also changed the dim_check() to turn on the Triac, leaving it on until the zero_cross_detect() turn's it off. Adapted from sketch by Ryan McLaughlin http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230333861/30 */ #define MY_DEBUG #define MY_RADIO_NRF24 #define MY_NODE_ID 300 #define SN "ACDimmer" #define SV "1.0" #define AC1_ID 1 #include <MySensors.h> #include <SPI.h> #include <TimerOne.h> // Avaiable from http://www.arduino.cc/playground/Code/Timer1 volatile int i=0; // Variable to use as a counter volatile as it is in an interrupt volatile boolean zero_cross=0; // Boolean to store a "switch" to tell us if we have crossed zero int AC_pin = 4; // Output to Opto Triac int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff int inc=1; // counting up or down, 1=up, -1=down int freqStep = 65; // This is the delay-per-brightness step in microseconds. // For 60 Hz it should be 65 MyMessage dimmerMsg(AC1_ID, V_DIMMER); void setup() { // Begin setup pinMode(AC_pin, OUTPUT); // Set the Triac pin as output attachInterrupt(1, zero_cross_detect, RISING); // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection Timer1.initialize(freqStep); // Initialize TimerOne library for the freq we need Timer1.attachInterrupt(dim_check, freqStep); } void presentation() { // Register the LED Dimmable Light with the gateway present( AC1_ID, S_DIMMER ); sendSketchInfo(SN, SV); } void zero_cross_detect() { zero_cross = true; // set the boolean to true to tell our dimming function that a zero cross has occured i=0; digitalWrite(AC_pin, LOW); // turn off TRIAC (and AC) } // Turn on the TRIAC at the appropriate time void dim_check() { if(zero_cross == true) { if(i>=dim) { digitalWrite(AC_pin, HIGH); // turn on light i=0; // reset time step counter zero_cross = false; //reset zero cross detection } else { i++; // increment time step counter } } } void loop() { dim+=inc; if((dim>=128) || (dim<=0)) inc*=-1; delay(18); }
My node registers with my gateway and all seems fine. Is the mysensors library using the same timer?
Any help would be appreciated.
Thank you,
Mike
-
Wake-On-LAN or other method
Hi,
I want to be able to wakeup a sensor remotely, kind of like WOL. Is it possible to do this via the IRQ pin on the radio that is connected to D2 (interrupt 0) on the Arduino? I saw in the radio wiring diagram a note about the IRQ not being used, is that still the case with the Dev branch?
Thank you,
Mike
-
RE: 💬 Gesture controlled MySensors, Floor lamp
Very nice. I did almost the identical thing about a year ago but I used an HS-SR04 distance sensor. I have LEDs under my kitchen cabinets and I placed the SR04 cabinet also and waving your hand by the sensor will turn the LEDs fully on or off. Dimming is done manually via OpenHAB. I will have to try the gesture sensor.
Mike
-
RE: Why is my ESP8266 MQTT Client Gateway an Access Point?
Thank you, I will try it right in the gateway code.
I'm using the NRF24L01+ radios and I have not seen any noticeable difference in the range. Mind you I never tried to see how far I can go when I was using a serial gateway, but for now all my sensors work as they did with the serial gateway.
-
RE: Why is my ESP8266 MQTT Client Gateway an Access Point?
Forget that last message. I reliazed you mentioned to change the MyGatewayTransportEthernet.cpp, which I did, but I'm running the MQTT Gateway. I found the same location in the MyGatewayTransportMQTTClient.cpp file (line 157) and added the entry there. That disabled the AP advertisement.
Thank you,
Mike
-
RE: Why is my ESP8266 MQTT Client Gateway an Access Point?
@hek I added the line to the file mentioned and uploaded my sketch again but it did not change anything.
Any other ideas?
Thank you,
Mike
-
Why is my ESP8266 MQTT Client Gateway an Access Point?
About 3 weeks ago I setup the ESP8266 MQTT Gateway from the Development branch and with the exception of adding the WiFI information and using a static IP I didn't change anything else. Everything worked as is and I am quite happy with it and thought nothing of it. this past weekend I got a new phone and had to join it to my router. In doing so I saw a wifi network called ESP_09E3. It turns out it is the Gateway advertising as a wifi access point, unprotected and open for all. I was quite worried but it was not a big problem. It has an IP that is not in my internal subnet and non routable ... but still ... why is it advertising as an AP and how can I stop it?
Thank you,
Mike
-
RE: Guide: Setting up and testing MQTT Client Gateway
@dakky The gateway tries to open a lot of connections and all of them seem to die after a short while
I had a similar problem a while back, not with the mysensors dev branch, but while using the subpub MQTT library on a ESP8266. After upgrading my MQTT (mosquitto) server to version 1.3.5 it corrected to the problem. You may want to take a look at the version you are running.
Mike
-
RE: Guide: Setting up and testing MQTT Client Gateway
@ahmedadelhosni I have not had to add any repeaters to my network yet so I should be good until a more permanent solution is worked into the library. Thank you again for you solution.
@hek Do you expect a more permanent fix for this solution to be pushed to the dev branch?
http://forum.mysensors.org/topic/2193/gatewayesp8266mqttclient-in-development-branch/11Thank you,
Mike
-
RE: Guide: Setting up and testing MQTT Client Gateway
I have tried a few things but without success, I keep getting the following output on the gateway when I try to send a message to a sensor
0;0;3;0;9;send: 0-0-0-106 s=3,c=1,t=2,pt=0,l=1,sg=0,st=fail:0
Oddly the sensors have no problem sending a message to the gateway. For example when I reset my dimmer the serial output on the gateway is the following
;0;3;0;9;read: 106-106-0 s=255,c=0,t=17,pt=0,l=3,sg=0:1.5 0;0;3;0;9;Sending message on topic: mygateway1-out/106/255/0/0/17 0;0;3;0;9;read: 106-106-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0 0;0;3;0;9;Sending message on topic: mygateway1-out/106/255/3/0/6
I have used an external power supply rather than connect the radio to the 3.3v pin on the nodemcu breakout board but that did not change anything, I also added the following but without luck
#define MY_RF24_PA_LEVEL RF24_PA_LOW
The only thing I have not done was compile the sensor with the library in the dev branch, but I was under the impression I did not need to.
Any help would be appreciated.
Thank you,
Mike
-
RE: st=fail help please
I have been trying to solve this same error while using the GatewayESP826MQTTClient sketch in the development branch
(http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway/2)
I am powering the radio via the 3.3v pin on the nodemcu breakout board. I have a cap on the radio, as I have on all my radios, and I get very good range and reception.
I will try to change the following:
#define MY_RF24_PA_LEVEL RF24_PA_LOW
Thank you,
Mike
-
RE: Guide: Setting up and testing MQTT Client Gateway
I remembered that ack is disabled on my sketches, as I did not see a point in using it with the serial gateway connected to node-red. I will recompile my sketch with ack enabled.
Thank you for your help.
Mike
-
RE: Guide: Setting up and testing MQTT Client Gateway
@hek said: "st=fail" means that your gw doesn't receive any ack on the sent radio message
Thank you for the quick response. Do I have to recompile all my sketches using the dev branch? Right now all my sensor sketches are compiled with version 1.5.
Everything works fine with my serial gateway. When I do my testing with the ESP MQTT gateway I turn off my serial gateway to avoid conflicts and when I restart one of my sensors it sends the sketch version and it presents its self and I see this in the gateways serial interface and I also see it in mosquitto. My sketches seem to have no problem sending to the gateway, but the gateway does not appear to be able to send anything to the sketch.
MIke
-
RE: Guide: Setting up and testing MQTT Client Gateway
@hek said:
MY_MQTT_SUBSCRIBE_TOPIC_PREFIXI am unable to find this anywhere in the mysensors library files. I find MY_MQTT_TOPIC_PREFIX in MyGatewayTransportMQTTClient.cpp, but that is it.
Should MY_MQTT_SUBSCRIBE_TOPIC_PREFIX not be there also?
Mike
-
RE: Guide: Setting up and testing MQTT Client Gateway
Not sure I'm doing this properly. I started with only this
#define MY_MQTT_TOPIC_PREFIX "mygateway"
My sketch was able to subscribe and publish to the mygateway topic.
I then went to this:
#define MY_MQTT_TOPIC_PREFIX "mygateway"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"but my gateway was not able to receive anything from "mygateway1-in" but it was still receiving from "mygateway".
I then went to this:
#define MY_MQTT_TOPIC_PREFIX "mygateway"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"but still not able to send or get anything from "mygateway1-in" or "mygateway1-out"
What am I doing wrong?
Also, when I send the following from mosquitto:
mygateway/106/3/1/0/2I get a st=fail error.
"0;0;3;0;9;Message arrived on topic: mygateway/106/3/1/0/2
0;0;3;0;9;send: 0-0-0-106 s=3,c=1,t=2,pt=0,l=3,sg=0,st=fail:100"Any help would would be appreciated.
Thank you,
Mike
-
RE: Guide: Setting up and testing MQTT Client Gateway
@hek said:
MY_MQTT_SUBSCRIBE_TOPIC_PREFIX
You must have read my mind, I was coming here to ask how do you subscribe? LOL
Excellent job as usual.
Mike
-
RE: GatewayESP8266MQTTClient in Development Branch
@FotoFieber I switched to ethernet gateway and wrote my own controller in node-red
I am attempting the same . For some reason though I cannot get the mysensors ESP8266Gateway to receive data from node-red. I configured a TCP node in node-red with the gateways IP on port 5003. When I connect the serial monitor I can see the client connection established, but when I send data from node-red I get nothing. I am able to telenet to the gateway and in the serial monitor I see the messages I type so I know the gateway can receive, but it does not receive from node-red. How did you get node-red and the gateway to exchange messages?
Thank you,
Mike
-
RE: GatewayESP8266MQTTClient in Development Branch
@hek Thank you. I should have mentioned I have the gateway working but I was wondering how to define the node id in the clients. In any case, I was coming back here to say I had figured it out.
I have a temp sensor communicating with the gateway.
Mike
-
GatewayESP8266MQTTClient in Development Branch
Hi,
I am starting to do some testing with the GatewayESP8266MQTTClient in the Dev branch. How do we define our own nodeid's. In the past I would do it via begin() in void setup{}. Do we now put begin() in the presentation function?
Mike
-
RE: What's up with gateway code on github ?
@hek Thank for the update, it looks very interesting.
I have been working on a ESP/MQTT sketch using the ESPWIFI Gateway and the subpub library. I will try the sketch in the development branch. I'm sure you have workout everything I am having problems with
Regards,
Mike
-
RE: ESP8266 WiFi gateway port for MySensors
Hi,
If I want to use the GatewayESP8266MQTTClient sketch located in the development branch do I also need to use the mysensors libraries in that branch?
Thank you,
Mike
-
What's up with gateway code on github ?
What happened to all the Gateway examples on github? When I look at the ino files they are all very basic and all the same.
Mike
-
RE: ESP8266 WiFi gateway port for MySensors
@Yveaux said:
Can you check the boardmanager which version of ESP Arduino you have installed?
That was the problem, I was running an older version, I upgraded it and now it show's the same as your version.
Thanks again,
Mike
-
RE: ESP8266 WiFi gateway port for MySensors
Thank you for the quick response @Yveaux & @hek
I started working on the gateway today but I seem to be having a problem. I already had IDE version 1.6.5 installed with the board manager enabled. I've been creating some sensors on some ESP-01 for a few weeks without a problem. I replaced the MySensors folder I had in my library folder with the most recent one. My old sketches still compile but when I try to compile the ESP8266Gateway sketch I get the following error.
Esp8266Gateway.cpp.o: In function `incomingMessage(MyMessage const&)': Esp8266Gateway.cpp:(.text+0x74): undefined reference to `vsnprintf_P' Esp8266Gateway.cpp.o: In function `output(char const*, ...)': Esp8266Gateway.cpp:(.text+0xb6): undefined reference to `vsnprintf_P' MySensors/MyHwESP8266.cpp.o: In function `hw_writeConfig(int, unsigned char)': MyHwESP8266.cpp:(.text+0x138): undefined reference to `snprintf_P' MySensors/MyHwESP8266.cpp.o: In function `MyHwESP8266::MyHwESP8266()': MyHwESP8266.cpp:(.text+0x16f): undefined reference to `snprintf_P' MySensors/MyHwESP8266.cpp.o: In function `MyHwESP8266::debugPrint(bool, char const*, ...)': MyHwESP8266.cpp:(.text+0x19a): undefined reference to `vsnprintf_P' MyHwESP8266.cpp:(.text+0x1b3): undefined reference to `vsnprintf_P' collect2: error: ld returned 1 exit status Error compiling.
All I changed in the ESP8266Gateway example sketch was the SSID and Password.
Regards,
Mike
-
RE: ESP8266 WiFi gateway port for MySensors
Hi
Excellent build and exactly what I have been looking for. I just got my ESP-12 this week and I am about to build this. I just have one question, what is the "Inclusion mode" for? I tried to figure it out by look at the sketch and it's not quite clear.
Thank you for everything you have done to get this to where it's at.
Mike
-
Distance Sensor and NewPing
Hi,
I am using the HC-SR04 distance sensor that is in the mysensor store along with NewPing version 1.5. My sketch works fine when the distance sensor is connected to a short wire (less than 50cm) to the arduino, but when I connect it to wire that is about 1 meter I get random distances being returned from the sensor when there is nothing in front of it. Does anyone know what the maximum distance of the wire connecting the distance sensor to the arduino can be? If this is noise can I add a cap between ground and vcc to filter it.
Thank you,
Mike
-
RE: Install your own controller on cheap android tvbox
The TV box you are talking about is pretty much like the Cubieboard2, which is also an A20 processor, except the cubieboard2 has 1GB of DDR3 memory. I use a Cubieboard3, also known as a Cubietruck, which is an A20 dual core 1Ghz with 2GB of DDR3 memory. The Cubietruck runs Cubuntu server, on this I run openHAB, Node,js, Node-RED and Mosquitto server. I have the MySensor serial Gateway connected to the USB port of my Cubietruck and node-red handles all the incoming serial messages and parses them to an MQTT format, and the other way around it takes MQTT message and parses them to a MySensor serial format and sends it the serial gateway. I also have a 128GB SSD attached to it and use it as a NAS for my 3 OpenELEC media center servers running on Raspberry Pi's and I also have some Raspberry Pi's with PiCams that stream mjpeg videos to the NAS. It works like a charm all in one little package.
I have been documenting my installation and configuration progress, one day when I have more time I will put it up somewhere.
Regards,
Mike
-
RE: Node-Red as Controller
@Fredrik-Carlsson said:
The only thing is that you must point the topic of the mqtt node directly to a child. Its not possible to just subscribe to topics higher in the hierarchy.
For example in MyMQTT app on Android i can just subscribe to topic MyMQTT and then i get messages from all nodes connected to the Gateway. This is not possible with the mqtt node in NodeRED. You must specifically point it.
You can capture all higher level topics by using the # symbal. As I mention above, my openHAB sents RF24SN/out/.... and on node-red I have an mqtt node that listens for RF24SN/out/#.
Mike
-
RE: Node-Red as Controller
I also use node-red with a serial gateway attached. I created a flow that converts the serial payload to a mqtt type payload and it is picked up by openHAB. This also works the other way around. openHAB sents everything out via mqtt and node-red picks it up and parses it back into a serial formated payload which is picked up by the serial gateway. I also use node-red's Owntracks node to monitor my proximity and send updates to openHAB as an mqtt message and I also have a flow that monitors my phone and my wifes phone, if we are both home the outside lights get turned off at 22:00. node-red also sends twitter messages to me when my doors and windows are opened and no one is home.
I only use mqtt with with a combiniation if nfr radios via the serial gateway, like I mentioned above, and I also use ESP8266 modules running lua. So as not to send the wrong payload to the serial gateway, all topics that come from openHAB that are destined for the serial gateway start with RF24SN/out/... and on node-red I subscribe the RF24SN/out/#. This will capture all those message and they will get parsed to the serial format (Nodeid;clientid;message;...etc).
Everything that happens in node-red is passed to openHAB. I have a couple of relays and leds I control from openHAB. The leds use the MySensor LEDDimmer. Basically node-red acts as the middle man between the serial gateway and openHAB/mqtt.
Mike
-
RE: thethingbox
I have a project going with openhab and thethingbox. I only use Mqtt with a combination of nrf24l01 and esp8266 modules. thethingbox server is simply used as a catch all for all mqtt messages from sensors or openhab. i parse all the message coming into ththingbox and take action depending on the message. If my door or window sensor is tripped a message is sent to Twitter. I also send temp and humidity readings to thingspeak and my cell phone reports long and lat coordinates to thingspeak so that my lights can come on as I approach the house. My next project is to setup ip cameras and motion sensors and sent pics to drop box.
Openhab is really not hard, you just have to keep at it, once you get it you will kick yourself for over complicating it
Mike
-
SerialGateway Output
Hi, This is my first post, I'm quite new to MySensors. I'm just becoming familiar with the SerialGateway with a long term intention of connecting it to a RPi. What I have done is used a Arduino Pro Mini (5v version) and wired the radio as per http://mysensors.org/build/connect_radio and I uploaded the SerialGateway sketch. I then used an Arduino Pro Mini (3v3 version) and install the radio is per the link above and I uploaded the BinarySwitchSensor sketch. When I open the serial monitor on the gateway I see the the following output.
0;0;3;0;14;Gateway startup complete.
0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
255;255;3;0;3;
0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
255;255;3;0;3;
0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
255;255;3;0;3;
0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
255;255;3;0;3;
0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
255;255;3;0;3;
0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
255;255;3;0;3;
0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
255;255;3;0;3;And this is the output from the sensor
send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=ok:
req node id
send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=ok:
req node id
send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=ok:
req node id
send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=ok:
req node id
send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=ok:
req node id
send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=ok:The problem is the output does not change regardless of whether the switch is open of closed. Am I missing something? Should the output not be different based on the state of the switch?
Any help would be appreciated , thank you.
Mike