TM_Mikrotik: thermometer for Mikrotik RouterBOARDs

This version of thermometer TM is designed specifically for Mikrotik RouterBOARDs. Thermometer is connected to the RouterBOARD's serial port and it is powered from the same port. With this thermometer...more information
TM_Mikrotik - RS232 thermometer for RouterBoards Mikrotik
TM_Mikrotik - RS232 thermometer for RouterBoards Mikrotik
Connecting external sensor or switch and external power supply
Connecting and adjusting thermometer for Mikrotik
RouterBoard RB411 with connected thermometer
RouteBoard Mikrotik with thermometer
RouterBoard Mikrotik RB411
Web thermometer from TM Mikrotik
TM_Mikrotik: thermometer for Mikrotik RouterBOARDs
TM_Mikrotik: thermometer for Mikrotik RouterBOARDs
TM_Mikrotik: thermometer for Mikrotik RouterBOARDs
TM_Mikrotik: thermometer for Mikrotik RouterBOARDs
17,00 EUR excl. VAT20,57 EUR incl. VAT
More than 20 units in stock
Wednesday 20.11.With a delivery company:tomorrowPersonally in Prague:
CodeTM_Mikrotik2Warranty36 monthsCustoms Code90251920Weight18 g
Show more

This version of thermometer TM is designed specifically for Mikrotik RouterBOARDs. Thermometer is connected to the RouterBOARD's serial port and it is powered from the same port. With this thermometer you can measure temperature from 2 points or monitor a status of switch.

This version of thermometer TM Mikrotik is derived from standard serial TM thermometer.

Features of thermometer for Mikrotik

Product is part of Made for Mikrotik program.

  • Thermometer for RouterBoards Mikrotik.
  • Powered from the RouterBoards COM port - extremely low power consumption.
  • Integrated temperature sensor.
  • External input: For second temperature sensor or monitoring the status of switch.
  • External sensor with a length up to 20 m.
  • After turning on the thermometer sends current data (temperature and status of a switch) to RouterBoard every 10 sec.
  • Communication speed 9,6 kBd or 115,2 kBd.
  • Measurement of temperature in Celsius or Fahrenheit.
  • The possibility of an external power supply.
  • The possibility of a serial line connected to a non-standard cable.
  • Measures temperatures from -55 °C to +125 °C, 0,1 °C resolution
  • Operating temperature range: -20 to +70 °C
  • This thermometer is a part of Made for Mikrotik program - we are among MikroTik Certified Integrators.

Usage

  • How to connect TM Mikrotik to the RouterBOARD Mikrotik.
RouteBoard Mikrotik with thermometer

Thermometer connected to the RouterBoard RB411 (click to enlarge)

Transfer and publishing temperature to the web server

The following guide is an example how TM Mikrotik can be used to send temperature on the server and display it in the graph. The author of instructions and scripts is lwq.cz. Thank you for your cooperation.

Web thermometer from TM Mikrotik

Example of measured temperature on TM Mikrotik, connected to RouterBoard - online teploty.lwq.cz/hostivar

The general procedure, What is needed?
  1. RouterBoard with RS232 or PC with installed RouterOS version 4.x or later (tested with version 5.9 on RB411U).
  2. TM_Mikrotik must be correctly set up using jumper switch. Described in the documentation for thermometer.
  3. After connecting thermometer to RS232 the activity is indicated by LED.
  4. It is necessary to have unused RS232 (software unused port) for connecting TM Mikrotik.
  5. Then set remote-access with logging for serial0 and appropriate scripts.
  6. Data file is uploaded using FTP on the server and second script in RB sends commands to the first script for data processig.
  7. Data is saved to the MySQL database and then presented - for example in application code.google.com/p/tmep/
The specific procedure for setting RouterOS on RouterBOARD:

Scripts below is necessary execute via ssh/telnet or RouterBoards terminal.

  1. Turn off the system console on serial0 (on /system console print is serial0 number 0):
    /system console set 0 disabled="yes"
  2. Setting remote-access on serial0 with logging traffic.
    /port remote-access add allowed-addresses=0.0.0.0/0 channel=0 disabled="no" log-file="tm.dat" port="serial0" protocol="raw" tcp-port=0
  3. Create two tasks that run periodically:
First script - runs once a day

First script controls turning off remote-access on thermometer port, deleting data file and restarting the logging. This script runs once a day. It can be run more often, but it is necessary only for very slow data lines. Script sends one file with max. file size 150kB, which is logged all day (file size increases - file transfer is greatest at night, when the Internet usage drops). If the script ran more often the transferred file would be smaller, but log file in the RouterBoard would be more filled and settings would be changed too often. Permissions are set to the minimum necessary for operation.

01 /system scheduler
02 add disabled=no interval=1d name=Refresh_TM on-event="/port remote-access set 0 d\
03     isabled=yes\r\
04     \n\r\
05     \n:delay 2\r\
06     \n\r\
07     \n/file remove tm.dat\r\
08     \n\r\
09     \n:delay 2\r\
10     \n\r\
11     \n/port remote-access set 0 disabled=no" policy=\
12     read,write,test start-date=mar/27/2012 start-time=01:00:03
Second script - runs e.g. once per minute

Second script controls sending regular data, for example every minute via FTP to a remote server and then run the script located here for data processing (addition to MySQL, etc.):

01 /system scheduler
02 add disabled=no interval=1m name=Send_TM on-event="/tool fetch mode=\"ftp\" \
03     address=\"ftp.example.com\" user=\"user_tm\" password=\"tm_user_pwd\" src-pat\
04     h=\"tm.dat\" dst-path=\"tm_factory0086.dat\" upload=\"yes\" ascii=\"no\" keep\
05     -result=\"no\"\r\
06     \n\r\
07     \n:delay 5\r\
08     \n\r\
09     \n/tool fetch mode=\"http\" url=\"http://temp.example.com/tmp/maker.p\
10     hp\?do=factory0086\" keep-result=\"no\"" policy=\
11     ftp,read,write,test start-date=mar/27/2012 start-time=23:03:57

Now we have set to send data from RouterBoard and the server can process the data furthermore.

Processing temperatures of the RouterBoard on the server

In the below example a modified application TMEP 4.2 is used. This application processes data from thermometer. Example of the marker.php script:

	<?php
	//"factory0086" is unique ID of each TM_Mikrotik (security reasons etc.)
	if ($_GET["do"] == "factory0086") {
	    $aFile = @file("./tm_hostivar.dat"); //change path to *.dat file if you need so
	 
	    if (count($aFile) > 1) { // something wrong ? do nothing
	 
	        // go line by line (here you can add much more useful cmds)
	        for ($i = 0; $i < count($aFile); $i++) {
	             
	            // ignore lines shorter then 5 chars (+5.5C is needed minimum)
	            if (strlen($aFile[$i]) < 4) continue;
	         
	            $aTMP = explode(";", trim($aFile[$i])); // trim off useless chars etc.
	            // make array of LAST measured temperatures (converted to valid float values)
	            $aTemp = array("temp_1" => floatval(substr($aTMP[0], 0, strlen($aTMP[0])-1)), "temp_2" => floatval(substr($aTMP[1], 0, strlen($aTMP[1])-1)));
	        }
	 
	         // the URL for TMEP 4.2 input file
	        $sUrl = "http://temp.example.com/index.php?temp_factory0086=";
	         
	        // a little of debug response (to receive this on Mikrotik, you would need to change keep-result to "yes" at fetch http command
	        ?>
	        <html>
	            <body><?php echo "Success ! (".$aTemp["temp_2"]."C)"; ?></body>
	        </html>
	        <?php
	        @file($sUrl.$aTemp["temp_2"]); // call input file of TMEP 4.2
	    };
	} else {
	 
	    // security feature - if is this script called by browser or some unexpected way then redir to some web starts
	    Header("Location: http://temp.example.com/", TRUE, 301);
	};
	?>
Parsing measured values from a log file

The following script allows to parse measured values as varibales from a log file, thus data can be further processed, e.g. evaluate and send reports of temperature overheating or contact closure. Script was taken from this Mikrotik forum.

:global content [/file get [/file find name=tm.txt] contents] ;
:global contentLen [ :len $content ] ;

:global lineEnd 0;
:global line "";
:global lastEnd 0;

:do {
  :set lineEnd [:find $content "\n" $lastEnd ] ;
  :set line [:pick $content $lastEnd $lineEnd ] ;
  :set lastEnd ( $lineEnd +2 ) ; 
  
  :global entry [:pick $line 0 $lineEnd ]
  
} while ($lastEnd < ( $contentLen -2 ) )

  :log info [:pick $line 2 7 ] 
  :log info [:pick $line 8 ]
Mutace obrazků;;;;;;;;1029;1029;;;;1029

tm-routerboard-thermometer-mikrotik.pdfDocumentation

Documentation of TM Mikrotik thermometer.

File size: 240 kB

Date: 04-10-2012

Download

TM_Mikrotik - RS232 thermometer for RouterBoards MikrotikTM_Mikrotik - RS232 thermometer for RouterBoards Mikrotik
Connecting external sensor or switch and external power supplyConnecting external sensor or switch and external power supply
Connecting and adjusting thermometer for MikrotikConnecting and adjusting thermometer for Mikrotik
RouterBoard RB411 with connected thermometerRouterBoard RB411 with connected thermometer
RouteBoard Mikrotik with thermometerRouteBoard Mikrotik with thermometer
RouterBoard Mikrotik RB411RouterBoard Mikrotik RB411
Web thermometer from TM MikrotikWeb thermometer from TM Mikrotik
TM_Mikrotik: thermometer for Mikrotik RouterBOARDs
TM_Mikrotik: thermometer for Mikrotik RouterBOARDs
TM_Mikrotik: thermometer for Mikrotik RouterBOARDs
TM_Mikrotik: thermometer for Mikrotik RouterBOARDs
DescriptionDownloadPicturesAccessories