Easiest way to log temperatures?

Moderator: Telldus

Post Reply
musjuh
Posts: 2
Joined: Fri Mar 17, 2023 9:45 am

Easiest way to log temperatures?

Post by musjuh »

Which is the easiest way to log temperatures between a Tellstick Duo and a Raspberry Pi?

My goal is to store temperature and humidity values over time and present them on a simple webpage, much like it is described
here http://ovla.blogg.se/2013/february/valk ... blogg.html. Unfortunately the script tdtool2.py is only for Tellstick Net so I'm stuck at the moment. There are several mentions of an adapted tdtool.py för Tellstick Duo but I can't find it. Any help is greatly appreciated.
pglpgl
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: Easiest way to log temperatures?

Post by pglpgl »

1. Store data in a txt file
2. FTP on the web where PHP
3. Process the txt file to the database MySQL
4. Simple Web, all in PHP, example www.senzorsnu.cz
mdi
Posts: 18
Joined: Fri Mar 17, 2023 9:45 am

Re: Easiest way to log temperatures?

Post by mdi »

Hei,
here is a quick demo, with trends on temp & humidity
https://dasdata.co/x.aspx?das=SVj9yc/03 ... 1gUq832w==

just make an account and store any data you wish!

:wave:
SuperCed
Posts: 8
Joined: Fri Mar 17, 2023 9:45 am

Re: Easiest way to log temperatures?

Post by SuperCed »

It's quite easy.

Copy tdtool to the directory where you want to execute this PHP script :

Code: Select all

<?php
// Report all errors except E_NOTICE
ini_set('error_reporting', 'E_ALL ^ E_NOTICE');

// crontab -e
// /opt/local/bin/php /opt/local/apache2/htdocs/cedhome/logger.php
define('GLOBAL_PATH', '/opt/local/apache2/htdocs/cedhome/');

include(GLOBAL_PATH.'includes/include_top.php');

$output = '';
$vars = '';
$str = exec(GLOBAL_PATH.'tdtool --list-sensors', $output, $vars);

$index_time = mktime();

foreach($output as $key => $value) {
 	$tab = explode("\t", $value);
 	
 	//echo "\n TAB";
	//var_dump($tab);
	$time = null;$id = null;$temperature = null;
	foreach($tab as $key2 => $value2) {
		$tab2 = explode("=", $value2);
		switch ($tab2[0]) {
			case 'id':
				$id = $tab2[1];
				break;
			case 'temperature':
				$temperature = $tab2[1];
				
				break;
			case 'humidity':
				$humidity = $tab2[1];
				break;
			case 'time':
				$time = $tab2[1];
				break;
		}
	}
	if ($time && $id && $temperature) {
		$sql = "INSERT INTO `cedhome`.`log_temp` 
			(`log_id`, `id`, `temperature`, `humidity`, `log_date`, `index_time`) 
			VALUES (NULL, ".(int)$id.", '".addslashes($temperature)."', '".addslashes($humidity)."', '".addslashes($time)."', '".$index_time."')";
		echo "\n".$sql;
		ced_mysql_query($sql);
		
	}
}



include(GLOBAL_PATH.'includes/include_bottom.php');

?>
Post Reply