Jump to content

Cheap (and accurate) temperature data logging


dnb

Recommended Posts

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.  

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 .

 

 

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...