Since the software code is a little complex, I’ll show you the major technology point in this part, I run a web server on Beaglebone Green Wireless to manage the Grove Modules, view the Grove Sensor Values and using a Grove – Realy to control a table lamp or something else.
Step1:Install Flask
I use a flask web framework for this APP, Flask is a lightweight Python web framework based on Werkzeug, Jinja 2 and good intentions.
You can install it by executing followingcommand.
pip install flask
Step2: Install Flask-Socketio
Flask-SocketIO gives Flask applicationsaccess to low latency bi-directional communications between the clients and theserver. The client-side application can use any of the SocketIO officialclients libraries in Javascript, C , Java and Swift, or any compatible clientto establish a permanent connection to the server.
In this project, we need flask-socketio sothat the server can update the sensor data to the client as well as the clientcan tell the server to open or close the Grove – Relay.
Install it by following command.
pip install flask-socketio

Step3: Install Gevent
The flask-socketio package relies onasynchronous services, in this project, I select gevent.
gevent is the framework used in previousreleases of this extension. The long-polling transport is fully supported. Toadd support for WebSocket, the gevent-websocket package must be installed aswell. The use of gevent and gevent-websocket is a performant option.
Install it by following command. This stepmay takes you about 10 minutes
pip install gevent

Step4: Download the code
Now, we have already install therequirements, download the code from github.
git clone https://github.com/Lee-Kevin/19.HomeControlCenterBBGW

Step5: Run the code
Navigate to the project directory 19.HomeControlCenterBBGW/Codeand runthe demo code
python runserver.py