Online control of LED with MQTT protocol

Tell us the story of your project: 

MQTT is an easy to use protocol that enables IoT devices to pass messages. In this project, I used the integrated WiFi capability of the RTL8195 Ameba-1 development board to send and receive MQTT messages and control a LED over the internet.

How-to: 

In this project I am using the Ameba-1 development board from Realtek, based on the RTL8195/RTL8710 soc, part of its AmebaIoT ecosystem. This board can be programmed using the Arduino IDE and is pin compatible with many sensors and expansion boards. It also has WiFi, NFC, and USB Host functionality as well, making it suitable for many IoT applications. Any other development boards capable of a WiFi connection can also be used, but the code will need to be changed.

 

To begin with, ensure that you have the Arduino IDE installed and configured for programming the Ameba-1 board. Instructions to do this can be found at https://www.amebaiot.com/en/ameba-arduino-getting-started/

 

Next, connect the LED and push button to the board by following the wiring diagram in the youtube video here. The wiring for this project is rather straightforward, but make sure that you connect a resistor of at least 220 ohm between the LED and the board. This resistor is vital to protecting the LED from too much current, without it, the LED could burn out and fail.

 

Once the wiring is done, connect the board to the computer. Download the code provided at the GitHub link and open it in the Arduino IDE. Before you upload the code to the board, there are a few changes that need to be made to the code. Please make the following changes:

  1. Line 31 - enter the name of the WiFi network the board will connect to
  2. Line 32 - enter the corresponding password of the WiFi network
  3. Line 35 - enter the URL or IP address of the MQTT server to use. If you do not have your own server to use, you can choose to use the free server at test.mosquitto.org

Upload the code to the board once these changes are made.

 

On your Android/iOS mobile device, download and install a MQTT client from the app store if you do not have one already. Configure the app to use the same MQTT server, and subscribe to the outTopic. Push the push button and the Ameba-1 board will send a MQTT message with the current state of the LED. Publish either a '1' or '0' to the topic "inTopic", and the LED will turn on or off respectively once the message is received by the board.

 

MQTT provides a powerful and simple method to control and interact with IoT devices over the internet. This project can be used as a base for complicated systems, such as getting the temperature and humidity from a sensor, or controlling motors to move something.

Difficulty: 
Duration: 
Share a "Show & Tell" video.: 
https://www.youtube.com/watch?v=9qTNshMkaKE
Collaborators: 
wyy170592
Number of Forks: 
0
Tools: 
Name: 
Arduino IDE
Quantity: 
1
Materials: 
Name: 
LED
Quantity or amount: 
1
Name: 
Push Button
Quantity or amount: 
1
Name: 
Connecting wires
Quantity or amount: 
1
Name: 
220 ohm resistor for LED
Quantity or amount: 
1
Name: 
Mini Breadboard
Quantity or amount: 
1
Name: 
Android / iOS device
Quantity or amount: 
1
Boards & Kits: 
Name: 
Realtek RTL8195
Quantity: 
1
Team Members: 
Team member name: 
wyy170592
What role did this person play on the project?: 
Project Lead
Public
Sort Order: 
0
Teaser: 
Make use of the integrated WiFi capability of the RTL8195 board to switch a LED over the internet.
Show & Tell video as default: 
Creation Date: 
Thursday, March 19, 2020 - 14:22