MQTT on Windows

I needed to use my Windows 10 Virtual Machine to attend a workshop where labs could only be accessed from Windows operating systems (buh-uh-uh!).

So since I’m back to Windows again, let’s see if If how I can use MQTT on it.

There are two builds of mosquitto tools for Windows: one that it’s based on cygwin and another ‘native’ built with Microsoft Visual Studio

I started with the second: mosquitto-1.4.15a-install-win32.exe

Please note that I’m using a Windows 10 (x64) virtual machine, not quite full updated and it’s July 2018… things might/will change a bit after a while.

So this is x86 (win32) build but it works on x64. It just needs 3 aditional libraries (dll’s) to work:

  • libeay32
  • ssleay32
  • pthreadVC2

The install wizard says that the first and second library can be extracted from the light install of OpenSSL for Windows. But recent versions of OpenSSL no longer use this libraries so I had to download an older one: version 1.0.2o

So I installed this build with the option to include the libraries in the local bin folder where I went to copy “libeay32.dll” and “ssleay32.dll”. Both libraries properties had “file version 1.0.2.15, product version 1.0.2o”.

I copied these 2 files to a new folder “C:\mqtt”

Then I went to POSIC Threads for WIndows project and downloaded the 2.9.1 release and extracted “Pre-built.2\dll\x86\pthreadVC2.dll” also to “C:\mqtt”. File properties had “file version 2.9.0.0, product version 2.9.0.0”.

Then I installed mosquitto 1.4.15a on the same “C:\mqtt” folder, extracting files and configuring the service. This created a Windows Service named “Mosquitto Broker” with a “MQTT v3.1 broker” description, configured as “Automatic” but not started.

From command line, changing to “C:\mqtt” and executing “mosquitto_pub.exe” gives an error stating that another library is missing (MSVCR100.dll). This is from “Microsoft Visual C++ 2010 Redistributable Package” so I installed the x86 version.

Now the same command worked and I could also start the service (“Mosquitto Broker”).

The command line argument are the same as for Linux so

mosquitto_pub.exe -h localhost -m "0" -t sfx -r

works and if I open a second command line window I can see this message arriving:

mosquitto_sub.exe -h localhost -t sfx

Nice. Now I can use LEGO MINDSTORMS, Linux, Raspberry Pi, Android, Arduino and Windows systems on my IoT projects. If someone offers me an Apple OSX device, I’ll be a true polyglIoT ! 😀

Rock Concert IoT

Este artigo é a parte 5 de 5 da série  LEGO Rock Concert

So last days I’ve been assembling the stage surroundings, a truss-based structure to support the left and right video walls and also the self-powered speakers:

LEGO Rock Concert: good progress with the stage and electronics

I gave up hiding the speakers under/inside the stage. I know, speakers aren’t LEGO but I think they look good enough this way.

Also I have been testing the Raspberry Pi Zero W with the PiTFT and a local USB webcam. I use ‘VLC’ to stream the webcam video to the wireless network and can show a stream on the PiTFT with ‘mplayer’. And since mosquitto-clients package is also available for Raspbian I got a way to control everything with just a bash script with MQTT.

So this is the IoT setup now:

LEGO Rock Concert: The IoT

From any mosquitto publisher I can select which stream to show on each video wall and also start a bash script on the EV3 with the sound card and the LEGO Power Function lights so a music plays while the lights blink.

Only problems till now:

  • ‘mplayer’ takes 5 seconds to start playing the stream, doesn’t seem to be a problem with the raspberry nor with the stream, just some kind of warm-up from mplayer, if I can’t fix it will have to find another video player that works with the PiTFT (it’s framebuffer, not X-based)
  • a small USB endoscope camera I was considering using has some problems to show up on first boot of the Rasberry Pi so I will probably use another webcam, bigger but more reliable

While testing the IoT I used my Ubuntu laptop (‘mosquitto-pub’ and ‘mosquitto-sub’) but found a MQTT Dashboard App that works fine both on my Android 5.0 Phone and my Android 4.0 tablet. But I also wanted to use an EV3 as a controller so I tested a few bash scripts with the local keys but found it too limited… so decided to make a better control panel:

LEGO IoT Control Panel

The four medium motors are used as selectors,  I divided a whole rotation in 8 intervals (45º each) to have 8 options on each motor. So it works like this:

– one selector for Video Wall #1

– one selector for Video Wall #2

– one selector for Sound and Lights

– one selector for Special Effects

I can choose what stream I want to show on each video wall and start playing a music. Later I will add more options (photo presentation, youtube video…) and use the 4 EV3 touch sensors to adjust parameters for each option (like the brightness, the frequency or the effect of the lights, the volume of the sound, forward/backward while showing some presentation…).

A video explaining this:

I speak in english but my voice is weak and I had an allergic caugh in the middle so I added sub-titles (also in english).