@Edoardo-Macrì It should work irrespective of the library version. Cross check your connection again, don't forget about capacitors too and lastly make sure you add that #define part into your code.
Posts made by ayo
-
RE: arduino mega nrf wiring
-
RE: Sensor node not working without #define MyDebug
So I tried to see if I make one last attempt to fix this problem again, I tried the Alex option using a delay(10) in the for loop. So I put a delay(10) in the for loop of my gateway code whoa it works fully well. I guess their is truly a timely issues here and the enable my_debug it's somehow doing a slowing things down work.
But using a delay(10) in the loop isn't really an efficient way though.
@delinend said:I have solved it, with the fix from Alex, with a delay(10) in the loop() Thanks
UPDATE: Using a delay(1) also works for me too
-
RE: Sensor node not working without #define MyDebug
Is it commenting out my_Debug at the gateway side or at the sensor node side. Mine is at the gateway side and the sensor node fails to connect even though my_debug isn't commented out. I even try commenting it out self it doesn't still work either.
@karl261 said:
@ayo Hmmm I experienced this also Once with the default repeater node sketch. The radio failed completely when commenting out the my_debug.
However, it went away somehow, so I cannot debug it. It went away after several reuploads of the sketch. So maybe there was just something wrong during programming in my case... -
RE: Sensor node not working without #define MyDebug
The Sensor node is being powered by an Arduino Mega 2560 var a USB connection to my pc as source of power. I have a 10uf cap btw the 3.3v and Gnd that powers the nrf24L01+ radio. It's just the normal traditional sensor node setup. Also I have an Led connected to one of the arduino mega pins (pin 4).
@cimba007 said:Can u describe more about your sensor node? What voltage? What speed? General setup?!
-
Sensor node not working without #define MyDebug
Hello,
I have built a sensor node with one of the mysensors examples and my gateway runs the default SerialGateway code without any modification. Sensor node is running on Arduino Mega and Gateway device runs on Arduino Uno and am using the mysensor 2.0. Everything is working properly well but when I tried commenting the #define MY_DEBUG on the gateway code I observe that the sensor node can't seems to work well again and can't successfully connect to the gateway device.Sensor node won't work well if comment the My_Debug code on the gateway.
//#define MY_DEBUG
Sensor node works well if I uncomment the My_Debug code on the gateway
#define MY_DEBUG
My sensor node #define MY_DEBUG code is uncommented.
This is the screenshot of the result from the gateway and the sensor node respectively
Result from the sensor node
It fails at this stage
TSP:PING:SEND (dest=0) !TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=fail:1 TSP:CHKUPL:FAIL (hops=255) !TSM:UPL:FAIL
What am I doing wrong? or any fix to make the gateway work with printing out the debug messages.
I will really appreciate the help.
Thank You.
-
RE: Problem getting the code to run with MySensors library 2.0
I meant without the MY_Gateway_Serial thing
@palande.vaibhav said:@ayo
How can I make sensor nodes with the MY_GATEWAY_SERIAL line in the code. This just makes the device a gateway. How do I make it a sensor node with that line included?Just having two different devices in the same code will work??
Like in this code:
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * DESCRIPTION * * Interrupt driven binary switch example with dual interrupts * Author: Patrick 'Anticimex' Fallberg * Connect one button or door/window reed switch between * digitial 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 * */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_GATEWAY_SERIAL #define MY_NODE_ID 1 #include <SPI.h> #include <MySensors.h> #define SKETCH_NAME "Binary Sensor" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" #define PRIMARY_CHILD_ID 3 #define SECONDARY_CHILD_ID 4 #define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch #define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch #if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3) #error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif #if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3) #error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif #if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN) #error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same #endif #if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID) #error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same #endif // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED); MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED); void setup() { // Setup the buttons pinMode(PRIMARY_BUTTON_PIN, INPUT); pinMode(SECONDARY_BUTTON_PIN, INPUT); pinMode(8,OUTPUT); // Activate internal pull-ups digitalWrite(PRIMARY_BUTTON_PIN, HIGH); digitalWrite(SECONDARY_BUTTON_PIN, HIGH); Serial.begin(115200); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER); Register binary input sensor to sensor_node (they will be created as child devices) You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. If S_LIGHT is used, remember to update variable type you send in. See "msg" above. present(PRIMARY_CHILD_ID, S_DOOR); present(SECONDARY_CHILD_ID, S_DOOR); } // Loop will iterate on changes on the BUTTON_PINs void loop() { uint8_t value; static uint8_t sentValue=2; static uint8_t sentValue2=2; // Short delay to allow buttons to properly settle //sleep(5); value = digitalRead(PRIMARY_BUTTON_PIN); if (value != sentValue) { // Value has changed from last transmission, send the updated value send(msg.set(value==HIGH ? 1 : 0)); digitalWrite(8,!(digitalRead(8))); String string = "Value changed to: "; Serial.println(string += value); sentValue = value; } value = digitalRead(SECONDARY_BUTTON_PIN); if (value != sentValue2) { // Value has changed from last transmission, send the updated value send(msg2.set(value==HIGH ? 1 : 0)); sentValue2 = value; } // Sleep until something happens with the sensor sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SECONDARY_BUTTON_PIN-2, CHANGE, 0); //sleep(0,CHANGE,0); }
-
RE: Problem getting the code to run with MySensors library 2.0
I was able to make the blinking thing run with #Define MY_GATEWAY_SERIAL commented out by having another Arduino Uno runing the gateway serial program. Basically you will need two devices setup to work or you could make use of this hack
too which will also make your device work too without having to connect to the parent.Go to your library folder and find the mysensors library folder open it and look for the core folder open the MySensorCore.cpp file make sure you have a backup of that file before opening it.
Find this section of the code
#if defined(MY_RADIO_FEATURE) // Save static parent id in eeprom (used by bootloader) hwWriteConfig(EEPROM_PARENT_NODE_ID_ADDRESS, MY_PARENT_NODE_ID); debug(PSTR("Starting Connection Process\n")); transportInitialize(); // My modification should be removed for later debug(PSTR("Starting Connection Process 2\n")); int counter = 0; while (!isTransportOK()) { hwWatchdogReset(); transportProcess(); //debug(PSTR("Trying to connect to parent \n")); #if defined(ARDUINO_ARCH_ESP8266) yield(); #endif counter++; if (counter >= 3) // exit after 3 attempts to connect break; } debug(PSTR("Starting Connection Process 3\n")); #endif
You can replace that section with those or just make those modification you see.
Save and try to upload your program again with the #define MY_Gateway_Serial thing commented out and the program will still run.What that modification does is to exit the loop after 3 connection attempts.
-
RE: Problem getting the code to run with MySensors library 2.0
No it is not like that.
You can create sensor nodes without the MY_Gateway_Serial thing, you just have to make sure that you have one device acting as a gateway device and the rest as a sensor node and everything will work very fine.
The reason you are having problem is because you are only building with one device and the library requires at-least 2 devices to work.
@palande.vaibhav said:
@ayo
Then this makes library 2.0 completely useless cause we always have to use MY_GATEWAY_SERIAL and so can't create sensor nodes.If you also confirm this then I am gonna report this as a bug.
-
RE: Problem getting the code to run with MySensors library 2.0
Yes they won't communicate
@palande.vaibhav said:
@ayo
But adding #define MY_GATEWAY_SERIAL to the code for the sensor node will make it a gateway. Right? Please check my last post where I posted the screenshots of this making both of them initialize as the gateway.And if both are gateways they won't communicate
-
RE: Problem getting the code to run with MySensors library 2.0
I think one way to go about making it work is to edit that element of the mysensor main code that makes it enter an infinite retry loop is to is to make it retry for about maybe 3 times if no connection still it should raise a flag and leaves the loop and continue into the main code.
-
RE: Problem getting the code to run with MySensors library 2.0
So I tried the whole code thing again as you have requested and I notice something weird happening to the device.
This is the code below//// Enable debug prints to serial monitor //#define MY_DEBUG // // //// Enable and select radio type attached #define MY_RADIO_NRF24 ////#define MY_RADIO_RFM69 // //// Set LOW transmit power level as default, if you have an amplified NRF-module and //// power your radio separately with a good regulator you can turn up PA level. //#define MY_RF24_PA_LEVEL RF24_PA_LOW // //// Enable serial gateway //#define MY_GATEWAY_SERIAL #include <SPI.h> #include <MySensors.h> void setup() { // Setup locally attached sensors pinMode(8, OUTPUT); } void presentation() { // Present locally attached sensors Serial.println("Presentation Runs"); } void loop() { // Send locally attached sensor data here digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second Serial.println("Loop is running");
}
After I commented out #define MY_GATEWAY_SERIAL nothing really happens on the serial monitor as you have said.
No blinking nor display on the monitor.So I went back to the code and enable #define MY_DEBUG to see what was actually happening....
THEN..I figured out what was happening
I uploaded the new code with #define MY_Debug uncomment and #define MY_Gateway_Serial still commented out I got this one the serial monitorStarting sensor (RNNNA-, 2.0.0) TSM:INIT TSM:RADIO:OK TSM:FPAR TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: !TSM:FPAR:FAIL !TSM:FAILURE TSM:PDT TSM:INIT TSM:RADIO:OK TSM:FPAR TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
From the result, the device is working as a node and trying to communicate with the parent/gateway and it enters an endless retry loop that keeps trying to communicate with the gateway. This is the reason i suppose nothing seems to be working because it is stuck trying to connect to the parent.
The Addition of #define MY_GATEWAY_SERIAL makes it already a gateway/parent device and avoids that endless loop thing.@palande.vaibhav said:
@ayo Did you try running the code?
-
RE: Problem getting the code to run with MySensors library 2.0
I don't have access to my computer now I will try it when I have it.
@palande.vaibhav said:
@ayo
did you try commenting #define MY_GATEWAY_SERIAL and running your Blink code?
Can you please try that? -
RE: Problem getting the code to run with MySensors library 2.0
Okay....so you are really having a strange problem here.
Am using the Arduino version 1.6.8,
Can you consider upgrading your arduino version maybe that could fix the CRC thing... -
RE: arduino mega nrf wiring
Just connect it like this
That should Work.
In your arduino code add the following before the #include <SPI.h>
#include <MySensors.h>// Pin Confuguration for Arduino Mega #define MY_RF24_CE_PIN 40 #define MY_RF24_CS_PIN 53
and you are good.
-
RE: Problem getting the code to run with MySensors library 2.0
So I tired the blinking thing on my own Arduino setup using the MySensors 2.0 installed var the Arduino Library manager.
The Led blinks with the mysensors library attached.
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 // Set LOW transmit power level as default, if you have an amplified NRF-module and // power your radio separately with a good regulator you can turn up PA level. #define MY_RF24_PA_LEVEL RF24_PA_LOW // Enable serial gateway #define MY_GATEWAY_SERIAL // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender) #if F_CPU == 8000000L #define MY_BAUD_RATE 38400 #endif // Flash leds on rx/tx/err #define MY_LEDS_BLINKING_FEATURE // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Inverses the behavior of leds //#define MY_WITH_LEDS_BLINKING_INVERSE // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway #define MY_INCLUSION_BUTTON_FEATURE // Inverses behavior of inclusion button (if using external pullup) //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP // 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 // Uncomment to override default HW configurations //#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED #include <SPI.h> #include <MySensors.h> void setup() { // Setup locally attached sensors pinMode(8, OUTPUT); } void presentation() { // Present locally attached sensors } void loop() { // Send locally attached sensor data here digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) wait(1000); // wait for a second digitalWrite(8, LOW); // turn the LED off by making the voltage LOW wait(1000); // wait for a second }
Maybe you can give that a short...
-
RE: Problem getting the code to run with MySensors library 2.0
I believe the problem is a result of the pin 13 you are using for the Led. The Mysensor & SPI both require pin 13 (Pin 13 is SCK pin for SPI) for the radio communication. Try and move your Led Pin to another pin from Pin 8 downward.
-
RE: [Solved] MySensors node not working, Trouble finding parent node
Okay....So after some trial I finally got the whole system to work now. The problem was from the node device, I re-soldered everything on the node part and it works flawlessly. I have even try adding more nodes to it which works without problem too. Now I will proceed to building my own Arduino based controller.
Thanks I guess -
[Solved] MySensors node not working, Trouble finding parent node
Hello,
Have been having problem trying to get atleast 2 nodes to work properly and I can't seems to figure out the problem/solution.
I have the Ardunio Uno as my serial gateway connected to the NRF24L01+ radio with a 10uf cap using the 2.0 GatewaySerial example (unchanged and even changed :)).
Have checked the pins for continuity and voltage drop where everything seems okay.
On the sensor node side, I have an Arduino Mega 2560 connected to the same NRF24L01+ 2.4GHz radio powered by an external 3.3V regulator.
On the sensor node am running the default dust sensors code adding just a modification of static node id of 6 and arduino mega CS and CE radio pinsWhat I've tried: Swapping the codes between the 2 arduino boards, trying out another type of the nrf24l01+ radio, moving the node further away from the gateway, moving the node and gateway closer, trying other example similar codes for the sensor node.
I don't have a controller, so I've hard-coded the node ID and parent id with #define MY_NODE_ID 6 and #define MY_PARENT_NODE_ID 0 for the sensor node not sure if that's necessary for the gateway device.
At the end am hoping to build my own limited controller powered by the Arduino mega or Due incorporating the Nextion touch Display for User Interface.So, when I start the two monitors up within a few seconds of each other (gateway first), here's the output of the gateway:
Gateway log messages 0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0) 0;255;3;0;9;TSM:INIT 0;255;3;0;9;TSM:RADIO:OK 0;255;3;0;9;TSM:GW MODE 0;255;3;0;9;TSM:READY 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.0.0 0;255;3;0;9;No registration required 0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1 0;255;3;0;9;TSP:MSG:READ 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=6) 0;255;3;0;9;TSP:CHKUPL:OK 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 0;255;3;0;9;TSP:MSG:READ 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=6) 0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL) 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 0;255;3;0;9;TSP:MSG:READ 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=6) 0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL) 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 0;255;3;0;9;TSP:MSG:READ 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=6) 0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL) 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 0;255;3;0;9;TSP:MSG:READ 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=6) 0;255;3;0;9;TSP:CHKUPL:OK 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 0;255;3;0;9;TSP:MSG:READ 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=6) 0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL) 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 0;255;3;0;9;TSP:SANCHK:OK 0;255;3;0;9;TSP:MSG:READ 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC
Output from the Arduino Mega 2560 Sensor node
NOde Log Message Starting sensor (RNNNA-, 2.0.0) TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=6) TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: !TSM:FPAR:FAIL !TSM:FAILURE TSM:PDT TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=6) TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: !TSM:FPAR:FAIL !TSM:FAILURE TSM:PDT TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=6) TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: !TSM:FPAR:FAIL !TSM:FAILURE TSM:PDT TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=6) TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: !TSM:FPAR:FAIL !TSM:FAILURE TSM:PDT
This is the code preview of the dust sensor running on the Arduino Mega 2560
#define MY_DEBUG #define MY_RADIO_NRF24 // Optional for Arduino Mega only #define MY_RF24_CS_PIN 53 #define MY_RF24_CE_PIN 40 #define MY_NODE_ID 6 #define MY_PARENT_NODE_ID 0 //#define MY_PARENT_NODE_IS_STATIC #include <SPI.h> #include <MySensors.h> #define CHILD_ID_DUST 0 #define DUST_SENSOR_ANALOG_PIN 1 unsigned long SLEEP_TIME = 3*1000; // Sleep time between reads (in milliseconds) //VARIABLES int val = 0; // variable to store the value coming from the sensor float valDUST =0.0; float lastDUST =0.0; int samplingTime = 280; int deltaTime = 40; int sleepTime = 9680; float voMeasured = 0; float calcVoltage = 0; float dustDensity = 0; MyMessage dustMsg(CHILD_ID_DUST, V_LEVEL); void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Dust Sensor", "1.1"); // Register all sensors to gateway (they will be created as child devices) present(CHILD_ID_DUST, S_DUST); } void loop() { uint16_t voMeasured = analogRead(DUST_SENSOR_ANALOG_PIN);// Get DUST value // 0 - 5V mapped to 0 - 1023 integer values // recover voltage calcVoltage = voMeasured * (5.0 / 1024.0); // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/ // Chris Nafis (c) 2012 dustDensity = (0.17 * calcVoltage - 0.1)*1000; Serial.print("Raw Signal Value (0-1023): "); Serial.print(voMeasured); Serial.print(" - Voltage: "); Serial.print(calcVoltage); Serial.print(" - Dust Density: "); Serial.println(dustDensity); // unit: ug/m3 if (ceil(dustDensity) != lastDUST) { send(dustMsg.set((int)ceil(dustDensity))); lastDUST = ceil(dustDensity); } sleep(SLEEP_TIME); }
This is the gateway code
#define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_NODE_ID 1 //#define MY_PARENT_NODE_ID 0 #define MY_RF24_PA_LEVEL RF24_PA_LOW // Enable serial gateway #define MY_GATEWAY_SERIAL // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender) #if F_CPU == 8000000L #define MY_BAUD_RATE 38400 #endif // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway //#define MY_INCLUSION_BUTTON_FEATURE // Inverses behavior of inclusion button (if using external pullup) //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP // 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 // Inverses the behavior of leds //#define MY_WITH_LEDS_BLINKING_INVERSE #include <MySensors.h> void setup() { // Setup locally attached sensors } void presentation() { // Present locally attached sensors } void loop() { // Send locally attached sensor data here }
From what I believe is happening is that the sensor node is trying to request for the Parent address I think and the Gateway sees that sensor node request but somehow failed to respond to request. Also am still worried why the sensor node is actually trying to request for the parent id when it has already been hardcoded into the senor code as
#define MY_PARENT_NODE_ID 0
I believe their must be something I am dong wrong here?? or something I am not seeing well.
Any help to make these all work will be appreciated.