wmarkow / arduino-mesh

Arduino mesh network layer
GNU General Public License v3.0
2 stars 0 forks source link

Smalltalks related to sensor networks #1

Open wmarkow opened 6 years ago

wmarkow commented 6 years ago

@furiati, let's not put offtopics to the nRF24 library with our smalltalks about sensor networks. We can "elaborate" here. Let me quote your last comment from RF24 issue:

I think this could work, which does not mean that it is the best option. The idea is: main station send a request to the sensor station, the sensor station responds with the sensor data and starts de power down sleep process for X seconds. When the main station receive the data, it calculates how long it has taken (like in my sketch and rf24 examples) and reset the time counter for next polling. So we know time until next polling will be something like: X + transmission time/2 + Y. Y will be a little more time to be safe. Maybe i am over complicating thing, anyway i am learning things.

I think you are over complicating things ;) This sounds easy but it requires a good time synchronization between main station and the sensor station. I have the feeling that it will work fine after beginning (when you power up your devices) but after a few minutes (or sooner) it will be out of sync and the main station will not receive any response from the sensor station (because sensor station will be in a sleep mode). Besides you need to track the synchronization with each sensor station; if you have 10 of them, then you need to provide time synchronization between main station and 10 sensor stations. Then you need ten time counters in your main station source code. Every time you add a new station you need to update your main station source code. The main station will have more work to do (like posting data to IoT server), which consumes time, and you will be again out of the sync between master station and sensor stations.

I did not make any test using the 6 data pipes at the same time. I don't know if it will be collisions problems or not. have you been experimenting with this?

To be honest I have tried to understand the idea of this 6 data pipes. I think that same day ago I understood this but today I'm lost again :) I was experimenting with the idea of sensors connected to a mesh. There is a nRF24 mesh implementation provided by nRF24 team. I wasn't experiment with this because it was not suitable for me: I think it allows only nRF24 chips to be used (correct me if I'm wrong) in the mesh. My idea was to use some other wireless chips as well. So I came up that I could use a flooding mechanism to send data in the mesh topology. Besides I wanted to check if that will work. I have just found some article in the web. You can take a look (I will as well). Going back to your question: yes I was experimenting with nRF24 chips and flood mesh and it was working fine. I have implemented some "random" access to the transmission medium and data at some point I was able to lower the collisions rate and packet retransmission increases the chances that the data will reach the main station. Besides I was testing the flooding mechanism and it seems to work correctly: I had a three nodes A, B, C where nodes A and C didn't have a direct range contact (there were to far from each other so the direct transmission is not possible). I have put a node B somewhere between A and C and the transmission was possible then, because node B was acting like a repeater. With this solution you can extend the physically range of your network and you do not have to worry about some routing between the nodes.

I did some test with a demos d1 mini, it works with the RF24 library, unless the printf function. My plan is to upload the gathered data to Thingspeak or similar ioT service. I think it is enough for my purpose and it is way cheaper than a RaspberryPi which can be used for more complex things.

What is d1 mini? Can you post a link to this? Is this something related to ESP8266? I was using NodeMcu at some time. To upload the data to Thingspeak or something similar you need a device that has Internet access and is possible to send small packets to the web. I suppose that this would be a main station as well; it collects data from the sensors stations and redirects them to the Thingspeak. I think this kind of device is called gateway (in terms of IoT) and the server like thingspeak or openhab or domoticz is called a controller. As a good start take a look at MySensors. You can get familiar with IoT idea there and maybe they will inspire you with something.

furiati commented 6 years ago

Perfect! Sorry if somedays it takes me a little more time to answer, I am a little busy at work this days.

I think you are over complicating things ;) This sounds easy but it requires a good time synchronization between main station and the sensor station. I have the feeling that it will work fine after beginning (when you power up your devices) but after a few minutes (or sooner) it will be out of sync and the main station will not receive any response from the sensor station (because sensor station will be in a sleep mode). Besides you need to track the synchronization with each sensor station; if you have 10 of them, then you need to provide time synchronization between main station and 10 sensor stations. Then you need ten time counters in your main station source code. Every time you add a new station you need to update your main station source code. The main station will have more work to do (like posting data to IoT server), which consumes time, and you will be again out of the sync between master station and sensor stations.

Maybe it will become ugly and I will have to left this path. For the time I will keep experimenting because I am learning new things every day. I want to note that I am not using the RF24 Mesh library, I am only using the RF24 library. Because of that the maximum number of sensor stations will be six (the same number of data pipes).

To be honest I have tried to understand the idea of this 6 data pipes. I think that same day ago I understood this but today I'm lost again :) I was experimenting with the idea of sensors connected to a mesh. There is a nRF24 mesh implementation provided by nRF24 team. I wasn't experiment with this because it was not suitable for me: I think it allows only nRF24 chips to be used (correct me if I'm wrong) in the mesh. My idea was to use some other wireless chips as well. So I came up that I could use a flooding mechanism to send data in the mesh topology. Besides I wanted to check if that will work. I have just found some article in the web. You can take a look (I will as well). Going back to your question: yes I was experimenting with nRF24 chips and flood mesh and it was working fine. I have implemented some "random" access to the transmission medium and data at some point I was able to lower the collisions rate and packet retransmission increases the chances that the data will reach the main station. Besides I was testing the flooding mechanism and it seems to work correctly: I had a three nodes A, B, C where nodes A and C didn't have a direct range contact (there were to far from each other so the direct transmission is not possible). I have put a node B somewhere between A and C and the transmission was possible then, because node B was acting like a repeater. With this solution you can extend the physically range of your network and you do not have to worry about some routing between the nodes.

Well I will try to make it simple and I tell you what I understand about pipes (maybe I am wrong). A pipe is like a communication channel between a emitter and a receiver, that channel is unique so there is no conflicts with another nodes. The nrf24l01+ chip can listen to six data pipes at the same time, so this is the limitation that I was talking about. When using a mesh, it works different. Hope this is a little more clear for you. I think RF24 mesh is only for Nordic chips. What other chips do you want to use and why? The nrf24 team is doing a very good job, and RF24 mesh is very efficient and stable. I don't know if I like the flood method, I need to think about it. I think if you only have 3 nodes, is easier to program the B node like a repeater and not using this mesh system. It depends on the number of nodes. How long is too far? Are there a lot of walls in between or noise from lot of wifi networks or something? Because there are nrf24l01+ modules with power amplifier and antenna that have a pretty good range.

What is d1 mini? Can you post a link to this? Is this something related to ESP8266? I was using NodeMcu at some time. To upload the data to Thingspeak or something similar you need a device that has Internet access and is possible to send small packets to the web. I suppose that this would be a main station as well; it collects data from the sensors stations and redirects them to the Thingspeak. I think this kind of device is called gateway (in terms of IoT) and the server like thingspeak or openhab or domoticz is called a controller. As a good start take a look at MySensors. You can get familiar with IoT idea there and maybe they will inspire you with something.

Sorry I forgot to mention and yes it is esp8266 based board: Wemos D1 Mini I tested this board with Thingspeak (there is a library) and with nrf24l01 and it works well, at least at the moment. I don't know the terms, thanks for the link I will take a look.

I think this is all haha for the moment.