How To: Smart Home setup to track indoor temperatures and humidity with sensors, Raspberry Pi, MQTT, Node.js, Vue.js and Chart.js

comments 5
English / Tutorials
TLDR; This three-part tutorial explains how to setup a basic smart home web app tracking sensor data for temperature and humidity with a Raspberry Pi and web technologies like Mosquitto, Node.js, Express.js, Vue.js, Quasar and Chart.js.

Tiny Smart Home

So I went on maternity this January and came up with an idea about a nice little project to do in my free time that went a little further from my usual Javascript front- und backend projects I usually do at work. I have a Raspberry Pi 3 at home I bought over a year ago and never did something useful with so I decided I wanted to track temperatures and humidity in our child’s room and bedroom to a have an idea about a good indoor climate. In the end I wanted to finalize a cloud-based dashboard web app which provides the incoming sensor data in real time and available everywhere and everytime.

I wrote this three-part tutorial to track my experiences, tech choices and suggestions for you to follow and came up with a solution that comes with an easy hardware setup and some popular (and worth to learn if you are not already familiar with) web development technologies, including Node.js, Mosquitto and Vue.js.

The basic three parts will allow you to run a web application on your local machine. Nevertheless I added some more features including persistent database storing and the deployment in the cloud with Heroku. You will find these tutorials at the end of this page.

The code base is stored on Github!

1 . Choose and install hardware (sensors, receiver, Raspberry Pi) for a basic tracking tool on temperature and humidity

I did some research on how to build basic weather stations and home automation systems with a Raspberry Pi but they were mostly no wireless solutions or they came up with too much IoT hacking/soldering and especially required a lot of electrical knowledge I do not have. The core problem I figured out was that many tutorials wanted me to build a remote sensor gagdet with radio functionality and sleep mode (e.g. with an Arduino) all on my own. So the question was: Is there a better and easier alternative to such an all self made solution and what about the receiving hardware on the Raspberry Pi?

Fortunately, there exists an easier alternative I will show you in this part of the tutorial which deals with slightly more expensive IoT gagdets but which enabled me to set up my smart home hardware in a smooth but nonetheless instructive way.

2. Get and process your smart home sensor data with MQTT Broker Mosquitto and a Node.js backend

The main problem in this part was how to set up a stable and endlessly running task on my Raspberry Pi to continuously receive the (correct!) sensor data. Secondly I wanted it to somehow process and transfer it to a backend/microservice/middleware, which then would provide an upcoming frontend with JSON data to display. MQTT is the IoT protocol to go with but how to set it up? How can a MQTT broker like Mosquitto work with a Node.js backend properly?

3. Display smart home data in a Quasar, Vue.js and Chart.js powered web application

This was somehow the easiest part, because I mainly work as a frontend engineer and know how to implement dashboard-like web app solutions in combination with backend REST API services and the like. I challenged myself with an insight into Vue.js, since I mainly used React as a SPA framework before. In search of a nice UI library I discovered Quasar, which provides a very useful CLI and UI components so that there was no need to come up with an own CSS by myself.


 Add more features?

I wrote some more or less standalone tutorials, which will help you to improve your existent application with some more capacities.

  1. Deploy your smart home application up to the cloud on Heroku (coming soon)
  2. Build a simple session-based authentication with Node.js and Vue.js (coming soon)
  3. Get a CSV download out of PostgreSQL or lowdb database on Node.js

5 Comments

  1. First off I would like to say fantastic blog! I had a quick question that I’d like to ask if you do not mind. I was interested to know how you center yourself and clear your mind prior to writing. I’ve had a difficult time clearing my mind in getting my thoughts out there. I truly do take pleasure in writing but it just seems like the first 10 to 15 minutes are generally wasted simply just trying to figure out how to begin. Any suggestions or tips? Kudos!|

  2. Hey there! I’ve been reading your web site for some time now and finally got the bravery to go ahead and give you a shout out from Lubbock Texas! Just wanted to tell you keep up the great job!

  3. I think this is one of the most vital info for me. And i’m glad reading your article. But should remark on some general things, The web site style is wonderful, the articles is really excellent : D. Good job, cheers|

Leave a Reply

Your email address will not be published. Required fields are marked *