3

I have a pretty big Raspberry Pi project for controlling a Paludarium (see http://www.paluweb.nl ). The entire automation is done in Python, and the Python scripts talk via the serial port to +- 12 Arduino-like boards that do the actual hardware control (light, mist, rain, temperature etc etc). I have the Pi retrieve real meteo data from a biological station in Costa Rica, and store all of these values (plus control values I send out to the hardware) in a SQLite database.

It all works beautifully, BUT I do everything through SSH today. Adding an interactive web frontend has always been a dream, but what to choose? At first I was told that Flask might be a good micro frontend to use. Then I saw CGI scripting. Then I saw Node-js...

I want to get my hands dirty, but I want to make sure I make the right choice now and not figure out I've taken the wrong road later on. What I need:

  • Able to create a complex web page with tabs where I can configure variables etc (I have MANY settings)
  • Buttons on the website to control hardware (basically call python scripts)
  • Draw graphics on the web page that draws its values from the SQLite Db and I want to be able to change the graphs in realtime as I change date/time or enable/disable checkboxes for what I want to see
  • Must run on a decent webserver that runs as a service on the Pi.

I run Raspbian on the Pi. Does anyone have an idea on what is smart (and what is not so smart) to do?

0

2 Answers 2

5

If you already have a Python backend, I would recommend, for simplicities sake, stick with Python for the frontend so you can use the already existing codebase.

There are so many Python Web-Frameworks out there and it's pretty all about how you like to do things. There are small frameworks like Flask, that are simplistic and minimalistic, which means you might need to do a little bit more but your code can be fast and you know what it does, and there are full-fledged all-in-one frameworks like Django that help you with pretty much anything you could imagine.

Able to create a complex web page with tabs where I can configure variables etc (I have MANY settings)

That sounds like you want some kind of generator that takes something like a dictionary with all possible options(and their datatypes) and generates an HTML form from that.

Buttons on the website to control hardware (basically call python scripts)

That would pretty easy if you implement your web frontend in Python. Just call the Python functions.

Draw graphics on the web page that draws its values from the SQLite Db and I want to be able to change the graphs in realtime as I change date/time or enable/disable checkboxes for what I want to see

A REST-API inside your frontend code and some nice JavaScript with some graphing module(there are plenty for libraries like jQuery) should do the trick.

Must run on a decent webserver that runs as a service on the Pi.

Most Python frameworks support WSGI easily thus can be run with Apache or nginx without any hassle.

3
  • Thanks for the elaborate feedback. As for the settings, I have many parameters I can tweak and tune. Right now I have python script that will simply write a new settings file. But I'd like to have webpages with numbers/sliders/checkboxes which will adjust the values in the settings file when I press OK. Basically you're saying that Flask is a pretty good way to go? I like my code to be clear and "under my control"
    – Erik Z
    Jan 13, 2015 at 19:56
  • Then Flask should be right for you. For the Options.. Either find some dynamic HTML form generator or try to build it yourself. My advice would be some kind of dict with all possible options(possibly grouped) and what datatype they represent. From that you could easily generate some kind of form.
    – Izzy
    Jan 13, 2015 at 20:02
  • Then Flask it is :) I will be looking out for a form generator because I don't believe in manually building everything just because you can... My time is limited too... Thanks for the feedback!
    – Erik Z
    Jan 14, 2015 at 21:44
2

I have a home automation setup: tompiechota.co.uk. I've got one or two C++ scripts, mostly python scripts and bash here and there as the backend. My frontend is written in both php, both front and back end interact with mysql. The web interface uses jsquery theme called nativedroid Which is very easy to get started with. To be honest most of my front end just calls php's os.system to run the relevant shell command based on html form input and variables in mysql. But I suppose it depends on what languages you are most familiar with.

2
  • Checked it out, quite amazing. The app looks well-designed I must say Jan 13, 2015 at 19:21
  • This look very nice! If php can simply call shell commands on the click of a button that sounds temptingly simple... I am familiar with C (not C++, I'm old ;) ) and a Python. For web not too much really... Played a bit with javascript and java. I'm from the embedded world, so web stuff is too new for me. I don't mind diving in, but I want to make sure I start of in the right direction... I'd hate to have to go back to square one and figure something new because the route I took won't do "X"...
    – Erik Z
    Jan 13, 2015 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.