Menu

Tree [989dac] main /
 History

HTTPS access


File Date Author Commit
 IDs.py 2021-06-06 kitebuggy kitebuggy [398906] IDs.py added to prepare IDs.txt to be used in n...
 LICENSE 2021-04-10 kitebuggylux kitebuggylux [15e9ce] Initial commit
 README.md 2022-01-15 kitebuggy kitebuggy [6754b6] Rewrite of README.md
 configuration.py 2021-05-08 kitebuggy kitebuggy [75e10e] Changes in getting the Id's of the sensors.
 configurationPC.py 2022-01-01 kitebuggy kitebuggy [8bff30] Create configuration on PC to remote weathersta...
 copyto.py 2021-06-06 kitebuggy kitebuggy [398906] IDs.py added to prepare IDs.txt to be used in n...
 getID.sh 2021-05-08 kitebuggy kitebuggy [75e10e] Changes in getting the Id's of the sensors.
 getsensors.py 2024-05-18 alex alex [526e18] Added plot.py for PC
 getsensorvalues.py 2024-05-20 alex alex [989dac] - tfa changed to get rid of improbable values o...
 plot.py 2024-05-18 alex alex [526e18] Added plot.py for PC
 plot_1.0.1.py 2021-04-10 kitebuggylux kitebuggylux [02a147] Add files via upload
 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 2024-05-20 alex alex [989dac] - tfa changed to get rid of improbable values o...
 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

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:

  • 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.
  • 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.

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:

  • 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

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:

  • Rewrite the README.md
  • use of configuration files <- partially done
  • Draw a the electrical circuit to use a bmp180 (airpressure, humidity and temperature-sensor) using fritzing
  • Explain the use of plots

=======

tfa-pi

configuration

pexpect
configparser