IoT — temperature and humidity sensor example using MXDevKit and Custom MQTT Broker

Michael Linder
3 min readDec 27, 2017

In the previous article, I described how to configure a custom MQTT broker on AWS EC2 instance and test out the different types of communication. This post will provide a Step-By-Step guide to create an IoT example using a custom MQTT broker, a microcontroller and an Android phone.

1 Before you start

You need to have following parts to start:

  1. MXChip IoT DevKit AZ3166 (http://mxchip.com/az3166)
  2. MQTT Broker (e.g. iot.eclipse.org or DIY one)
  3. Android Smartphone with installed MQTT Dash app

2 Configuration and Preperation

In order to prepare the development environment, use the instructions https://microsoft.github.io/azure-iot-developer-kit/docs/get-started/ to (1) configure your MXDevKit and (2) install the development tools on your machine.

3 Scenario

In this scenario we are using a MQTT communication to get temperature and humidity from the MXDevKit everytime we publishing a new message to the topic “mxtest” using the MQTT Dash app on the Android device.

Scenario

4 Microcontroller program

For this scenario the Microsoft MQTT example Sketch was used as base and adapted according to the above defined scenario. You can find this sketch here.

5 Installation on MXDevKit

  1. If you have an AntiVirus Software like McAffee, you have to deactivate it before.
  2. Download the sketch
  3. Open VS Code with Administrative Privileges
  4. Open the sketch
  5. Connect the MXDevKit
  6. Configure mqttServer variable in MQTTClient.ino
VS Code — configuration MQTT Server

7. Upload the sketch to the MXDevKit

(1)Use CTRL+P and then (2) enter task device-upload

Sketch upload to MXDevKit

--

--

Michael Linder

#Passionate and #creative #teamplayer, working on adoption of new technologies within enterprises. More information: http://linkedin.com/in/michael-lin…