Pi code for multiple Moteinos

Started by ColinR, February 11, 2014, 02:40:10 PM

ColinR

Hello,

I'd like to set up a network of sensor nodes with a gateway transceiver attached to an RPi to poll them. Is there example code of such a gateway node and code (preferably Python) on the Pi side to communicate with such a gateway?

Kind regards,
Colin
CuPID Controls :: Open Source browser-based sensor and device control
Interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

Felix

Hi Colin, welcome to the forum!
Yes most of my examples revolve around a multi node single gateway network, where the gateway interfaces to a Pi or similar host running python. Python then reads all packets via serial and relays information where needed - into a mySQL database, or EmonCMS, or web app. My garageMote example uses node.js as a host.
Please see the blog at lowpowerlab.com or the github repository at github.com/lowpowerlab for the actual writeups and code.

ColinR

Hi Felix,

Thanks for the quick response. I double-checked the libraries and blog, but haven't found much Pi-side code, python or otherwise. I found a tiny bit in the email example, but is there support for issuing commands on the Pi side, for example a poll request or change in parameters, such as poll frequency, which io to read and/or report, etc?

I'm sorry if I'm missing where this is in the blog or repo, but I have not yet located it.

Thanks,
Colin
CuPID Controls :: Open Source browser-based sensor and device control
Interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

Felix

Colin, perhaps I misunderstood. I have given some generic and some specific application example code sketches. The generic ones are meant to get you started with using the RFM transceivers and understand how to send/receive/sleep etc. The specific examples illustrate how the transceivers might be used independently or in a network configuration to report data or control certain devices (like the garage door). As of this writing, I have not put together any examples where the gateway can change the settings or how an end node behaves. The wireless programming feature can be used to update the firmware on a leaf node.
Part of the SwitchMote release will be an example sketch that will allow to store essential radio settings in the EEPROM such that they will not have to be included with every sketch you load (like network, id, is HW or not, frequency, and things that don't change often). That example can be extended to include other pieces of information and also to be updateable via wireless commands from a gateway.

Sorry if I did not address your specific needs with my examples but generally the examples are to get you started and it is left to the user to customize based on their requirements. Please don't take this as a discouragement. It's a small community and it can grow better by each individual sharing their experience and perhaps their code/progress so others can benefit just as my examples and projects were opened for contribution.

ColinR

Hey, no problem Felix.

I'm just trying to decide which wireless boat to jump on and also not reinvent the wheel. I'd about begun connecting my XBees up to ATMega328ps and sat down to solder and program and happened upon your boards, which look like what I'd eventually end up with after some Eagle, board revisions, and dinking around.

Unless I'm missing something, it doesn't seem like there is any reason that a basic command for nodes and gateways could not be built that would allow the nodes to reprogram internal variables such as poll time, resolution, reporting frequency, power down, etc, based on formatted serial data. For example, Gateway sends serial data node3:polltime:60, and the sketch-programmed node sets its value internally and sends ack.

From the Pi side, a serial motegateway:node3:polltime:60 command instructs the gateway to carry out the command.

Does this make sense?

Thanks,
Colin
CuPID Controls :: Open Source browser-based sensor and device control
Interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

KanyonKris

Forum member john_k2ox has contributed a "remote control" library called COMMAND_LINE that is along the lines of what you want. Use his library as-is or as a starting point for your own customized solution.

http://lowpowerlab.com/forum/index.php/topic,265.0.html

Felix

Quote from: ColinR on February 11, 2014, 05:58:17 PM
Hey, no problem Felix.

I'm just trying to decide which wireless boat to jump on and also not reinvent the wheel. I'd about begun connecting my XBees up to ATMega328ps and sat down to solder and program and happened upon your boards, which look like what I'd eventually end up with after some Eagle, board revisions, and dinking around.

Unless I'm missing something, it doesn't seem like there is any reason that a basic command for nodes and gateways could not be built that would allow the nodes to reprogram internal variables such as poll time, resolution, reporting frequency, power down, etc, based on formatted serial data. For example, Gateway sends serial data node3:polltime:60, and the sketch-programmed node sets its value internally and sends ack.

From the Pi side, a serial motegateway:node3:polltime:60 command instructs the gateway to carry out the command.

Does this make sense?

Absolutely can do. And yes, thanks to Kris for pointing out john_k2ox's library contribution that can do something along those lines.

ColinR

Great start. I can very easily build a command set on top of that.

Thanks for the quick replies, guys. It's great to know there is an active community and developer(s).

Last request -- best way to mount this onto an RPi? I've got very limited room in my enclosure. I have enough room for something like this: http://shop.ciseco.co.uk/slice-of-radio-wireless-rf-transciever-for-the-raspberry-pi/ , but not enough room to mount something .. well, really anywhere else. I'm sure somebody has gotten creative?

I see that at least the serial and one of the 5V pins line up, so I could chop the extra length off the headers running out the top of my current board, jumper the others, and put a bumper on the underside of the board.

Colin
CuPID Controls :: Open Source browser-based sensor and device control
Interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

Felix

Good question. I've been wanting to come up with some better solution to put a Moteino + Pi + space for other stuff in some kind of enclosure. A breakout board is not out of the question but since there are so many breakouts and add-on boards for Pi it's so hard to tell what a good design would be. I think most cases for Pi are almost useless once you want to add 1 or 2 addons. So a custom enclosure that allows easy expansion would be required.

For now may I suggest more of a DIY on the fly compromise: use velcro or standoffs with screws to mount the Pi and then velcro for Moteino. There is at least 1 other thread in the forum that I can recall where someone asked for ways and materials that can be used to mount a Moteino inside a case and some suggestions have been posted there. At this point the short answer is ... use your imagination. I will post any updates on the LowPowerLab blog if such solution is envisioned.

BTW the pins will not align correctly. You will need to pair TX on the Pi with RX on the Moteino and vice versa. TX connected to TX will collide and not work at all, same for the RXes.

ColinR

Ok I'll see what I can do. For reference, this is what my enclosure looks like:





So I've got room on top, just not much around.

C
CuPID Controls :: Open Source browser-based sensor and device control
Interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

ColinR

I'll work something out and post it. Guess I should ... buy a mote.
CuPID Controls :: Open Source browser-based sensor and device control
Interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com