The main project contains several files. To best present things, we'll only concentrate on two files:
server.js
: This is the file that will create our web server and send data to the HTML web pageindex.html
: This is the page that will open the web browser to display the data received
The server.js
file creates a server on the listening port 3344
and will be responsible for creating a socket (rpi_temperature
) that contains the CPU temperature of Raspberry Pi. The socket function uses, among others, the vcgencmd
command (
https://github.com/raspberrypi/firmware/blob/master/opt/vc/bin/vcgencmd
), permitting us to monitor the CPU temperature, as shown here:
setInterval(function() { child = exec("vcgencmd measure_temp | awk -F:", function (error, stdout, stderr) { if (error !== null) { console.log('exec error: ' + error); } else { var date = new Date().getTime(); ...