💬 The Sensor Network


  • Admin

    This thread contains comments for the article "The Sensor Network" posted on MySensors.org.


  • Plugin Developer

    So if I understand correctly I could just by default enable the repeater on every non-battery powered node I create? The nodes wil only use a repeater if they can't connect to the gateway directly? Are there any downsides to enabling it, besides using more battery? Will the airwaves be full of repeating shouting nodes, like a speech at an Occupy demonstration, and perhaps disrupt wifi?


  • Mod

    @alowhum I don't know the answer but this thread has an earlier discussion on the same subject.



  • In the example sketch for the RepeaterNode it has this info:

    • It is important that nodes that has enabled repeater mode calls
    • process() frequently. Repeaters should never sleep.

    So, is this for older sketches for versions below 2?
    Do we need to add something more to the example sketch?


  • Admin

    This is done automatically nowadays. I will update the doc.



  • If I have multiple repeater nodes, is there a way to force a child node to got to a repeater Node and not to the GW? I have tried to use the setDestination function but that still goes via GW.


  • Mod

    @talhatec setDestination sets final destination, not intermediate destination.

    Use MY_PARENT_NODE_ID and MY_PARENT_NODE_IS_STATIC to set static routing.



  • @mfalkvidd I will try this out today and see if it helps. But this will just make the child node always communicate with the Repeater node. What im trying to do is : https://forum.mysensors.org/topic/6984/pairing-nodes-with-each-other

    So on first boot, i want the child node to goto the GW and get a node-ID and register itself. Afterwards I want it to pair to a Repeater node.



  • A theroetcical capacity using RFM 95 LoRa radios in 433 MHz ISM band:
    Lora Config bandwith: 125 KHz.
    ISM band 433.050 - 434.790 MHz.
    Allows for these 5 "channels";

    1. 433.125
    2. 433.400
    3. 433.650
    4. not used (ISM noise from commercial devices on 433.920 etc)
    5. 434.150
      6 .434.400
      7 .not used (local ham repeater), (yes its nice to check!)

    Each GW can handle 254 RF Nodes
    254 x 5 RF channels = 1270 sensor nodes in any one geographical location. (including repeated nodes)?
    p


  • Mod

    @cloolalang you can also vary the spreading factor (6 alternatives) and the coding rate (4 alternatives), yielding 24x1270= 30,480 nodes. There are other options as well (encryption, directed antennas and more) but what to do will vary in each use case. Theoretical calculations can be fun, but they do not represent the real world.



  • @mfalkvidd Hello, you can give an example of how to do this ? and if it is possible to perform on a Gateways ?


  • Mod

    @frydrik all nodes, including the gateway, on the same MySensors network need to use the same settings.

    Documentation for settings: https://www.mysensors.org/apidocs/group__RFM95SettingGrpPub.html#gaedc32edc29ffd4ecc2c849e39010069e



  • @mfalkvidd Thanks for the answer, I want to create a network for reading electric meters in a city with a population of over 500,000 people, the limit of 254 nodes is too small, yes, I understand that you can create more Gateways to share them after different frequencies, the spreading factor, coding rate, and I understand according to this scheme that the point where there will be Gateways will consist of several Gateways each will have as ex. a different frequency and only the nodes will be connected to it with its frequency, you can look at the sketch drawn by me. It gets too complicated, can it be done in a single GW or with a reduced number of GW? diagrama.jpg


  • Mod

    @frydrik yes it can be done (in fact, has already been done multiple times). MySensors is not the right technology for that though. Take a look at Sigfox and LoRaWAN. NB-IoT and Wireless MBus might be applicable as well.



  • These technologies are quite expensive to make, mysensors comes with some pretty cheap solutions, I think mysensors can be used in urban areas where the density of electric meters is quite high, especially in the panels where the meters are usually installed are grouped several as ex. 4 and more, for this panel you can mount a node that will read the indications of all meters, thus drastically reducing the number of nodes and the cost will be even more attractive to carry out this project, I thought that these nodes can be made on esp8266 + RFM95 to gain greater distances between Gateways nodes, in rural areas I will think about implementing LoraWan, for me it is quite complicated to clarify with this technology.


  • Mod

    @frydrik LoRaWAN nodes can be made with esp8266 and rfm95. I have done so myself.

    LoRaWAN gateways are slightly more expensive, but they are able to handle at least tens of thousands of nodes which is 100x more than a MySensors gateway, so the cost per node is much much lower than for MySensors.



  • the problem is that I can't find code examples for LoraWan nodes so I can start this project on LoraWan, first I created my own LoraWan gateways on TTGO LoRa32 SX1276 OLED, and on another module TTGO LoRa32 SX1276 OLED a test node as in the video on youtube https://www.youtube.com/watch?v=T40a51TAMDI&t=401s
    something works but the number of messages that reach the gate are very small in 24 hours I can receive 5-6, the problem I think I miss a gateways with one channel, and the node transmits randomly on that 8 channels, in addition I do not understand how to combine a sketch that reads the pulses from a meter with the loraWan library, I can't find examples of how to do it, that's why I was enchanted by the mysensors community, it's simple to create a node to understand how it works,
    in mysensors I found what I needed + it is a receptive community, if you have experience with LoraWan please guide me how to start creating these nodes, I found how to build a local LoRaWAN® Network Server, and unfortunately here I stopped


  • Mod

    @frydrik I have multiple years of experience with LoRaWAN, but transferring that experience from one person to another in a forum thread is not possible.



  • to start with loraWan do I need to study the Arduino-LMIC library?



  • This post is deleted!


  • @mfalkvidd Hi, I have a question regarding the numbering of nodes, as I understood, 254 can be connected to a Gateway, if I configure a node of these 254 as a repeater then at this node they will connect in theory another 254, the question is how the handle can define this number of nodes?
    #define MY_NODE_ID ------ does it work in the range from 1 -254?


  • Mod

    @frydrik yes MY_NODE_ID can be between 1 and 254. No, repeaters will not allow you to add more nodes to the same MySensors network.



  • @mfalkvidd thanks for the answer, but I have another question, why can't the number of nodes be increased to more than 254? Is it a hardware limitation or can these values be changed inside libraries?



  • @frydrik Don't forget that each node can have up to 255 sensors and you can have multiple networks. So 3 gateways running 3 networks could have 193,548 sensors. Wouldn't that be enough? If not just add another gateway.

    If you used every channel on an nrf24l01+ you could have 254x254x128 sensors = 8,258,048!


  • Mod

    @frydrik said in 💬 The Sensor Network:

    @mfalkvidd thanks for the answer, but I have another question, why can't the number of nodes be increased to more than 254? Is it a hardware limitation or can these values be changed inside libraries?

    Because the MySensors library is designed that way, and because sending larger addresses will mean that messages must be shorter that what's currently supported.

    But MySensors is open source - anyone with enough skills, time and motivation can change it.



  • @skywatch thanks for the answer, I understand that 254 nodes can be connected to a Gateway, and 255 sensors can be connected to each node, the question is how to apply this for reading electric meters where their number is considerably higher than 254, as with a node to read as ex. at least 20 meters?



  • @frydrik I think you need to spend more time with mysensors to appreciate it's strengths and weaknesses and from that experience decided if it is suitable for your needs.



  • @frydrik For a population of 500,000, say 200,000 customers, you are into commercial scale data gathering such as EON etc might deploy, a principal driver for the power companies fitting smart meters.
    I would have to guess in a city of the size you mention, smart meters are already in place...



  • @zboblamont Absolutely - with hundreds of meters in properties, most of which will have wifi ap's, wifi cameras, bluetooth devices and microwave ovens then it's a really complex situation.



  • @skywatch Hello, I'm fascinated by the mysensors project, take off your hat in front of those who develop it, I'm not a programmer, that's why I can ask a lot of stupid questions, but otherwise you can't gain experience, I'm currently programming an arduino I use graphical programming I use a Russian application: flprog is very good for me, you can program an arduino with superficial programming knowledge. Now I'm trying to learn C ++ so I can clear up the code in arduino.



  • @mfalkvidd Hello, can you help me understand, I use the example to read the data on an electric meter, but I have some problems,
    when I set PULSE_FACTOR with the one indicated on the meter I receive the wrong result, for me the meter has PULSE_FACTOR 5000 and I receive double V_VAR1 with the number of real pulses, that is if the number as ex. 10 pulses the node transmits in Gateway 20. if I set PULSE_FACTOR = with the one indicated on the counter I get a value double with the real one, in the sketch I set PULSE_FACTOR 2500 and now I get real kwh as on the counter, my question is why does V_VAR1 have such values?



  • @frydrik You don't really need to be a "C++ programmer" to use mysensors. There are a lot of examples that you can learnn from and modify to your needs.

    That said I am impressed that a Russian speaker is getting on with this in such a fast way. 🙂

    I hope I don't upset anyone with this, but I still think of mysensors as an amateur/home project.... A learning adventure if you think of it like that. I don't consider it a commercial ready application for large scale implementation.

    That is of course just my experience and opinion based on many years using it. Your opinion may be different to mine, but the only way to know is to learn, try, fail, develop and try again...... 😉



  • @skywatch Hello, I am from the Republic of Moldova, I am a Romanian speaker, I also learned the Russian language, My country is the poorest country in Europe. I am also trying to implement this remote meter reading project as a pilot project, on my own account, I have no funding here, I have to implement it myself without any resources. so I can't say this is a commercial project



  • @frydrik OK, so with no funding the only option is to educate yourself little-by-little.

    Build a small test system and keep trying it in new locations to see how it goes. Learning by doing is the best and quickest way I think.

    Have you considered that signals might be hacked, spoofed or jammed? How will you mitigate such things?

    What you want to do may seem simple at first, but there is a lot to think about with such big ambitions.

    There is no easy short cut - try things for yourself and if you have problems then post them here and I am sure many people will try and help you.



  • @skywatch Hi, thank you very much for the encouragement, I will try to document the steps I did with pictures with schemes, but I will also think about security.



  • @frydrik My approach would be to make one gateway and one node only. It will simplify testing and speed it up a lot!

    Decide which bootloader you will use and why (the below list will impact that decision).

    Learn how to burn a bootloader and when successful move on to....

    Get the code working.

    Then add soft or hard signing to messages if you think you need to.
    Then add encryption to messages if you think you need to.
    Then add wireless firmware updates (FOTA) if you think you need to.

    Then, when you have it all as you want it is easy to duplicate it very quickly to lots of nodes. And test again.

    Also I suggest manually assigning node ID's as when power goes off they will all come back with the same ID, not randomly assigned ones.

    Always save a modified sketch with a new name or verison so if things don't go well you can go back to the last working version.

    It is very likely that you will hit many obsticals along the way. You need to remain focused and determined to do what you want. Be warned that it's going to take some time.



  • @skywatch
    Hi, now I do, I have 1 gate and 3 nodes, I have already connected 1 node to a test meter, now I choose the same data that is displayed on the meter screen and MYCONTROLLER, node ID I install it manually, now I want to test at what maximum distance can the connection between the gate and the node be made, the gate is made on TTGO LoRa32 SX1276 OLED and the test node also TTGO LoRa32 SX1276 OLED, the other 2 nodes are nodemcu esp8266 + RFM95, they have standard antennas that do not inspire me much confidence , I want to try to build other antennas to see the difference between the standard antenna and the one I made, then I want to solve the problem with bootloader for FOTA, I think to create the nodes from nodemcu esp8266 + RFM95 because I want to connect to a node several counters from 2-6-8, because arduino Pro Mini / Nano no more than 2 interrupts esp8266 all gpio can be as interrupt, here I think how to do bootloader for FOTA.!!
    my test stand:
    P01019-092719.jpg



  • Hi friends, in the above "The Radio Communication" topic I see these lines "You can also send messages directly between two nodes in the network without transiting through the gateway. For example, your outside temperature sensor can send its data directly to another sensor in your kitchen with an attached display."
    This is what I am struggling to achieve , please help me with an Example Sketch for both sender and receiver for the above setup and it will be a great start for me to explore the excellent features of MySensors IoT.


  • Plugin Developer



  • @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,


  • Plugin Developer

    @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
        }
      }
    }
    


  • Thank you so much and very kind of you. I will try this.



  • Hai jkandasa, It works fine, thank you so much for your examples and it cleared lot my doubts. Thanks again, you have given me good start.



  • 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.


  • Plugin Developer

    @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.



  • Thanks again for your immediate advice. It should be OK now.


Log in to reply
 

Suggested Topics

  • 3
  • 347
  • 110
  • 2
  • 10
  • 109

60
Online

11.4k
Users

11.1k
Topics

112.7k
Posts