Notice: Undefined index: order_next_posts in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 194

Notice: Undefined index: post_link_target in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 195

Notice: Undefined index: posts_featured_size in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 196

Monitor CPU temperature with Dizmo

Turn your Raspberry Pi into an Internet of Things with this CPU temperature gauge tutorial

The Raspberry Pi is an exciting prospect for people interested in an Internet of Things – size, power and flexibility make it perfect for powering any Internet-connected device around the home or office. Setting up a Raspberry Pi to be the brain of an IoT network isn’t exactly a case of selecting the right software in Raspbian, though; there’s a lot of custom work you need to do to get one going.

This is where Dizmo comes in, enabling you to control IoT objects using an online API that you can then access remotely. To show you how it works, we’re going to have it track the Raspberry Pi’s core temperature. In this tutorial we are going to work entirely over SSH, but you can easily do this straight on the Pi – the benefit of SSH though is that for a real IoT, it will be easier to maintain remotely.

Dizmo is designed to be a multi-touch interface
Dizmo is designed to be a multi-touch interface


Step 01 Dial into your Pi

Make sure your Raspberry Pi can connect to your network, either via Wi-Fi or ethernet cable, and find out he IP address by using ifconfig. Use this IP to dial into the Pi from another system with:

$ ssh pi@[IP address]

Step 02 Install dizmoSpace

If you haven’t already, grab dizmoSpace and install it to the system you plan for it to work with. All you need to do is download the zip and unpack it, then click the Dizmo icon or run it from the terminal.

Step 03 Launch issues?

If Dizmo is complaining about libraries when you try to run it, you’ll need to install some extra software. Open the terminal on the PC you’re working from and install the extra software with the following:

$ sudo apt-get install libavahi-compat-libdnssd-dev
$ sudo apt-get install libavahi-client-dev

Step 04 Download node.js

Now, we need to grab the latest version of node.js for the Raspberry Pi. Back in the SSH connection to your Raspberry Pi, use the following:

$ sudo wget
$ sudo dpkg -i node_latest_armhf.deb

Step 05 Add framework

Use node -v to check if it’s installed correctly – it should spit out a version number for you. Once that’s done, install express.js, which will be our web application framework:

$ sudo npm install -g express
$ sudo npm install -g express-generator

Step 06 Install framework

We’ll create the folder www in var and create a symlink for everything to run. Do this by moving to var, creating www and making the symlink with:

$ cd /var
$ sudo mkdir www
$ cd www
$ sudo ln -s /usr/local/lib/node_modules/ /node_modules

Step 07 Package file

First, create the file package.json with sudo nano package.json ,then enter:

“name”: “ServeSysinfo”,
“version”: “0.0.1”,
“dependencies”: {“express”: “4.x”}

Step 08 App node

Now, create a file called app.js and enter the following:

var express = require(‘express’);
var app = express();
app.use(express.static(__dirname + ‘/public’));
app.listen(3000, function(){
console.log(‘listening on *.3000’);

Step 09 Start node.js

You can now start the node server by typing in:

$ node app.js

It will say it’s listening on *.3000. Start up a new terminal, ssh in, and create the folder /public with mkdir /public to save all of the CPU data in.

Step 10 CPU information

We are going to use the vcgencmd command to get the CPU information from the Raspberry Pi. We will write a script that will do this and then write the info to sysinfo.json. Download the file from FileSilo and put it in /usr/local/bin.

Step 11 Make a cronjob

We will make it so that the temperature is updated every ten minutes. You can make it update much faster if you want, but have a play around with that. Open up cron with sudo crontab -e and add this at the end:

*/10 * * * * /usr/local/bin/

Step 12 Start creating the widget

It is time to actually start building the widget. First of all, create a folder on your local machine called Gauge and cd to it. Now you need to download the first file called info.plist into the working folder.

Step 13 Index file

A Dizmo widget is basically a HTML file, packaging resources together to create an interface or graphic. Here, we have the main HTML file that uses jQuery, which helps display the temperature. Still into the Gauge folder, download index.html.

Step 14 Style guide

Now we’ll add the CSS style sheet for the Dizmo widget. As usual, this styles up the display on the page that will become our widget. Download style.css and put it in the Gauge folder.

Step 15 Final application

The final step is to create the application.js file, which will call the temperature from the Raspberry Pi using Ajax. Again, download the application.js file into your Gauge folder.

Step 16 Get coding

With these building blocks, you can now start doing more interesting IoT things – controlling the GPIO ports, getting more information, having it connect to other objects to control them as well. Check out the Dizmo website for more details on projects that you can do.