Meeo Project : RemoteBlink — Turn on and off an LED remotely with Arduino and Meeo

Blinky or “Blinking LED” is probably the simplest way to get started with Electronics. It’s the “Hello World” of the hardware engineers. Making an LED blink is simple to do; just turn it on and off with on a given interval.

We are already in the era of the Internet of Things. It’s time that we challenge ourselves and make a new “Hello World” for IoT! The RemoteBlink project is the first step in learning IoT!

Prerequisites

First and foremost, you need to know some basics by checking this link out. Make sure that you have a Meeo account. The RemoteBlink will utilize the Toggle Widget. If you are not yet familiar with it, check this link to know the intricacies of the Toggle Widget.

Since we’ll be making the project with Arduino, you need to download the Meeo Arduino Library and make sure that you are using the latest version of the Arduino IDE.

Also, make sure that you have your hardware! For this project, you can either use an ESP8266 board or an Arduino board with an Ethernet Shield. You do not need to connect a separate LED to your board. We’ll use its built-in LED!

Code code code

Instead of making a blinking LED, why not control your LED anywhere in the world? Now that’s an IoT controlled LED! 💡🤘

If you have downloaded the Meeo Arduino Library, navigate the Arduino IDE and open the RemoteBlink example by clicking File->Examples->Meeo->ESP8266->RemoteBlink if you are using an ESP8266 board. If you are using an Arduino board with an Ethernet Shield, then open the RemoteBlink example by clicking File->Examples->Meeo->Ethernet->RemoteBlink.

Now that the RemoteBlink example is open, change the following variables based on your WiFi credentials, Meeo Credentials and the channel name you set for your Toggle Widget:

String nameSpace = "my_namespace";
String accessKey = "my_access_key";
String ssid = "MyWiFi";
String pass = "qwerty123";
String channel = "remote-blink";

If you have set the correct information, you can now upload the code to your board! While waiting for the upload to be finished, we’ll explain what is going on. Every board has a built-in LED. You can control it via this constant: LED_BUILTIN. For ESP8266 boards, the built-in LED is active low. This means that LOW needs to be sent to the LED for it to turn on. For our RemoteBlink project, instead of turning the LED on or off with a given interval, you will be able to control the LED through the Toggle Widget. If the Toggle Widget is on its “on” state, then the built-in LED of your board will turn on!

If you are asking how is that the Toggle Widget able to send data to the board, then you must take a look at the code block below:

void meeoDataHandler(String topic, String payload) {
Serial.print(topic);
Serial.print(": ");
Serial.println(payload);
if (Meeo.isChannelMatched(topic, channel)) {
if (payload.toInt() == 1) {
digitalWrite(LED_PIN, LOW);
} else {
digitalWrite(LED_PIN, HIGH);
}
}
}

The meeoDataHandler function is always invoked every time you change the state of the Toggle Widget. If it’s on state, it sends 1, and if it’s off state it sends 0 (see more details of the Toggle Widget here). In our case, our on-board LED is active low — it means that it lights up when it gets set to LOW. The function checks the topic and the payload. Since you are subscribed to the Toggle Widget channel, you will be able to receive the data every time it changes.

Control your LED anywhere

With your Toggle Widget, you can now control the built-in LED of your board anytime, anywhere! This project unlocks a lot of possibilities. If you take a moment and think about it, instead of using your board’s built-in LED, you can connect a relay to your board and voila! You can now control your appliances! How cool is that? Our simple IoT project is now your stepping stone for your very own Home Automation System! Awesome! 😎🤘

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.