Author Topic: Micro Controller, Mesh-network, Micro-python/ Circuit Python  (Read 4253 times)

0 Members and 1 Guest are viewing this topic.

Offline ixiionTopic starter

  • Supporter
  • ****
  • Posts: 3
  • Country: sg
Micro Controller, Mesh-network, Micro-python/ Circuit Python
« on: January 20, 2020, 09:25:12 am »
Hello Everyone,

this is my first post here in the forum.

I wanted to use this post to sketch out some rough ideas and seek help from others who might have build already something similar or are interested in this as well.

I'm trying to build a network of micro controllers (ESP32 or NRF528050 etc.) distributed over a compound of about 5 hectare land each of them connected to various sensors to measure values like status of equipment, pumps, batteries, water level in storage tanks. And others with relays todo switching etc. I'm going to feed the information into a server  (RPi?) that can show alarms or do initiate tasks like Power load shedding etc. My idea was to use micro python and an esp or similar since i'm not so familiar with programming in C but have some python and Linux experience. To send the data i intend to use Bluethooth LE or Wifi. But since the area is quite large i'm concerned that the range is not enough to send the data back to the local server. So i thought of using a mesh network like ESP-now or something Bluetooth based to make the network resilient and sending data it though without extra repeater stations. Until now i haven't figured out how to build a BLE or ESP-NOW mesh network with micro python and it seems that it's currently not supported yet :/ . So i wanted find out what other ideas that people have to build a similar system or how to use micro python with mesh technology.

Thanks




 

Offline forrestc

  • Supporter
  • ****
  • Posts: 700
  • Country: us
Re: Micro Controller, Mesh-network, Micro-python/ Circuit Python
« Reply #1 on: January 20, 2020, 09:35:20 am »
Hello Everyone,

this is my first post here in the forum.

I wanted to use this post to sketch out some rough ideas and seek help from others who might have build already something similar or are interested in this as well.

I'm trying to build a network of micro controllers (ESP32 or NRF528050 etc.) distributed over a compound of about 5 hectare land each of them connected to various sensors to measure values like status of equipment, pumps, batteries, water level in storage tanks. And others with relays todo switching etc. I'm going to feed the information into a server  (RPi?) that can show alarms or do initiate tasks like Power load shedding etc. My idea was to use micro python and an esp or similar since i'm not so familiar with programming in C but have some python and Linux experience. To send the data i intend to use Bluethooth LE or Wifi. But since the area is quite large i'm concerned that the range is not enough to send the data back to the local server. So i thought of using a mesh network like ESP-now or something Bluetooth based to make the network resilient and sending data it though without extra repeater stations. Until now i haven't figured out how to build a BLE or ESP-NOW mesh network with micro python and it seems that it's currently not supported yet :/ . So i wanted find out what other ideas that people have to build a similar system or how to use micro python with mesh technology.

Thanks

The technology you probably really want to use is LoRa.  Tends to be a bit more expensive, but the application you're describing is pretty close to the target application for LoRa.

A quick look online shows shields are available with various Howto's etc....



« Last Edit: January 20, 2020, 09:39:56 am by forrestc »
 

Offline ixiionTopic starter

  • Supporter
  • ****
  • Posts: 3
  • Country: sg
Re: Micro Controller, Mesh-network, Micro-python/ Circuit Python
« Reply #2 on: January 20, 2020, 09:55:48 am »
Thanks for your quick reply. I'm aware of LoRa but actually are not sure if i want to use it. First of all i'm not aware if LoRa is suitable for mesh networks. Then it is more expensive and the data rate seems to be quite low.

On the other side:
EPS-NOW as well as BLE Mesh claim to work up to a range of 800-1000m meshable and having a higher data-rate.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Micro Controller, Mesh-network, Micro-python/ Circuit Python
« Reply #3 on: January 20, 2020, 10:28:54 am »
Thanks for your quick reply. I'm aware of LoRa but actually are not sure if i want to use it. First of all i'm not aware if LoRa is suitable for mesh networks. Then it is more expensive and the data rate seems to be quite low.

On the other side:
EPS-NOW as well as BLE Mesh claim to work up to a range of 800-1000m meshable and having a higher data-rate.
Range of LoRa is so good that you don't need mesh networking - because 5 hectares can be covered with single LoRa base station. Avoiding mesh will greatly reduce complexity meaning Lora in the end will not be that expensive as you say.
 

Offline forrestc

  • Supporter
  • ****
  • Posts: 700
  • Country: us
Re: Micro Controller, Mesh-network, Micro-python/ Circuit Python
« Reply #4 on: January 21, 2020, 01:02:37 pm »
Thanks for your quick reply. I'm aware of LoRa but actually are not sure if i want to use it. First of all i'm not aware if LoRa is suitable for mesh networks. Then it is more expensive and the data rate seems to be quite low.

On the other side:
EPS-NOW as well as BLE Mesh claim to work up to a range of 800-1000m meshable and having a higher data-rate.
Range of LoRa is so good that you don't need mesh networking - because 5 hectares can be covered with single LoRa base station. Avoiding mesh will greatly reduce complexity meaning Lora in the end will not be that expensive as you say.

Plus, nothing which was originally described needs more data than a Lora radio can handle.

To help clarify, the range for LoRa is around 3km in urban and 7km in rural.   With good antennas it can go even farther.

As far as the datarate, let's assume you have 20 things you're monitoring, each can be represented in no more than 16 bits.   That's 320 bits.   Even if everything polls once per second, you've got more than enough bits in Lora to do this.

There's a big misunderstanding about how many bits/s are needed.   Generally things like you described really don't need to be polled more than once every few minutes, and often once an hour or once a day is fine.    If you were to poll those same 320 bits of data over a minute, you only are transmitting around 6 bits per second.

Note that there is often some confusion between Lora and LoraWAN.  You may or may not need/want the WAN functions.  Lora is the data radio, LoraWAN is a protocol layered on top of it.

One thing you also should be aware of is that implementing mesh on any protocol degrades the throughput.   There are several articles out there that describe the practical throughput of BLE mesh and most end up under 5kb/s, which is in the same realm as Lora.     
 

Offline ixiionTopic starter

  • Supporter
  • ****
  • Posts: 3
  • Country: sg
Re: Micro Controller, Mesh-network, Micro-python/ Circuit Python
« Reply #5 on: March 07, 2020, 03:54:45 am »
Just in case if someone doesn't want to use Lora etc. i found an interesting esp-now project for micropython.

to flash the bin use:
esptool write_flash 0x1000 micropython-1.12-14-g9bf5d9b80-espnow.bin


Code: [Select]
w.confg(protocol=network.MODE_LR)
puts the radios into a low-bitrate mode which is incompatible with normal WiFi but is meant to extend the range a bit.


here is an code example.

Code: [Select]
import network
import time

w = network.WLAN(network.AP_IF) # doesn't matter if AP or STA
w.active(True)
w.config(channel=1) # do make sure all devices are on the same channel
print('my mac addr:', w.config('mac'))

def tx(result):
mac, sent = result
print("send: %s - %r" % (mac,sent))
def rx(result):
mac, msg = result
print("recv: %s - %s" % (mac,msg))

BCAST_MAC = b'\xff\xff\xff\xff\xff\xff'

from esp import espnow
espnow.init()
espnow.on_send(tx)
espnow.on_recv(rx)
espnow.pmk('0123456789abcdef')
espnow.add_peer(BCAST_MAC)

counter = 0
while True:
    espnow.send(BCAST_MAC, "%s" % counter)
    counter += 1
    time.sleep(1)

would be great to get some feedback.
 
The following users thanked this post: ebclr


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf