Data transmission and protocol conversions, converters and isolators with interface RS232, RS485, RS422, USB, Ethernet, GPRS, WiFi, measurement modules, temperature and humidity sensors, I/O modules, custom-made electronic applications.

Czech version

Home > Thermometers > WEB Thermometer for your site

WEB Thermometer for your site

Do you want to measure temperature and make it available for visitors of your Internet site? Read this article. It contains an example of temperature measurement on the WEB for basic cases. Source codes for PHP are included. The temperature is measured via a following thermometers: TM (thermometer for RS232), TMU (thermometer for USB) or TME (Ethernet thermometer).

Temperature measurement

Figure 1. - Drawing of the principle of measured temperature inserting on the WEB pages in case of TM and TMU. As for TME the temperature is sent directly to the server without any need for help from the measuring station.

Internet thermometer in PHP

What you need for this solution:

  • Hosting (or intranet server) with PHP scripting.
  • Computer with connected TM or TMU temperature sensor, connected to the Internet at least from time to time or TME thermometer connected to the Internet.

The system of temperature measuring and updating on a WEB page is outlined in the drawing above. TM or TMU temperature sensor is connected to the computer at the measuring point and the control program is running. The program periodically measures the temperature via the sensor and sends it to the server on the Internet (or Intranet).

As for Ethernet thermometer TME the system of temperature transfer is even simpler. A required interval of the transfer and the Internet address of the script processing the temperature is set directly in TME. This is the only setting that needs to be done.

On the server side you will only need to insert a simple script into your WEB as described bellow, which will store the received temperature and displays it on the desired place on your site.

[The solution of temperature transfer described bellow is only the very basic solution example. This solution should naturally be enlarged with suitable security or to take measures against long-lasting failure of connection with the server.]

Utility Script

Source code of the utility script on the server:

PHP example

The script ensures both the receipt of measured temperature data and its displaying. The mentioned code can be simply saved as temperature.php file into the root directory of your WEB. If your server has an Internet name e.g. www.example.com, the address of the script will be www.example.com/temperature.php. The temperature can be stored on the server using a parameter passed to the script. A temperature of 25,6°C can be stored as follows: www.example.com/temperature.php?temp=25,6. This way you can test the script functioning. This way of temperature transfer is ensured by the control program described below.

If you subsequently open the www.example.com/temperature.php on your web browser, the text 25,6 is displayed (last passed temperature value).

The script on the server is finished. You can naturally insert it into you web pages, extend its functionalities or ensure better security. Regular updating of measured temperatures is provided by a bellow described service application. (No application is needed if the temperature is measured via the TME Ethernet thermometer. TME sends the temperature directly to the Internet without the need of any PC.)

Program for temperature measurement

What you need for this program:

  • Computer with Windows 2000 or Windows XP operation system.
  • Permanent or regular Internet connection. (Necessary for the temperature to be sent to the Internet server.)
  • Connected TM or TMU thermometer.
  • [No application is needed for TME Ethernet thermometer. TME sends the temperature without any need to use a PC.]

To download:

The control program ensures temperature measurements to be performed by TM or TMU sensors and sent to the desired Internet server. It enables to set up a measuring interval and can save the measured temperature into a file, which can be easily imported into Microsoft Excel program. The program must be run on the PC to which the thermometer is connected.

Program preview

The picture shows all the program windows. On the left you can see a minimized main window. Parameters setup window is displayed on the right.

Main Window

The Main Window shows the measured temperature and the course of the temperature sending to the Internet, or eventually errors in communication with the sensor or server. Records from this window are also stored into a text file in the format of TM2web - dd.M.yyyy.log. The file is saved in the directory where the program is stored.

The arrow to the right of the temperature can be used to minimize the main window into the shape of a narrow stripe (in the upper left-hand part of the picture).

Options button opens the Setup Window, Hide button hides the Main Window on the bottom bar in the area of the clock.

Setup Window

Target URL address - the address of the script processing the temperature on the Internet server. By pressing Send button it is possible to send the just measured data to the entered address.

Period of automatic sending to server - period in which the temperature will be sent to the Internet server. The time interval shall be set in minutes. Setting the interval to 0 discontinues the automated temperature sending to the Internet.

Source serial port - Choose the COM serial port the TM thermometer is connected to from the list or choose the virtual serial port of the TMU thermometer. Using the button to the right of the COM selection open/close the required port for the communication with the sensor. If the Automatic option is ticked, the selected port opens automatically when the program is started.

Additional setting temperatures storing into a text file

Always on top - the Main Window is always displayed on top of other windows.

Generate temperature LOG - A text file with measured temperatures will be stored every day into the directory containing the program. The file names will be stored in the following format Temperature(dd.M.yyyy).log. Each line contains one entry including the measuring date and time. The values are separated with tabulators which help to easily import the files into other programs like Microsoft Excel.

The Setup Window can be closed without saving changes by pressing the Close button or it is possible to save changes and close the window using the Save and close button.

 
Copyright © 1990 - 2008, Papouch s.r.o. All rights reserved.