How to log Temperature and Humidity from a ThermoPro TP350S in Linux

Back in the day I had to make my own data logger out of an ESP8266-12E wired to a temp and humidity sensor with custom firmware to log into my home WiFi and ping the results to a some custom PHP code to log! It's all pretty easy now days, IoT has come on so much we just call devices smart and give them an app.

Whilst the hardware and app are both great logging and displaying more than a years worth of data in a bit to make my new TP350S smarter I wanted to log the results to my Linux box.

It didn't take long to find a repository to work with and I've adapted some other logging code I run so I'm more than happy with it...

First we need to download some packages, be sure to already have Python 3 installed, but we'll need a couple of extras which you may not have, my stock Debian install had all the Bluetooth goodies ready to go but just need pydbus but your mileage may vary:

sudo apt-get install bluetooth bluez bluez-tools python3-pydbus python3-gi

not saying this is everything as there might be a couple missing

Next we'll grab the mac address of the device:

sudo hcitool lescan

mine popped out nicely with it's name:

XX:XX:XX:XX:A5:EE TP350S (A5EE)

then we're good to set up the files and folders:

cd ~
mkdir tp350
cd tp350

first we'll download a script which will let us interact with the unit:

wget https://raw.githubusercontent.com/pasky/tp357/refs/heads/main/tp357tool.py

and we can test it by running the following code remembering to change the mac address to the one we found above:

python3 tp357tool.py TH:EM:AC:AD:DR:ES now

you should see something like this:

temp,humid
21.6,48

now we know it's working we can go ahead and make the script

nano tp350.py

then paste in the following remembering to change your mac address again:

and ctl-o enter and ctl-x to exit then we are ready to go, just run the script using:

python3 tp350.py

if all is good we see a file called tp350.log created. We can check the contents by running:

cat tp350.log

where we should see something like:

2024-12-30,22:40:18 21.5 48

It logs the date/time then the temperature then the humidity. Every time the script runs it will just append the last reading to the bottom of the log.

Now we can schedule the script to run every 5mins using crontab:

crontab -e

then add this line remembering to change your username if it's not 'pi':

*/5 * * * * python3 /home/pi/tp350/tp350.py &> /dev/null

then:

ctrl-o ctrl-x

and sit back and enjoy.

Tags : thermopro tp350s tp357 linux datalog

Search Posts

Back to top