In brief: use thingy:53 from console. Log data in sqlite db then use to decide when open the windows to change air avoiding to waste energy. Web interface.
----------------------------------------------------------------------------------------------------
Recently all the countries of the world are experience some troubled times: COVID 19, global warming, and other local tragedies. So I was thing how can be nice to use a device as thingy:53 to monitor and if possible predict the temperature and other environmental parameters as CO2. When I got the device I was really amazed because it is quite small, seems to have really small power consumption and: I CAN CONNECT TO IT BY OLD SERIAL TERMINAL! I LOVE IT! Alas it is not a true serial (I loved it when the world was young) but an usb cable. So I create a virtual machine (virtual box) with ubuntu and I had connected the thingy:53 with the virtual machine. Everything was smooth ! I used tio simple terminal emulator. In this way I have found a way to communicate smoothly and simply with the pre-installed firmware. Do you remember the good old time of hayes modem commands ? AT+HELP will open a whole new world of both sampling and acquiring data.
However start in a more proper way: AQUACO is all about the collecting and the using of information collected by sensor or sensors to both improve air quality in your rooms AND reduce energy used in conditioning. So you can use at home or at work. AQUACO is useful with windows that can be opened. If you have other kind of windows AQUACO is probably useless.
AQUACO is written in python using flask, sqlalchemy and other library. It is not rocket science. but probably can be useful.
As I have already told I was amazed from the discovery that thingy:53 can be controlled by USB C console. So I have written a simple script (explorer.py) to test and play with the sensors and other thingy:53's features. You will find in the github repository: in https://github.com/gvieri/AQUACO/blob/main/thingy:53/explorer.py.
After, I started to productively use the object. And I have written two other scripts: https://github.com/gvieri/AQUACO/blob/main/thingy:53/logger.py and https://github.com/gvieri/AQUACO/blob/main/thingy:53/loggerindb.py both are aimed to log the data acquired by the chosen sensor on thingy. The second one is strongly aimed to log in a db file the data coming from Environmental sensor. The first one can log a sensor of your choice. For now it is not able to log more than a sensor at time.
SO: you can start to log from many thingy as you want.
Presentation and configuration is made by simple web app. Look in the https://github.com/gvieri/AQUACO/tree/main/web folder. We have a web app to be used to configure threshold and, a web to monitor the collected data from the logger.
To start one of these web app, I suggest to use this way: <export FLASK_APP = webconf.py ; flask run --host 0.0.0.0 >. Or: <export FLASK_APP = websynoptic.py ; flask run --host 0.0.0.0 >. I suggest to use a linux virtual machine (I use virtualbox but consider yoursef free to use your preferred virtualization system).
The code of presentation is really simple and will show you a master page with link to four pages (Temperature, Pressure, Humidity, and Gas). In on of these pages you will find on left the low threshold, the last value collected from the logger and the hi threshold.
In future I'm planning to use Gas resistance value and insert other sensors. I'm interested in both UV and micro/nano pollutants.
And now start to play the game:
0) buy and download all the hardware and software.
1) download virtual box and install it on you preferred pc
2) create a linux virtual machine with ubuntu 20.04 LTS.
3) from the freshly installed linux virtual machin point th borwser on https://github.com/gvieri/AQUACO then download: https://github.com/gvieri/AQUACO/blob/main/createenvinroment.sh (in raw mode).
4) open a terminal THEN run this script with bash ./createenvironment.sh
-- note this script will download and install anaconda virtualization system pay attention.
5) close the termina (exit) THEN open a new one, THEN cd testwiththingy/AQUACO
6) run a script with bash setenvironment.sh
-- hopefully now everything is correctly downloaded.
-- if you get some error message, best thing to do is to read the script then give the command by command line.
7) now insert the hardware
7.1) lsusb
7.2 now put the thingy in the usb port. Then enable the virtual machine to see it.
7.3) reuse lsusb:
7.4 repeat to connect the tv dongle (if you have it)
Now we are going to start the work ... (remember that every terminal that you are going to use you will have to give the command: "conda activate testwiththingy)
8) db creation: cd testwiththingy/AQUACO
then:
* cp db/* .
* python3 createradiodb.py
* python3 createsampledb.py
* python3 createconfdb.py
If everything is ok ls *.sqlite will list you three sqlite files: confaquaco.sqlite externalsampleaquaco.sqlite sampleaquaco.sqlite.
9) start to work:
first thing: sudo usermod -aG dialout <your user>
* cp thingy\:53/* .
Now you can play with the thingy explorer!!!!!
* python3 explorer.py -h will you give help ... I suggest to start to obtain the HELP from thingy:
And now start to acquire data from thingy:
* python3 loggerindb.py -h will give you help
* python3 loggerindb.py will give you the data in a sqlite db.
10) to start to acquire from tv dongle:
* python3 rtl433processor.py -h then rtl433processor.py -s <your sensor comptabile with rtl_433> will put the data in externalsampleaquaco.sqlite
Now we can start to play with web:
cp -R web* .
And now
* export FLASK_APP=webwindow.py ; flask run --host 0.0.0.0
Now you can point your browser to the external ip of your virtual machine and:
To look the contents of 'thingy' db:
* export FLASK_APP=websynoptic.py ; flask run --host 0.0.0.0
to configure some threshold:
* export FLASK_APP=webconf.py ; flask run --host 0.0.0.0
So that's all folks!
I want to remember you that this code is in alpha status, that it is a proof of concept and so on.
Now a special thanks to NORDIC (I love this product ... It is able to communicate with my mobile phone from inside a refrigerator!!!) AND to Edge Impulse... The capability to use thingy:53 from a 'console' was a really nice thing! I LOVED IT!!!
Comments