Webapp and data requests

General programming chat and advice for beginners

3 posts
by Gitch » Sat Jun 17, 2017 11:56 pm

So I am currently building my first web app where I will be using a Pi to be a interface between a few different devices around my house.

The first one is an air conditioner unit that provides it's status in JSON format when requested and makes changes by sending JSON data using a CURL command. My first question is there a normal time frame people use to retrieve data to update my web app? I was thinking every 500ms, so if somebody else makes a change - it should be almost instantaneous on my app (or is that too often?)

The second device will be another Pi (or more likely just a micro controller) reporting the status of several parameters. How do you store your data? I was thinking of using a MySQL database, and running an update to keep the current status - or am I better off using a text file, or just storing it in memory? The MySQL (or other DB) would allow for data logging but would it be overkill for unlogged data?

Posts: 2
Joined: Sat Jun 17, 2017 11:38 pm
by scotty101 » Mon Jun 19, 2017 9:41 am
To your second point about storing data.
1. For all the logging I've done on Pi's I've used SQLite rather than MySQL. I consider them overkill for such a small application and I find them easier to backup and restore.
2. For small settings/status information, I usually export this data in JSON format. Easy to export and import in python and many other languages.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter
Posts: 2145
Joined: Fri Jun 08, 2012 6:03 pm
by Gitch » Tue Jun 20, 2017 1:41 am
Thanks scotty101,

Yeah, I hadn't looked to far into the DB yet and whilst I am familiar with MySQL, my quick research has shown SQLite to be better suited to embedded designs... Looks like it time for a change :)

As for the 2nd point, more looking at how the state data (i.e. on / off) is stored and written. For example, if I had a power switch would I use and update a SQL statement (the method I'm leaning towards) or some other method that is better suited?

Posts: 2
Joined: Sat Jun 17, 2017 11:38 pm