Menu

Tree [0a85f6] main /
 History

HTTPS access


File Date Author Commit
 IDs.py 2025-03-01 kitebuggy kitebuggy [0ed998] Changes in ID.py, README.md, getsensorvalues.py...
 LICENSE 2021-04-10 kitebuggylux kitebuggylux [15e9ce] Initial commit
 README.md 2025-03-02 kitebuggy kitebuggy [b73a14] added boot.sh for an automatic start after a re...
 bme_280.py 2025-03-02 kitebuggy kitebuggy [aeb817] changed tfa.py to work in cron (user=pi)
 boot.sh 2025-03-02 kitebuggy kitebuggy [b73a14] added boot.sh for an automatic start after a re...
 configuration.py 2025-02-21 kitebuggy kitebuggy [01e2ea] New commit after problems
 configurationPC.py 2025-02-21 kitebuggy kitebuggy [01e2ea] New commit after problems
 copyto.py 2021-06-06 kitebuggy kitebuggy [398906] IDs.py added to prepare IDs.txt to be used in n...
 exampleplot.png 2025-02-21 kitebuggy kitebuggy [01e2ea] New commit after problems
 getID.sh 2021-05-08 kitebuggy kitebuggy [75e10e] Changes in getting the Id's of the sensors.
 getsensors.py 2025-02-21 kitebuggy kitebuggy [01e2ea] New commit after problems
 getsensorvalues.py 2025-03-02 kitebuggy kitebuggy [aeb817] changed tfa.py to work in cron (user=pi)
 plot.py 2025-02-21 kitebuggy kitebuggy [01e2ea] New commit after problems
 progOnPc.png 2025-02-21 kitebuggy kitebuggy [01e2ea] New commit after problems
 sensorid.py 2021-05-08 kitebuggy kitebuggy [75e10e] Changes in getting the Id's of the sensors.
 sensorname.py 2021-07-10 kitebuggy kitebuggy [005157] 2nd version (ugly) of sensorname
 tfa.py 2025-06-29 kitebuggy kitebuggy [0a85f6] Errorreport with time and sensor
 tfaweather.png 2025-02-20 alex alex [11cdf4] renamed weatherstation1.png to weatherstation.png
 tfaweather1.png 2025-02-20 alex alex [3f1160] New Logo rectified
 transfer.py 2021-06-06 kitebuggy kitebuggy [398906] IDs.py added to prepare IDs.txt to be used in n...

Read Me

Weatherstation with tfa outdoorsensors

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.

On your 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.

On the raspberry pi

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:

  • tfrec: The directory, where the executable tfrec is placed. Create a directory wherever you want and copy the executabe tfrec in it. In my opinion, /opt/tfrec is a good place, because it is a common place to hold extern programs.
  • data: The directory, where the data provided by each sensor is stored in an interval of 5 minutes. Please note, aas these files are being opened and closed often a day, the SD card of the raspberry is not well suited for this. Use a USB Stick instead. Each day, a new directory in form of yy/mm/dd is created and filled with the sensors data.
  • project: The directry, where all he project is stored: Its needed executables
  • tmp: A temporary directory. Please be aware that a file is opened each time, a sensor sends a value, written in an then closed. A lot of IO operations are done. To prevent your storage to die because of too much IO cycles, these values should be written to a virtual file system. Linux has such a virtual filesystem in /tmp, which is maintained by the kernel and runs in RAM.
  • server: A distant remote server, where the data is copied to at midnight. All the data received that day is copied to this remote server. In the pre-definition it's on the NAS on the Fritz!Box router.
  • rpath: The remotepath on the remote server used.

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:

  • TFA2 is the type of the sensor
  • ID 10009200 is the ID of the sensor
  • +17.0 is the value sent, here it is a temperature in °C

Another example is:

TFA2 ID 100092c0 +20.3 62% RSSI 58 Offset -28kHz where:

  • TFA2 is the type of the sensor
  • ID 100092c0 is the ID of the sensor
  • +20.3 is the value sent, here it is a temperature in °C
  • 62% is the relative humidity measured by this sensor

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.

progOnPc

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:

exampleplot

Have a lot of fun!

Todo:

  • Rewrite the README.md <- done on 21.02.2025
  • use of configuration files <- partially done
  • Draw a the electrical circuit to use a BME280 (airpressure, humidity and temperature-sensor) using fritzing
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.