Smart home series – Part 3 – Getting some momentum

Posted by Gjermund Bjaanes on January 10, 2016

It’s been a little while since I had any update for my Smart home series.

The last time I thought I had failed miserably at soldering, but after a brand new component gave the same errors, I finally sought some help.

Turns out I the problem was with my Arduino setup. According to the help I got, the problem was:

“When you program the UNO using USB it communicates with the ‘328 via pins D0 & D1. The ESP8266 is interfering with this process.”

The thread I started to get help: https://forum.arduino.cc/index.php?topic=369554.0

So the solution to my problem was to have the following code in my sketch:

#include <SoftwareSerial.h>
SoftwareSerial MySerial(8, 9);

I was then finally able to upload and test the shield, which worked like a charm! I managed to connect to my WiFi network and ping a server. Yes!

 

MQTT

Finally, with some momentum, I wanted to set up an MQTT broker and get the basic setup up and running.

I explained the basic principles with MQTT in one of my previous posts: Smart home series – Part 1 – Learning MQTT and buying stuff

I have a first generation Raspberry Pi, which I am going to use as my MQTT broker.

I installed a Debian variant called Raspbian Jessie Lite and the MQTT broker software Mosquitto.

The images can be found here: https://www.raspberrypi.org/downloads/raspbian/

I installed Mosquitto using the following commands:

curl -O http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
rm mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo curl -O http://repo.mosquitto.org/debian/mosquitto-jessie.list
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients

 

To test the setup I installed a basic MQTT client on my normal computer, and connected to the raspberry.

In order to see the incoming messages, I used the following command on the Raspberry server:

mosquitto_sub -d -t hello/world

 

I then published a message on hello/world.

On my raspberry, I could see the following message:

Client mosqsub/7714-raspberryp received PUBLISH (d0, q0, r0, m0, 'hello/world', ... (0 bytes))

 

Success! The broker is up and running!

 

Next steps

Now that I finally have some momentum I hope to get something useful created pretty soon.

The big next step is obviously to get my Arduino to somehow send MQTT messages based on information from one of my sensors.

After that it’s all programming, testing and tweaking. Look out for more updates!


Follow me on Twitter: @gjermundbjaanes