Author Topic: Listen Mode & Multiple Radios  (Read 2971 times)

rubberchicken

  • Newbie
  • *
  • Posts: 9
Listen Mode & Multiple Radios
« on: April 19, 2016, 10:57:32 PM »
Hi,

Long time reader, first time poster.

I am not sure where exactly to post this as the questions spans a number of topics but here goes anyway.

I have a large number of Moteino Megas deployed in a mesh network using the RadioHead RFM69 Library. This works great and is a requirement because my environment is always changing.

I run battery nodes with LiFePo4 batteries bypassing the regulator, this also works great and nodes have good battery life. Because of the environment all my nodes are in sealed enclosures and it takes a bit of effort to seal them up and to deploy them where they operate, once done I would like to leave them deployed for the life of the battery.

Now, the problem is that from time to time I need to refine my code. Collecting, opening and re-programming 100+ nodes is a little bit tedious...and I will soon need to deploy a new batch in another location.

I have been thinking of a way around this since I have no desire to be a programmer and modify libraries etc. My programming ability is limited to cut+paste and basic debugging.

I like Felix's library and the new features the community here have been adding and understand Felix's reluctance to share his mesh code, so it seems that 1 library alone does not meet my requirements.

So, one idea I have been thinking about is to add an extra RFM69 radio to my nodes and run them in Listen Mode with the LowPowerLab RF69 Library, as I understand it this would allow me to communicate with the node from a gateway (or most likely a laptop close to the node) for little power overhead and give me the ability to do OTA programming and change node settings.

What I don't understand is how to do this and still have my regular code running. My regular code is just a basic sleep for a while, wake up, collect data, transit and go back to sleep cycle. The demo listen mode code only wakes up when it is being communicated with. Would Listen Mode work nicely with another radio operating on the same node?

I have also been following other threads here where multiple gateways are suggested as a way of having nodes with different radio settings, would it not be simpler to have a gateway with multiple radios? As I understand it the moteino's can have 2 radios and the moteino megas can have 3, is this correct or is there an issue with running more than one radio. With the RadioHead library the library is called with reference to the SS and Int pin so technically is is possible to have 1 LowPowerLab and 2 RadioHead (RFM69 + LoRa) libraries loaded.

Is what I am suggesting reasonable and would it be possible to implement with Listen Mode? How would I go about doing this?

Cheers,

Paddy

joelucid

  • Hero Member
  • *****
  • Posts: 869
Re: Listen Mode & Multiple Radios
« Reply #1 on: April 20, 2016, 05:38:16 AM »
Hi Paddy,

this might be great timing: I have a bootloader which enables updating applications on a Moteino by simply rebooting them. This bootloader uses its own radio library which is independent from RFM69 or RadioHead.

It works like this:

When you reboot your Moteino it tries to connect to a install server and if a new version of its application is available it will download, install and run it. All of this needed to fit into 4kb of code so I had to implement a new radio library. It doesn't matter whether your apps use RFM69, RadioHead or any other library - the bootloader will just work.

In short the bootloader would support your use case without second radio or external flash. I've been using it personally for around 1.5 years and am working on releasing it. We should chat to see if my plans fit your roadmap. I'll send you a PM.

Joe

rubberchicken

  • Newbie
  • *
  • Posts: 9
Re: Listen Mode & Multiple Radios
« Reply #2 on: April 20, 2016, 07:25:38 AM »
Hi Joe,

This does sound interesting however if I understand this correctly I would still require physical access to the moteino to reboot it and some sort of external reset switch, and it would not give me the advantages of being able to communicate to the node through Listen Mode which is a feature that I would really like?

Physical access to the node in some cases is difficult or expensive, I could buy extra radios for all the nodes for less than it costs me to access the difficult ones, so the radio cost really is not an issue.

The external switch part I have taken care of with hall sensors so as not to compromise the integrity of my enclosures and I guess one of these could be used to trigger a reset. I currently use these in various ways to put some sensor nodes into different modes, eg I have an OLED display/receiver with a magnet in the base, when I put this on top of a node it switches to frequent transmission to the display in addition to it's very infrequent transmission to the gateway. A magnet on a stick could be used to trigger reset on some of the nodes but not all.

I am keen to explore the multiple radio option more at this stage unless there is fatal flaw in my thinking here.

Cheers,

Paddy

joelucid

  • Hero Member
  • *****
  • Posts: 869
Re: Listen Mode & Multiple Radios
« Reply #3 on: April 20, 2016, 08:08:18 AM »
Quote
This does sound interesting however if I understand this correctly I would still require physical access to the moteino to reboot it and some sort of external reset switch

All that's required is a way to reboot the Moteino which you can do in software. That's how I do it in my setup all the time. I just setup the new image and the send a restart command to the Moteino, it restarts and the bootloader does the rest.

Just do a
 
Code: [Select]
wdt_enable( WDTO_15MS ); while( true ); 

to force a reset.

You do have a communication channel back to the Moteino's, correct? Usually (without listen mode) one does this by sending a payload to the Moteino with the ACK packet. The server can queue commands for a given Moteino and deliver them when it phones home.

Quote
and it would not give me the advantages of being able to communicate to the node through Listen Mode which is a feature that I would really like?

That depends: I guess from your description that your Moteino's are primarily asleep to save battery. Periodically they wake up and participate in the mesh. It that's the case you could use listen mode while the Moteino is sleeping and on wakeup configure the RH library for mesh communication.

Quote
Physical access to the node in some cases is difficult or expensive, I could buy extra radios for all the nodes for less than it costs me to access the difficult ones, so the radio cost really is not an issue.

Yeah - that what it sounds like. I have a similar setup though not quite as difficult as yours. But I have a Moteino in a waste water sewage pit which I prefer not to open frequently ;) - and I have a lake thermometer that I potted in epoxy so there's no way to program it the traditional way at all.

Quote
The external switch part I have taken care of with hall sensors so as not to compromise the integrity of my enclosures and I guess one of these could be used to trigger a reset. I currently use these in various ways to put some sensor nodes into different modes, eg I have an OLED display/receiver with a magnet in the base, when I put this on top of a node it switches to frequent transmission to the display in addition to it's very infrequent transmission to the gateway. A magnet on a stick could be used to trigger reset on some of the nodes but not all.

This is exactly the kind of use case that I originally implemented listen mode for: being able to interactively manage and configure a Moteino without significant battery life impact. So yeah, that in combination with the bootloader might be ideal.

Prior to listen mode I had a command to increase the update frequency of the Moteino. So while it would usually phone home 1 an hour (giving me an opportunity to send a command back with the ACK once an hour) I could set it to an update every 10 seconds, wait an hour and then be able to send a command every 10 seconds.

Quote
I am keen to explore the multiple radio option more at this stage unless there is fatal flaw in my thinking here.

It's certainly possible that multiple radios might work. I'd be concerned about the battery life implications (I'm always paranoid that way ;) ), and the overall complexity of the solution. You'd also have to make sure that both antenna's are installed such that they don't impair each other.

Joe

rubberchicken

  • Newbie
  • *
  • Posts: 9
Re: Listen Mode & Multiple Radios
« Reply #4 on: April 20, 2016, 04:05:19 PM »
Ok, as it currently stands I do not have a communication channel back to my sleepy nodes, another reason I am looking at this option. The way that ACK's work with the RadioHead library is different than with the LowPowerLab library, it is not so straightforward to ACK with custom data. To further complicate this, with the mesh library ACK's only travel one hop and most nodes are a few hops away from the gateway.

My nodes are primarily asleep to conserve battery, I have been following other threads regarding syncing with RTC etc but this starts getting more complicated that I would like. I like keeping things very simple. As it currently stands I only have 3 programs that I have to maintain for about 140 nodes that perform a wide variety of functions, my Generic Node Code, Generic Gateway/Router and Generic Display. Different functionality is enabled with #define's, this is working very well, is very easy for anybody to understand and means that when I make changes/improvements/bug fixes to my node code I am editing 1 file not 140. If I had to add routing tables or other custom code to deal with routing ACK's back to the nodes this would get very complicated and unmanageable.

"It that's the case you could use listen mode while the Moteino is sleeping and on wakeup configure the RH library for mesh communication." - I had though about this but came to the conclusion that 2 separate radios with 2 separate libraries would be easier for me to understand and implement rather than getting 2 libraries to work with 1 radio. If this could be done without modifying libraries I would be keen to try this but I think it may be beyond my programming capabilities.

Phoning home as you suggest may also be an option that is within my capabilities to implement to receive data, but might not be practical given that I would be waiting out in the field for up to an hour (less at expense of battery drain) to open communication to each node, would take me a week to re-program all nodes. I guess this is why listen mode sounds great, I just don't know how to use it in parallel with my regular code.

Based on your advice my best approach would be to stick with 1 Radio and modify my node code to:

Wake
Switch Radio to RH Mesh Library
Collect and Transmit Data
Switch Radio to LPL Library with listen mode
Sleep Node in listen mode

This sounds reasonable if it is technically possible.

Cheers,

Paddy






joelucid

  • Hero Member
  • *****
  • Posts: 869
Re: Listen Mode & Multiple Radios
« Reply #5 on: April 20, 2016, 04:26:39 PM »
I think it should work out of the box. Just initialize the radio library as you would in setup on cold start (radio.initialize, set key etc) and it should reconfigure the rfm69 to the appropriate settings. I think this is likely less problematic than running two radios.

I do similar things all the time as I reconfigure the radio between boot, listen mode, normal settings, ook Rf plug automation etc. I've only had one issue: rfm69 registers the Irq handler before initialing the instance pointer. But it's not clear that would hit you and if it would it's a one line fix.

Your setup sounds quite interesting. One day you'll have to tell us what exactly you're doing with all these nodes!

joelucid

  • Hero Member
  • *****
  • Posts: 869
Re: Listen Mode & Multiple Radios
« Reply #6 on: April 20, 2016, 04:51:19 PM »
Btw funny that you mention running with just 3 apps for all 120 nodes. Reminds me of the time when I started. I never had more than even 1 binary for the first 10 months or so. It would come up as generic node and you could then reconfigure it to become what it should be by issuing a command over Rf. The mote would then reboot and instantiate the correct sensor instance on next boot. Just imagine how easy it was to rebuild/update everything!

This worked so well that in my first bootloader I actually just cloned the firmware installed on another Moteino. Very easy, no room for serial data corruption and very standalone.

However as you can imagine it didn't last forever. Now I have a gateway app and 3 sensor apps for maybe 17 different node types.

rubberchicken

  • Newbie
  • *
  • Posts: 9
Re: Listen Mode & Multiple Radios
« Reply #7 on: April 21, 2016, 03:22:21 PM »
Thanks Joe,

I am travelling at the moment but will give this a try when I get home.

It didn't take me long to realise that a separate program file for each node was not going to work. What I have is good but what you have sounds better, I hadn't thought about storing the node configuration in eprom. That would simplify things even more as it would only need to be set once per node type and then any updates are just updates to the generic code without any node specific #defines...another thing for me to learn how to do when I can find some time.

Cheers,

Paddy