💬 The Sensor Network
-
@jkandasa Hi, thank you, I am a newbie, please advice what are the changes to be done to use Node2Node, to receive data from a sender and display on a LCD or OLED please. I am finding difficult only on the Receiver side, please help.
With Great Regards,@RagoTube
Note: I didn't test this code. I believe it should work.Sender node
#define MY_DEBUG #define MY_RADIO_RF24 #define MY_NODE_ID 21 #define DISPLAY_NODE_ID 0 #define TEMPERATURE_SENSOR_ID 0 #include "MySensors.h" // triggering interval static const uint32_t trigger_ms = 10000; // 10 seconds uint32_t lastTrigger = 0; MyMessage msgGeneral(TEMPERATURE_SENSOR_ID, V_TEMP); void setup() { } void presentation() { sendSketchInfo("Temperature node 1", "1.0"); present(TEMPERATURE_SENSOR_ID, S_TEMP, "Temperature"); } void loop() { if (millis() - lastTrigger > trigger_ms) { lastTrigger = millis(); // set destination address msgGeneral.setDestination(DISPLAY_NODE_ID); // get temperature from your temperature sensor float lastTemperature = 0.0; // update from your sensor // send message to display node send(msgGeneral.set(lastTemperature)); } }Display node (Gateway node)
#define MY_DEBUG #define MY_RADIO_RF24 #define MY_GATEWAY_SERIAL #define TEMPERATURE_SENSOR_ID 0 #define TEMPERATURE_NODE_ID 21 #include "MySensors.h" float lastTemperature = 0.0; void presentation() { sendSketchInfo("Display node / Gateway", "1.0"); } void setup() { } void loop() { } void updateDisplay() { // update your display with "lastTemperature" } void receive(const MyMessage &message) { if (message.sender == TEMPERATURE_NODE_ID) { // message from temperature node if (message.sensor == TEMPERATURE_SENSOR_ID && message.type == V_TEMP) { // message from temperature sensor lastTemperature = message.getFloat(); updateDisplay(); // update display } } } -
Hi, I missed to notice that, it works as long as the Gateway is ON, when I turn off the Gateway it stops receiving the data. I assumed that your example "Node2Node" code will work with out a Gateway in between. Please advice.
@RagoTube looks like we need a gateway in a sensor network and with the help of gateway node-node communication can happen. The beauty of MySensors gateway is, you can use your gateway as a node.
I just updated my example shown here. Now the display node is a gateway node.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login