jonnyd42 wrote: ↑
Sun Aug 18, 2019 10:16 pm
I'd like to set up my raspberry pi 3 to act as an IoT management hub for a thermostat and some other home automation things I'm making with arduinos. I'm connecting the arduinos to the Pi via BLE. I'd like to be able to access the pi via a web portal so that I can issue commands and view graphs.
That's what node-red was made for. If you are unaware of it look at some examples on youtube. Then install and test it on any pc.
For the thermostat example, I want to be able to turn on my AC, view usage graphs, and current indoor temperature from a web portal even when I'm not home. A few questions:
-What's the best way to set up the Pi as an accessible server that hosts the webpage on my network?
What do yo mean by this? You just do a normall raspbian installation configure its network, install whatever packages are needed for your project then write the code.
-If I have the server running on a thread, how should I take control inputs like "turn on AC" and send the data over BLE? Should I maintain a bluetooth daemon? What's the best way to do a cross thread function call then?
If you find a bluetooth library that actually works with your sensors you just install and use it in node-red environment.
Or maybe your ble sensors open a virtual serial pipe over ble, sending lines with text messages in which case you have to open those serial ports as any input file from node.red and read values from pipes. And send text to send messages back to ble sensors if they need such messages/commands.
If neither of the above doesn't work then you look for whatever Pi libraries are able to communicate with your sensors and do your own scripts which run separately as bridges between node.red and your sensors, forwarding messages between them.
Sending messages to node.red from an external script/process is quite straightforward, but I won't enter too much details here. It can be done in many ways like tcp/udp/http/mqtt/database it is made to talk with whatever protocols are available out there.