Skip to content
View in the app

A better way to browse. Learn more.

BuildHub.org.uk

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cheap (and accurate) temperature data logging

Featured Replies

When I calibrated a bunch of DS18B20s, I found the biggest variance was in the time they took to react to a temperature change.  This can give the impression that they are less accurate than they are.

On 26/08/2021 at 07:54, MJNewton said:

You shouldn't have to calibrate these sensors.

 

As old Ronald Reagan said: trust but verify.  Actually doing the calibration was a very useful confidence exercise and meant that I could have trust in the sensor outputs.  I've zero problems with my DS18B20-base temperature acquisition in the four years that I've been using it.  

  • 1 month later...
On 10/06/2021 at 07:43, Adrian Walker said:

I building a temperature monitor and logger at the moment.  From a hardware point of view I'm using DS18B20 (12 bit gives 0.0625°C), Raspberry Pi Zero with a 1-wire HAT.

Temp.jpg

 

How is this progressing? I'm new to RPi, but like the idea of having multiple sensors, some installed in the slab, some air mounted etc to monitor and essentially control heating / ventilation. 

 

On 03/10/2021 at 15:45, Jenki said:

 

How is this progressing? I'm new to RPi, but like the idea of having multiple sensors, some installed in the slab, some air mounted etc to monitor and essentially control heating / ventilation. 

 

 

Still work in progress as other projects (inc 4 poster bed) have over taken this.

On 03/10/2021 at 15:45, Jenki said:

How is this progressing? I'm new to RPi, but like the idea of having multiple sensors, some installed in the slab, some air mounted etc to monitor and essentially control heating / ventilation. 

Here is the code I use.  Just change the 28-xxxxxxxxxxxx number to your sensors number.

You can add more sensors by just copying and pasting in the part relating to the sensor while incrementing the number by one.  Then add the sensor number to the "writes to data file" line. 

 

 

#!/usr/bin/python

#imports necessary libaries
import os, time, datetime

#load drivers
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

while True:
#Sort out the time format
    dt = datetime.datetime.now()
    runday = dt.day
    dt.day == runday

 

#sensor 1
    tfile = open("/sys/bus/w1/devices/28-0306979462ca/w1_slave")
    text1 = tfile.read()
    tfile.close()
    temperature_data1 = text1.split()[-1]
    temperature1 = float(temperature_data1[2:])
    temperature1 = temperature1 / 1000

 

#sensor 2
    tfile = open("/sys/bus/w1/devices/28-031097946bbc/w1_slave")
    text2 = tfile.read()
    tfile.close()
    temperature_data2 = text2.split()[-1]
    temperature2 = float(temperature_data2[2:])
    temperature2 = temperature2 / 1000


#sensor 3
    tfile = open("/sys/bus/w1/devices/28-030197941c13/w1_slave")
    text3 = tfile.read()
    tfile.close()
    temperature_data3 = text3.split()[-1]
    temperature3 = float(temperature_data3[2:])
    temperature3 = temperature3 / 1000

 

#sensor 4
#    tfile = open("/sys/bus/w1/devices/28-03149794263a/w1_slave")
#    text4 = tfile.read()
#    tfile.close()
#    temperature_data4 = text4.split()[-1]
#    temperature4 = float(temperature_data4[2:])
#    temperature4 = temperature4 / 1000


#opens and reads the time
    ts = time.time()

#sets time to UTC and dd/mm/yyyy hh:mm:ss format
    UTC = datetime.datetime.utcfromtimestamp(ts).strftime('%d/%m/%Y %H:%M:%S')

    logfile = '/home/pi/monitoring/data/1wire-%s-%s-%s.csv' % (dt.day, dt.month, dt.year)


#creates and opens or appends data to file
    tfile = open(logfile, "a")

#writes to data file
    tfile.write("%s"%UTC + ",%s"%temperature1 + ",%s"%temperature2 + ",%s"%temperature3 + '\n')

#closes data file
    tfile.close

#sleeps for (n) seconds until next reading
    time.sleep(25)

17 minutes ago, SteamyTea said:

    tfile = open("/sys/bus/w1/devices/28-0306979462ca/w1_slave")

 

Note that those sensors are likely to be fake - genuine Maxim sensors have four zeroes in the last 16 bits of the serial number. Genuine ones are only a few quid more at the likes of CPC etc and removes any doubt about accuracy, longevity etc.

Edited by MJNewton

On 26/08/2021 at 09:54, MJNewton said:

You shouldn't have to calibrate these sensors

 

As old Ronald Reagan said: trust, but verify. ? 

6 hours ago, SteamyTea said:

Here is the code I use.  

Thanks ?

  • 2 weeks later...

I would find it quite handy to log temperatures in several rooms throughout the house.  Does anyone do neat looking sensors that I can plug into an ethernet port, with a PC based program to view the data?

1 hour ago, Mr Punter said:

I would find it quite handy to log temperatures in several rooms throughout the house.  Does anyone do neat looking sensors that I can plug into an ethernet port, with a PC based program to view the data?

Why, is it running cables, even very small ones that is the problem?

 

Here is an idea, using cheap parts, to start logging data.

https://microcontrollerslab.com/micropython-bme280-esp32-esp8266-temperature-humidity-pressure/

1 hour ago, SteamyTea said:

Why, is it running cables, even very small ones that is the problem?

 

I would like to log and display temperature data from each floor in a 4 storey house.  It has an ethernet network so I would like to use the CAT5 cable, even if I don't use proper ethernet - so maybe adapt leads either end - but proper ethernet would be my preference and view the data on my PC.

1 hour ago, Mr Punter said:

but proper ethernet would be my preference and view the data on my PC

Dead easy.

Raspberry Pi Zero W, with BME 280, power off the ethernet (POE), connect to your router, or another router, either wirelessly or via USB to ethernet adapter, up to you.

Then log data to a NAS (maybe a simple USB memory stick on the router) and read from that with the PC.

 

(edit: always check that what is in the description is the correct article, I have a few BMPs rather than BMEs because of shifty traders)

Edited by SteamyTea

11 hours ago, SteamyTea said:

Dead easy.

Raspberry Pi Zero W, with BME 280, power off the ethernet (POE), connect to your router, or another router, either wirelessly or via USB to ethernet adapter, up to you.

Then log data to a NAS (maybe a simple USB memory stick on the router) and read from that with the PC.

 

(edit: always check that what is in the description is the correct article, I have a few BMPs rather than BMEs because of shifty traders)

In my wait for planning / building warrant, this is similar to the project I'm working on. you also have the option of using RPI pico (£4), if you only want temperature as it has  inbuilt temperature.

I'm early stages at the moment. Playing with options of sending the data to a web sql database, but linking to a NAS maybe more straight forward.

I'm thinking of this RPi Display located centrally with a RPI located near the router to do the number crunching. but have not got to passing data between Pi's yet.

long term I would like to be able to control the heating from this as well.

the PICO could easily hide in one of these covers .

 

 

 

 

 

38 minutes ago, Jenki said:

you also have the option of using RPI pico (£4)

If it uses MicroPython, it may well work with the existing BME280 libraries.

I see there is some networking code on github for it.

Oh, and some BME280 code.

 

Micro electronics is just fantastic compared to mechanical engineering.

As soon as you start instrumenting a house and wanting to do more them IMO, it is just easier to bite the bullet and install Home Assistant on an RPi 4.  You get a Zigbee dongle for it and Zigbee thermometers cost a few £s each.  No need for any wiring fabric.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.