This project is based on the project tfrec
I use it on a raspberry 3B+, because its consumes less power than a PC.
First, you must configure the project. Run configuration.py and replace the values if needed.
It creates a hidden file .tfa.ini in your home directory.
The values explained:
After creating this config file, run getID.sh to get the IDs of each sensor. To work, the executable tfrec must be found in the directory described in tfrec. Each time, a sensor sends its ID, this value is only appended to the file /tmp/tfa/ (or the path desbribed in tmp)IDs.txt when it's not already contained in it.
The sensors are counted. After a while, when this number doesn't increase, the program should be ended by pressing CTRL-C. A file containing the IDs of the sensors received is now available.
Now execute the file IDs.py. It simply writes 2 times the same sensorID separated by a : in the file /tmp/tfa/sensorname.txt needed for the next step. This executable can also be used to reset the sensornames.
It is now time to give each sensor a name. I suggest to give it the name of the location, where you plan to place it. For this, open a new terminal and type /opt/tfrec/tfrec -W to start a capture with a wide filter (See project tfrec).
Each sensor sends its ID and a value (i.e. temperature) with it.
An example is:
TFA2 ID 10009200 +17.0 0% RSSI 56 Offset -23kHz where:
Another example is:
TFA2 ID 100092c0 +20.3 62% RSSI 58 Offset -28kHz where:
If you are unable to identify each sensor clearly by its ID, it i possible to heat it simply with your breath.
You willl see by the output on the terminal, with ID is used by this exact sensor. You simply replace it's ID with it's name in file /tmp/tfa/sensorname.txt behind the :, i.e. 10009200:Garden
Follow these instructions to find out each ID to each sensor. Be aware, that it's possible, you find more sensors than your own. These are sensors used in neighborhood, so name them accordingly.
Run the file ./createdevice to create virtual files for each sensor detected and listed in /tmp/tfa/IDs.txt)
Create a file /tmp/tfa/sensors.txt from the file /tmp/tfa/IDs.txt by adding the sensors name right to its ID separated by ':' (11009fc0:garden). Copy this file also to a safe place.
Create a service tfa by writing a file /etc/systemd/system/tfa.service:
[Unit]
Description=tfa Sensors service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=pi
ExecStart=/opt/tfrec/run-tfrec.sh
[Install]
WantedBy=multi.user.target
Copy the tfrec binary to /opt/tfrec/tfrec(We have already done it before)
Create a file run-tfrec.sh:
#!/bin/bash
TFREC_HOME=/opt/tfrec
exec "$TFREC_HOME/tfrec" -W -e /path/to/gettemp
echo "tfrec"
and make it executable.
create a cron job calling bmp180 and tfa.py every 5 minutes:
* * * * * /path/to/bmp180
2,7,12,17,22,27,32,37,42,47,52,57 * * * * /path/to/tfa.py
-> the different times(!=*/5)
are necessary, because certain sensors have not sent a signal on 00:00, so the time label refers to the day before -> problems in plot!
Then start the service tfa by typing sudo service tfa start. Verify if it's running by typing sudo service tfa status. Each time, the program receives data, it is written in itsfile (identified by its ID).
The same happens with the barometric pressure received by the bmp180 by starting
./bmp180.
Now that you have your weatherstation running on the raspberrypi, it's now a good time to start with the configuration of your PC to visualize the data collected by the sensors.
You can visualise the data received by calling ./plot.py
Todo:
=======
configuration
pexpect
configparser