This project is based on the project tfrec. Install it in /opt/tfrec
I use it on a raspberry 3B+, because its consumes less power than a PC.
Copy the file in a directory you want, unzip it and run the file configurationPC.py. Answer the questions and set the password. Normally, all predefined values are fine (except the password ;-) )
It creates a hidden file .tfa.ini in your home directory.
Now, connect to your raspberry via the terminal by typing: ssh -l pi weatherstation. Replace the name and the hostname of the raspberry accordingly. If you connect the first time to it, a question is asked: Are you sure you want to continue connecting (yes/no/[fingerprint])? Answer the question by typing yes. This way, a file .ssh/known_hosts is created in your home directory, containing the raspberry's fingerprint.
Copy all the files from the directory containing the project to the raspberry in a directory called weatherstation in your homedirectory except configurePC.py,plot.py and getsensors.py.
On your raspberry (in terminal), run the file configure.py and answer the questions accordingly. Also here, the default values are fine.
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.
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 window 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:
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 the mounted stick (mnt/Data).
If you are unable to identify each sensor clearly by its ID, it is 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 place a : behind its ID and complete by its 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.
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 in /opt/tfrec (or the place where you copied tfrec):
#!/bin/bash
TFREC_HOME=/opt/tfrec
exec "$TFREC_HOME/tfrec" -W -e /path/to/gettemp
echo "tfrec"
and make it executable.
In a crontab (crontab -e), add a line:
@reboot /home/pi/weaterstation-tfa-code/boot.sh
to copy elementary files to the right places in /tmp after a boot.
create a cron job calling tfa.py every 5 minutes:
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).
Now that you have your weatherstation running on the raspberrypi, it's now a good time to visualise the data reveived by the raspberry. Wait at least 10 minutes to get some data and visualise it by calling ./plot.py. A window containing the sensors and a calendar appears.
Choose the sensor by clicking on its radiobutton and choose the date. After a click on Ok, a window opens showing the graph of the sensor choosen:
Have a lot of fun!
Todo: