emoncms/raspberrypi — pull request #8 by Jerome-github (2013-03-04 01:09:41+00:00)
Title: RMF2Pi gateway

Hi.

I believe this python gateway is now functional. It can be used instead of the raspberrypi_run.php script.

Features :
- Can send to both local and (optionally) remote server
- Great logging capability : customizable logging level, rotated log that could be "tailed" and displayed in an AJAX field
- Non blocking serial read (won't get stuck if wrong frequency set or no packet received for any reason)
- Send time over RF to synchronize emonGLCD (see here : http://harizanov.com/2013/02/new-rfm2pi-board-in-the-works/#comment-658)

I made it as modular and commented as I could to allow for future adaptation.

There are a few hardcoded parameters for which I intend to add a configuration option in the php GUI : logging level, remote server send interval, toggle emonGLCD sync,...

To avoid duplicating DB configuration, I moved the config from settings.php to an ini file :
https://github.com/emoncms/emoncms/pull/33

If you think this is a bad idea, I can move back to a separate file.

Anyway, I'm open to discussion. Tell me what you think and I'll do some rework if needed.

Installation :

Depends on
- python-mysqldb
- python-serial

Usage :

To launch the script :

/var/www/emoncms/Modules/raspberrypi/rfm2pigateway.py &

If connecting via ssh, use nohup to avoid the program stopping when disconnecting :

nohup /var/www/emoncms/Modules/raspberrypi/rfm2pigateway.py &

It could be added to cron to be launched at startup.

It could even be daemonized (https://github.com/emoncms/raspberrypi/issues/5), although I don't see the necessity.