Very light weight web based realtime xbee monitor/control system. You can deploy it on your Raspberry PI if you like.
This project is originally designed for SUNIST Tokamak Wireless(ie. ZigBee) monitoring and control system. The system was originally programmed on Windows system using VB language which is hardly to maintain when more ZigBee modules added and of course not portable on other platforms.
This system uses xbee wireless module to monitor the status of power supply, vacuum chamber and other equipments as well as the control of them build up the slow one (in seconds). Below is a picture of xbee modules deployed around SUNIST Tokamak.
Install redis, python-pip, python-virtualenv with your linux distribution package manager (apt-get, yum, zypper, pacman etc.)
virtualenv --distribute ~/venv cd ~/venv source bin/activate pip install pyserial XBee redis Flask git clone https://github.com/dengshuan/sunist.git
- Modify your xbee configuration file: scripts/config.json
- Initialize your xbees. start redis server if not started yet
cd ~/venv/sunist/scripts python initialize.py
- Begin sampling
python sample.py
- Launch web server, run following commands in a new terminal
cd ~/venv/sunist source ~/venv/bin/activate python sunist.py
- Open http://localhost:5000 in your web browser. If you want to
view this page on other computer or mobile client, change last
line in sunist.py to
app.run(host = '0.0.0.0')
, and visit http://YourServerIP:5000 - Watch sampling data and change pin output level all in a web browser
- Deploy with nginx and uwsgi. Make sure nginx, uwsgi,
uwsgi-plugin-python installed on the server. Then create nginx
configuration file /etc/nginx/sites-avaliable/sunist
server { listen 5000; server_name hostname; location /static { alias /home/pi/venv/sunist/static; } location / { include uwsgi_params; uwsgi_pass 127.0.0.1:9001; uwsgi_param UWSGI_PYHOME /home/pi/venv; uwsgi_param UWSGI_CHDIR /home/pi/venv/sunist; uwsgi_param UWSGI_MODULE sunist; uwsgi_param UWSGI_CALLABLE app; } error_page 404 /404.html; }
And create uwsgi configuration file: /etc/uwsgi/apps-available/myuwsgi.ini
[uwsgi] plugins=python vhost=true socket=127.0.0.1:9001
Link above two files to enabled sites or apps and restart service
sudo ln -s /etc/nginx/sites-available/sunist /etc/nginx/sites-enabled sudo ln -s /etc/uwsgi/apps-available/myuwsgi.ini /etc/uwsgi/apps-enabled sudo service nginx restart sudo service uwsgi restart
That’s it! (Note that above deployment is based on raspberry pi with raspbian Wheezy. Other platform should be similar, but not tested yet)
- Different linux distributions may assign different device name for usb port, usually /dev/ttyUSBn or /dev/ttySn where n is a number. Make sure your distro assign /dev/ttyUSBn , if not, change /dev/ttyUSBn to /dev/ttySn in scripts/initialize.py and scripts/sample.py
- You would see Permission denied error if you are not in the
dialout group. Add yourself to dialout group by
sudo usermod -a -G dialout $USER
- Improve UI (heavily depend on user’s usage)
- Add web interface for configuration
- Add a detail documentation for secondary development