Toon app: temperature readings

Forum about forum-provided applications on Toon

Moderators: marcelr, TheHogNL, Toonz

Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Toon app: temperature readings

Post by Toonz »

On may 25th, 2017, posts pertaining to temperature logging were compiled into this separate thread. You may see remnants of other threads in the first few posts.

something completely different: I am working on an app to capture the actual room temperature and the programmed temperature level for the last 24 hours (rolling).
I keep an array in memory with the data points in intervals of 10 minutes. I noticed that at 04:00 (03:00 system time on my Toon) all data from memory is cleared.
Does anyone know what is happening at 03:00? I also noticed a lot of logfiles are written at that time but they do not contain any serious warnings/errors.
The workaround will be to write the 24h data to a local file each time but I am just curious what is going on.
temp.PNG
temp.PNG (9.04 KiB) Viewed 20374 times
log.PNG
log.PNG (29.53 KiB) Viewed 20374 times
member of the Toon Software Collective
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Software: modifications and extensions Toon

Post by marcelr »

Not sure what's happening, but I can imagine that quby wants to remove data from memory. Space is tight on toon.
An in-between solution might be the following:
I have been logging room temperature on my production toon for the last 10 months or so, with the following script:

Code: Select all

#! /bin/sh
#
# Script for reading toon room temperature values and storing them in a file.
# Data are stored on a daily basis: data for every day are put into a new file.
#
#   call: ./read_temp.sh outputfile_prefix
#
# The current date and .txt extension are added automatically.
#
#   example: ./read_temp.sh test &
#
# will yield files like: test-20151222.txt (and runs in the background, 
# so you can close your shell without stopping the logging).
#
# note 1: Toon fills in UTC timestamps, please correct afterwards for your 
#         timezone.
#
# note 2: Toon temperature values have an offset of -6 degrees (variable 
#         i2cTempError, in the happ_thermstat code, default value -6.0),
#         or -6 degrees + your manually entered temperature correction. 
#         To get the actual values, please correct for this offset.
#	  
# note 3: Timing isn't really spot-on. The sleep command creates intervals, not 
#         accurately timed interrupts, so intervals between samples will be 
#         slightly larger.
#
# marcelr, 20160327, store data in ramdisk, write to flash only once per day.
#
# marcelr, 20151222, first draft.
#

RAMDISKPATH=/var/volatile/local
DEST_PATH=/root/OTGW

# 
# temperature value files for toon (internally, toon uses the second file):
#
file0="/sys/devices/platform/imx-i2c.0/i2c-0/0-0048/device0/value"
file1="/sys/devices/platform/imx-i2c.0/i2c-0/0-0049/device1/value"

# set initial value for date cut-off (1 day + 1 second, to make sure it's used 
# in the very first loop iteration, even if you switch on the code at 
# midnight, sharp.)

sec_day_old=86401

today="`date +%Y%m%d`"
filename="$1-$today.txt"

mkdir -p $RAMDISKPATH
mkdir -p $DEST_PATH

while true; do
    read -r line < "$file0"
    t0=$line
    read -r line < "$file1"
    t1=$line
    unix_time=`date +%s`
    sec_day=`expr $unix_time % 86400`

# construct output filename

    if [ "$sec_day" -lt "$sec_day_old" ]; then

#       Clock has been reset to a value near 0; Date has been incremented.
#       Move file from RAMdisk to flash:

	if [ -e "$RAMDISKPATH/$filename" ]; then
	    mv $RAMDISKPATH/$filename $DEST_PATH/$filename
	fi

#       set filename for this day:

	today="`date +%Y%m%d`"
	filename="$1-$today.txt"
    fi
    sec_day_old=$sec_day
	
    echo -e "$unix_time\t$t0\t$t1" >> $RAMDISKPATH/$filename
    sleep 60
done
It stores temperatures every minute, with a timestamp, in a file on a ramdisk. At the end of the day, the file is moved to flash, and a new one opened.
Haven't had any glitches so far. The only thing is, when you reboot or powercycle your toon, the data in ramdisk are lost.

best,

marcelr
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Software: modifications and extensions Toon

Post by Toonz »

Nice! out of curiosity: do you cleanup historical daily txt files manually?
member of the Toon Software Collective
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Software: modifications and extensions Toon

Post by marcelr »

Haven't done that yet. So far, it's a bit over 9MB worth of disk space, for 322 days.
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Software: modifications and extensions Toon

Post by Toonz »

marcelr wrote: I have been logging room temperature on my production toon for the last 10 months or so, with the following script:
....
Marcel, just an observation: on my dev toon the Toon temperature values have an offset of -6 degrees, using the on/off boiler config (no boiler attached at all). On my production toon (OpenTherm interface) I noticed that the Toon temperature values have an offset of -5 degrees. In both systems the variable I2cTempError, in the happ_thermstat code, have the value -6.0) and both systems have no manually entered temperature correction. Beats me.....

Edit: dev toon on fw 3.2, prod toon on fw 3.6
member of the Toon Software Collective
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Software: modifications and extensions Toon

Post by Toonz »

Hi all,

I hereby post the final version 7 of the Buienradar app. Marcel feel free to move it to the download section.

EDIT (marcelr): Done. You can find the download file in the downloads thread.

Changelog:
- none - functionally the same as the previously posted 7.0.2 version. Fully compatible with the current XML file contents from Buienradar.
However, I was working on my new project in the same app. Some screens and modules were included in last post but not active. This final version of buienradar is clean and therefore 4K smaller.

In case you are interested in what I was doing: I wrote functionality to log the actual temperature and program temperature for the last 24 hours (rolling).
It was working but I found the added value rather low for a couple of reasons: the graph looks the same almost every day on my production Toon and it uses quite some system resources. With Marcel's solution to log the temperature with the -sh script you can easily pickup those temperature log files and make much more beautiful graphs in Excel or so.

If someone is interested I am happy to share the code (don't take it from 7.0.2beta, wasn't finished then).
screenshot taken 18:15 (n.b. restarted qt 23:30 yesterday) from my DevToon in the attic (without heating :-) ):
screenshot_temp_monitor.png
screenshot_temp_monitor.png (26.4 KiB) Viewed 20749 times
member of the Toon Software Collective
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Software: modifications and extensions Toon

Post by Toonz »

something completely different: a simple app to log and show actual temperature and target temperature (programmed or manually set) of the last 24 hours (rolling).
The graph is defined in AreaGraphMod.qml which is a modified version of the default component AreaGraph.qml.
Both values series (red and blue) are at 50% opacity, overlapping areas will therefor be purple.

Readings are taken from happ_thermstat every 10 minutes and stored in two files in var/volatile (give it two 10min cycles to initiate properly).
In case you asking what's wrong with my heating unit: this dev Toon is in the attic and not connected to a heating unit :-)
But it works fine on my production Toon.

Install by copying the folder temperatureLogger to the apps folder on Toon and add 'temperatureLogger' to the Globals.qml file as usual.
Screen can be opened via the thermometer icon in the systray.

Welcome any feedback or suggestions (positive or negative :-) ).
By the way, I will be toon-less coming week (schoolholidays).
Screenshot_templog.jpg
Screenshot_templog.jpg (93 KiB) Viewed 20451 times
Attachments
ToonTemperatureLogger_V0.1.zip
(8.54 KiB) Downloaded 610 times
member of the Toon Software Collective
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Software: modifications and extensions Toon

Post by marcelr »

Good job again, Toonz!

Is there a simple way to incorporate this into the existing graphs screen (by adding more tabs and/or tick boxes to the "stroom" and "gas" graphs)? Might save some memory, although this one in particular is not a large app, in terms of code size. Not sure how it works out in memory requirements.
My production toon with boiler status, buienradar and x11vnc has not a lot of memory left, and sometimes the qt-gui just overloads the memory usage to the extent that the gui gets killed and restarted (especially when using x11vnc).
I am not well versed in the internals of qml, but my guess would be that (using the right #pragma's) a lot of code can be forced to be loaded into memory just once.

BTW, enjoy your holiday.
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Software: modifications and extensions Toon

Post by Toonz »

marcelr wrote:Good job again, Toonz!

Is there a simple way to incorporate this into the existing graphs screen (by adding more tabs and/or tick boxes to the "stroom" and "gas" graphs)? Might save some memory, although this one in particular is not a large app, in terms of code size. Not sure how it works out in memory requirements.
My production toon with boiler status, buienradar and x11vnc has not a lot of memory left, and sometimes the qt-gui just overloads the memory usage to the extent that the gui gets killed and restarted (especially when using x11vnc).
I am not well versed in the internals of qml, but my guess would be that (using the right #pragma's) a lot of code can be forced to be loaded into memory just once.

BTW, enjoy your holiday.
Hi Marcel,

incorporating into the standard graph screens has some disadvantages, because it will be tied to a certain release and needs updating after each new firmware release (if they change the graph app). Secondly, my version has a 33% higher graph area to make it more easy to read temperatures (I made room by removing the top buttons of the original graph screen). I prefer to keep it stand-alone to be honest.

For the reasons you mentioned I haven't installed x11vnc of my production toon. On my devtoon I use x11vnc it frequently (not started on boot, just manually when needed) and in combination with qui-restarts with the console output redirection it gives stability issues rather quickly. I am therefor rebooting the dev toon regularly.
I will do some further work on the temparatureLogger app to minimize it's memory footprint and remove all unused elements from the AreaGraphMod.qml.
Will thoroughly test on boot Toons.

Regards,

Toonz
member of the Toon Software Collective
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Software: modifications and extensions Toon

Post by Toonz »

Hi all,

hereby the final version of the temperature logger app, good for daily use. Tested on two Toons for a couple of days without issues.
It shows a graph (via a tray icon) of the actual and programmed temperature of the last 24h.
This version is highly optimized, all unnecessary code (ahum , most at least :) ) is removed to minimize required space on disk as well as memory usage.

Changelog compared to the earlier beta version:
- no reading and writing of the 24 values anymore to a temporary file before and after each reading .
Full table is kept in ram only. Only disadvantage: when the qt gui restarts all data from the last 24h is lost but will be build-up again of course
- y-axis scale is now 12-28 degrees instead of 0-32 before, which makes it much more easier to read specific values
- javascript module simplified
- all unused elements/functions removed from the AreaGraphMod.qml
- temperatureLoggerApp.qml simplified significantly.

Hope you like it.

One possible future feature (if there is a need, just let me know):
- save the readings of the last 24h every day to a separate file for external usage.

Sample screenshot from my dev toon in the attic (without heating ;-) ):
temperatureLogger.png
temperatureLogger.png (63.83 KiB) Viewed 21157 times
Attachments
Toon_temperatureLogger_V1.zip
(7.78 KiB) Downloaded 613 times
member of the Toon Software Collective
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Toon app: temperature readings

Post by Toonz »

HI all,

A new version of the temperature logger app.

Changelog:
1.2
- added a third graph with outdoor temperatures taken from buienradar.
in order to see this data the buienradar app must be installed as well (version 8.0.5 or higher)
ToonTemperatureLogger_V1.2.zip
(8.98 KiB) Downloaded 642 times
Regardz,

Toonz
Attachments
Temp_1.2.png
Temp_1.2.png (29.33 KiB) Viewed 19405 times
member of the Toon Software Collective
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Toon app: temperature readings

Post by Toonz »

Hi all,

version 1.3.0 is now available in the ToonStore.
Changelog:
- Y-axis can be moved up and down to cater for outdoor summer and winter temperatures
- readings are now saved to a file and available again after a gui-restart
temperaturelogger_screenshot_1.png
temperaturelogger_screenshot_1.png (69 KiB) Viewed 18356 times
Kind regardz,

Toonz
member of the Toon Software Collective
jeltel
Starting Member
Starting Member
Posts: 18
Joined: Tue Dec 05, 2017 10:16 pm

Re: Toon app: temperature readings

Post by jeltel »

Toonz wrote:Hi all,

version 1.3.0 is now available in the ToonStore.
Changelog:
- Y-axis can be moved up and down to cater for outdoor summer and winter temperatures
- readings are now saved to a file and available again after a gui-restart
temperaturelogger_screenshot_1.png
Kind regardz,

Toonz
I really like this small app. But since a few days buienrader has been put behind https. And https is not supported by Toon. So there is no buitentemperatuur.
The buienrader app has implemented something and is working again. It uses a wget to get buienradar data. Can you use the buitentemperatuur from this app in your app?

Edit: nevermind. It's updating now. Cron from buienradar had to be manually restarted.
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Toon app: temperature readings

Post by Toonz »

Hi all,

A new version (1.3.2) has been published on Toonstore.
Changelog 1.3.2
- now compatible with firmware 4.16.8 (the up and down scroll arrows are now shown on the graph)
- no need to update on older firmwares (can't harm either)

Kind regardz,

Toonz
member of the Toon Software Collective
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Toon app: temperature readings

Post by Toonz »

Hi all,

version 1.3.3 is available on ToonStore.
Changelog:
- firmware 5 compatibility of the installer, no new functionality

Kind regardz,

Toonz
member of the Toon Software Collective
Post Reply

Return to “Toon Apps”