LM35+LCD+web+MySQL - 2) Lo sketch
Q
uello I am going to describe is a simple to design for measuring an internal temperature, which sees Arduino obviously used, the known sensor LM35, a classic HD44780 compatible LCD and a PC with Linux OS (eg Debian or a derivative distribution like Ubuntu). The LM35 LCD and Arduino that are connected to aa turn is connected to a PC which runs on an Apache web server, a MySQL server as well as hosting various Perl and PHP interpreters
the side Arduino:
the sensor is connected to one of the six analog inputs, while the LCD is connected to pin 7 (4 + 2 for the data for the control) of the port I / O digital Arduino. The sketch in his loop executes three very simple tasks assigned to three respective functions: dell'LM35 reads the voltage and converts it to degrees Celsius;
if the PC comes from a conventional character (eg the letter 's'), responds by sending the temperature to the PC experience (eg '15 .42' ) LCD still sends about half a second every local temperature acquired
From the PC side: the character of temperature sending request is sent from the PC to Arduino in two usage scenarios:
from the web page, on demand
, whenever the visitor opens the page itself or makes the refresh, the temperature returned by Arduino is so displayed in the web page from a script executed automatically by the system every half hour, the temperature data taken from Arduino is inserted into a MySQL database
The data stored in the database are then processed to create a graph of temperature acquired in the last 24hh. Then the server side, at a general level, we need: A first script,
fetcher, which has the fundamental task of opening the serial (USB), Arduino to send a character (eg ' s') and read from this, the temperature at that time. This script is then used to produce printing on the web page of the current temperature.
A second script,
logger, who also uses it for fetcher
take the temperature, but not see: the place to be in a MySQL database. This script is run automatically by the system every half hour, then stored in the database will read the temperature every half hour (eg 10:00, 10:30 ... etc.). A third and final script plotter, which has the task of taking from the MySQL server temperatures logged by loggers in the last 24hh and create, dynamically, an image with a graph of temperature as a function of time. This image is then displayed on a web page.
A dynamic web page (eg in PHP), call temp that every time you open it to read the temperature at that time by fetcher and printing on the screen. In addition, it must also display the graphic generated by plotter. In the remainder going into details, Arduino first side and then the PC side.
0 comments:
Post a Comment