Project Description

Description:

In this tutorial, the Ethernet technology will be used to connect an Arduino board over internet with a PC. The Arduino based IOT device and the PC will be setup to communicate using MQTT protocol  via HiveMQ Broker.

An IOT device based on Arduino will be designed in this project. The Arduino will be interfaced with an Arduino Ethernet Shield to connect with a router via Ethernet cable (Cat 5e). The Ethernet modem has TCP/IP stack in itself and MQTT protocol can be implemented over TCP/IP stack. So, an Ethernet modem is used to connect the device to the Internet. The Arduino board will also be interfaced a DHT-11 temperature and humidity sensor and an LED.

The Arduino device will communicate with a remote PC via MQTT broker. So, both the Arduino based device as well as the PC will act as MQTT Clients. The Arduino sketch will be written to read temperature information from the sensor and send it to the MQTT broker. A remote PC which is configured as another MQTT client will then receive the temperature readings and display them on the browser. It will also control the LED interfaced at the Arduino based IOT device by sending appropriate control commands over MQTT protocol. The PC connects with the broker using a chrome add-on – MQTTLens.

 

Components:

Arduino Uno

Arduino Ethernet Shield W5200

DHT sensor

LED

Resistor 220 ohm

Resistor 10k ohm.

Software Required –

• Arduino IDE
• HiveMQ broker
• MQTTlens (chrome addon)

Block Diagram:

104

Circuit Connection:

There is an Arduino based temperature monitor designed in this project. The IOT device has been designed by interfacing an Ethernet Shield, DHT-11 Temperature and Humidity sensor and an LED with the Arduino UNO.

105

Arduino UNO – Arduino UNO is one of the most popular prototyping boards. It is an Atmega 328 based controller board which has 14 GPIO pins, 6 PWM pins, 6 Analog inputs and on board UART, SPI and TWI interfaces. The board can communicate with the Arduino Ethernet Shield using the SPI interface. The Atmega 328 is the sitting MCU on the Arduino board.

The Arduino can be connected with the Ethernet shield by placing the Ethernet shield on the top of Arduino UNO or by connecting wires (wherever require!). The Ethernet shield is connected to the router (LAN) via Ethernet cable (Cat 5e). The Arduino is connected to the Ethernet shield as shown in the image below:

106

https://www.engineersgarage.com/Contributions/IoT-Communication-MQTT-Clients-HiveMQ-Broker

The DHT 11 Sensor sends data in the digital form to the Arduino board on one-wire protocol which must be implemented on firmware side. First the data pin is configured to input and a start signal is sent to it. The start signal comprises of a LOW for 18 milliseconds followed by a HIGH for 20 to 40 microseconds followed by a LOW again for 80 microseconds and a HIGH for 80 microseconds. After sending the start signal, the pin is configured to digital output and 40-bit data comprising of the temperature and humidity reading is latched out. Of the 5-byte data, the first two bytes are integer and decimal part of reading for relative humidity respectively, third and fourth bytes are integer and decimal part of reading for temperature and last one is checksum byte. The one-wire protocol is implemented on the firmware using an open-source library available for Arduino. The Arduino also connects with the Ethernet using an open-source library.
The read temperature and humidity values are sent as messages to the “current_temeprature” topic. The PC client receives messages on the topic and display the reading as message received.
The PC Client after connecting to the internet can publish messages on “Ethernet/LED_status” topic. The PC Client must be operated by a human. On the “Ethernet/LED_status” topic, either ‘on’ or ‘off’ message can be sent. If the message ON is published by the PC client, it will be received by the Arduino client and its firmware code interprets the message to switch on the LED light. If the message OFF is published by the PC client, it will be received by the Arduino client and its firmware code interprets the message to switch off the LED light.

 

Demo: