Temperature sensor in Metern

Talks about metering
Post Reply
Don
Posts: 4
Joined: Wed Dec 24, 2014 9:20 pm

Temperature sensor in Metern

Post by Don » Fri Feb 06, 2015 9:49 pm

Hello,

So far I'm running this software perfectly; Thanks!

Recently I succesfully implemented (outside) temperature, pressure and humidity in the graphics of Metern. Unfortunately negative temperatures (it's freezing outside) cannot be stored in the graphics. Testing the command gives "6(-6.7*C) is not valid, the correct format is 6(1234.5*C) ". Am I doing something wrong or is there a work-around?

gr Don

jeanmarc
Posts: 1600
Joined: Thu Aug 29, 2013 7:16 am

Re: Temperature sensor in Metern

Post by jeanmarc » Sat Feb 07, 2015 8:14 am

Hi,
I was aware of the bug. It will be correct in few minutes on the next release ;)

flane
Posts: 86
Joined: Mon Aug 11, 2014 7:22 am

Re: Temperature sensor in Metern

Post by flane » Mon Feb 09, 2015 8:40 am

Hello Don,
please let you give me some details on how you did it to detect temperature, humidity and pressure with Metern?

sensor types and scripts for Metern

Thank You

framboos
Posts: 23
Joined: Fri Apr 10, 2015 7:43 pm

Re: Temperature sensor in Metern

Post by framboos » Thu Apr 23, 2015 9:59 pm

Yes Don,

I would like to know this as well, can you please give us some more details about your setup?

escix
Posts: 19
Joined: Sun Sep 01, 2013 6:22 am

Re: Temperature sensor in Metern

Post by escix » Sun Apr 26, 2015 5:09 am

Hello All,

To use a temperature sensor / or any sensor which provides actual value compare to usage value, all you have to do is make a copy of the pooler script (say poolerTemp) with the following modification:

Code: Select all

#$lastval += $prevval;
i.e comment out the above line in the copied poolerTemp.

Use this as the command for the meter.

you may refer to my thread in this forum on modified scripts.

jeanmarc
Posts: 1600
Joined: Thu Aug 29, 2013 7:16 am

Re: Temperature sensor in Metern

Post by jeanmarc » Sun Apr 26, 2015 6:19 am

Hi,
There is a much simple script in comapps/example.php ;)

Don
Posts: 4
Joined: Wed Dec 24, 2014 9:20 pm

Re: Temperature sensor in Metern

Post by Don » Sun May 31, 2015 11:43 pm

Quite late response ... sorry ... :oops: I'm not that often reading this forum ....
I've never learned writing scripts the official way... but I can tell you, the scripts I use, they work :)

System: Raspberry Pi and Wheezy

/var/tmp is a tmpfs dir

/etc/modules contains
snd-bcm2835
i2c-dev
i2c-bcm2708
bcm2708_wdog
w1-gpio w1-therm

For temperature:
Hardware: two DS18B20 (temperture outside and temperature of a heating tube)

Edit /boot/config.txt / add line:
dtoverlay=w1-gpio,gpiopin=4

python script: Change sensor ID!

Code: Select all

#!/usr/bin/python
import os
import glob
import time

os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28-0114653f67ff')[0]
device_file = device_folder + '/w1_slave'
device_folder2 = glob.glob(base_dir + '28-01146606b8ff')[0]
device_file2 = device_folder2 + '/w1_slave'

def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines

def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        time.sleep(0.0)
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        temp_f = temp_c * 9.0 / 5.0 + 32.0
        return temp_c

def read_temp_raw2():
    f = open(device_file2, 'r')
    lines2 = f.readlines()
    f.close()
    return lines2

def read_temp2():
    lines2 = read_temp_raw2()
    while lines2[0].strip()[-3:] != 'YES':
        time.sleep(0.0)
        lines2 = read_temp_raw2()
    equals_pos2 = lines2[1].find('t=')
    if equals_pos2 != -1:
        temp_string2 = lines2[1][equals_pos2+2:]
        temp_c2 = float(temp_string2) / 1000.0
        temp_f2 = temp_c2 * 9.0 / 5.0 + 32.0
        return temp_c2

temp_buiten = read_temp()
with open("/var/tmp/buitentemp_nu.txt", "w") as text_file1:
    text_file1.write("6(%s*C)" % temp_buiten)

temp_cv_buis = read_temp2()
with open("/var/tmp/cvbuistemp_nu.txt", "w") as text_file2:
    text_file2.write("9(%s*C)" % temp_cv_buis)

For pressure:
Hardware: BMP085
raspi-config: add i2c support
install python smbus: sudo apt-get install python-smbus

python script:

Code: Select all

#!/usr/bin/python

from Adafruit_BMP085 import BMP085

bmp = BMP085(0x77)

temp = bmp.readTemperature()

pressure = bmp.readPressure()
altitude = bmp.readAltitude()

print "8(%.2f*hPa)" % (pressure / 100.0)
Update every minute:
Added two line in /etc/crontab
*/1 * * * * root python /home/pi/weer/luchtdruk.py > /var/tmp/pressure_nu.txt
*/1 * * * * root python /home/pi/weer/temperatuur_buiten_cvbuis.py

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest