In a previous tutorial, we covered how to connect and read from DS18B20 sensors with your Beaglebone. I’d now like to cover the process of displaying live-updating DS18B20 temperatures in your browser using a Beaglebone Black. We’ll be using Socket.IO, a simple library that can be used to quickly communicate between a web browser and the server using the web sockets protocol. This tutorial will display all connected DS18B20 sensors in a nicely formatted table. This is geared towards developing a basic understanding how to use nodeJS with Socket.IO and the DS18B20 sensor. It can be used as a groundwork to use temperature readings in graphs and other formats. I use very similar code to turn on or off my connected SSR and pump relays.

DS18B20 Temperatures In Your Browser


I will assume you already have the following installed:


The Beaglebone and Raspberry Pi nodeJS development community is quite active. This means there are a lot of libraries available that make it simple to do tasks on your Beaglebone. For example, we will be using a package specifically for reading DS18B20 temperatures.

Install NodeJS Packages

In a SSH session, move the current directory to your webserver’s document root (i.e .e /var/www) and install the necessary Node packages.

The necessary packages should now be installed into the directory ./node_modules/

Create app.js

Using your favorite text editor or IDE, let’s create the app.js file. This file is the node script that will be performing most of the work. It is responsible for the periodic reading of sensor values and sending them to connected web browsers.

Copy and paste the following into the file app.js:

Save and close as app.js.


Next you will need to create the file index.html. This file is loaded by your web browser and contains code to handle variables emitted from socket.IO.

Save and close as index.html.

Wrapping it up

You’re ready to test out your node script! Start the script using node app.js. You’ll need to leave open your current terminal window as the process is linked to your login when you run it like this.

Open up index.html in your web browser. In a few seconds, you should see live updating temperature readings from each connected DS18B20 sensors.