Main menu:

Contact

Papouch store s.r.o.
Strasnicka 3165/1b
102 00 PRAGUE 10
Czech Republic

Telephone:

+420 267 314 267

Fax:

+420 267 314 269

info@papouch.com

Skype:

Payments

In our e-shop you can also pay by credit cards MasterCard®, Maestro®, VISA® and VISA Electron®.
Additional Options

Links

Downloads:

Downloads...


Products > Measurement > Thermometers and Hygrometers > RS232 > TM_Mikrotik: thermometer for Mikrotik RouterBOARDs >

TM_Mikrotik: thermometer for Mikrotik RouterBOARDs

Product code: TM_Mikrotik2
Warranty: 3 years
VAT: 21%
Price inc VAT: 20.57 €
Price ex VAT: 17 €
TM_Mikrotik - RS232 thermometer for RouterBoards Mikrotik

Description

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.

	/system scheduler
	add disabled=no interval=1d name=Refresh_TM on-event="/port remote-access set 0 d\
	    isabled=yes\r\
	    \n\r\
	    \n:delay 2\r\
	    \n\r\
	    \n/file remove tm.dat\r\
	    \n\r\
	    \n:delay 2\r\
	    \n\r\
	    \n/port remote-access set 0 disabled=no" policy=\
	    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.):

	/system scheduler
	add disabled=no interval=1m name=Send_TM on-event="/tool fetch mode=\"ftp\" \
	    address=\"ftp.example.com\" user=\"user_tm\" password=\"tm_user_pwd\" src-pat\
	    h=\"tm.dat\" dst-path=\"tm_factory0086.dat\" upload=\"yes\" ascii=\"no\" keep\
	    -result=\"no\"\r\
	    \n\r\
	    \n:delay 5\r\
	    \n\r\
	    \n/tool fetch mode=\"http\" url=\"http://temp.example.com/tmp/maker.p\
	    hp\?do=factory0086\" keep-result=\"no\"" policy=\
	    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);
	};
	?>

Images




Files:

Downloads


tm-routerboard-thermometer-mikrotik.pdfDocumentation

Documentation of TM Mikrotik thermometer.

File size: 240 kB

Date: 04-10-2012

Download


Related products





Do you have any question or a suggestion? We would like to hear it!


If you have any question, suggestion or just a note, we are pleased to hear all about it! Just write it in the following form and send it, simple as that. You can also contact us or our distributor by phone or e-mail, all can be found in contacts.




ERROR