getting data from sensor to sensor



  • Hi
    I have few sensors and gateway conected todomoticz server on RPi, id like to make new node - display node.
    It means it will be LCD dispaly conected to arduino with some switches do change data.
    But i dont know how idea how get data from other, nodes, how can i ask gateway about it? is it possible?
    for example how i can ask about value of 2nd child in 5th node?


  • Hero Member

    @Robert-Król Yes that is certainly possible, Have a look at requesting data on the api page. You can request data from any node on your Mysensors network.



  • unfortunatelly is not wrote enough clear for me 😞
    I still cant get data from other node....
    For example in my network i have meters (node 5, node 7 - temperature, node 10 humidity, etc) and big display (node 40), how can i ask from node 40 about value from node 5, 7, 10??
    how can i do "display_txt = node5.tempearure"



  • If you want to request sensor values directly from other nodes, they all can't be sleeping, because they would have to handle the incoming request. Since you're using an LCD display on the requesting node, I assume that it will always be powered, right?

    In this case, I'd suggest to send all the sensor values your're interested in both to the GW and to the LCD node. The sensor nodes can go back to sleep after taking and sending the new measurements and the LCD node will be able to display the new values as soon as they've been sent to it.

    On the sensor nodes (5, 7, 10, etc):

    #define LCD_NODE_ID 40
    void loop() 
    {
        send(msgTemp.set(temp)); // Send to GW
        send(msgTemp.set(temp).setDestination(LCD_NODE_ID)); // Send to LCD node
    }
    

    Now you have to listen for incoming messages on the LCD node:

    #define KITCHEN_NODE_ID 5
    #define BEDROOM_NODE_ID 7
    bool receivedNewSensorValues = false;
    
    void receive(const MyMessage &msg) 
    {
        // Set a flag so that you can update the LCD when needed
        receivedNewSensorValues = true;
    
        // Receiving temperature from kitchen node
        if (msg.getSender() == KITCHEN_NODE_ID && msg.getType() == V_TEMP)
        {
            kitchenTemp = msg.getFloat();
        }
    
        // Receiving humidity from kitchen node
        if (...) {}
    
        // Receiving temperature from bedroom node
        if (...) {}
    }
    
    void loop() 
    {
        if (receivedNewSensorValues)
        {
            // Update LCD
        }
    }
    


  • Just an opinion about this issue. If you don't want to modify your sensor code and keep it "generic", you should move the logic and communication to the controller. Domoticz (or any other controller) already receives the data. It can conditionally send it to the LCD node.
    Having the code on the gateway or on nodes makes sense if you want it to work when the controller/gateway are out of reach.



  • Great, atm i can send data from my sensors to gw and display node. But what about asking from lcd note to data from other node (always powered)?
    In my network i have some ESP nodes which send data to domoticz, id like to some of this data on my dispaly node.



  • @boum I did it in this way from some time, but it looks less elegant. I have to make many virtual devices in domoticz, devices which send data to my lcd node. It works, but i think sending data directly to lcd will work better (or not... :))
    The best solution would be ask directly domoticz (gw) about data sending from other node, but propably its not work in that way


Log in to reply
 

Suggested Topics

  • 5
  • 2
  • 2
  • 3
  • 5
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts