Blynk BRIDGE – Another way to Communicate between two ESP8266 modules

A new excellent method to communicate between Internet of Things modules, regardless the network or position on globe, is available now with the Blynk BRIDGE Technology provided by the IoT Blynk platform. You can now interconnect all your IoT projects using the Cloud Blynk Server as a live central transaction manager and the best part is that this feature is free. Also a big advantage is the simplicity and speed of development process thanks to the Blynk library which does all the hard work.

ESP8266 to ESP8266 Communication with Blynk Bridge

I know we already covered much of this topic in the esp talk each other article, but I just bumped into this awesome Blynk platform and I am going to get the most of it just because is mostly free and seems reliable. If you are new and want to get started with Blynk app you should read this article first:

Project Goal and expectations

The two ESP8266-01 modules used in this project should be able to communicate each other even they both connect to the internet using different networks. One module will be connected using the home WiFi router and the other one will connect using my 4G Vodafone mobile connection via Hot-spot.

The first ESP-01 module will measure temperature and humidity using a DHT22 Temperature and humidity sensor. The measurements will be periodically pushed to the Blynk app dashboard and displayed via Blynk Gauge Widget. We will set a temperature alarm point at 28 Celsius degrees. When this alarm threshold is fired, the first ESP will open a 220V Relay attached to the second ESP-01, and also update a virtual LED on the second ESP Blynk dashboard.

Hardware parts and wiring diagram

Yes, ordinary simple! For the sake of demonstrating the working principle, we need to keep it simple and easy to make it. Therefore in this project the following parts were used:

The working principle – how it works?

Because we have two Internet of Things modules, we also need to create two Blynk projects in the Blynk App. Every IoT module, in our case the ESP-01, will be associated with a unique Blynk Authorization Token. We will use this unique tokens in order to gain access to other Internet of Things modules connected.

If you already read our first Blynk turorial, you should know how a simple Blynk project works. The Blynk Server opens a bidirectional communication channel with the IoT module isolating it with the unique Authorization Token, allowing transactions from both sides. With Blynk Bridge, we can now ask the Blynk server to give us access to other communication channels in exchange of proper tokens.

Once we’ve gained access to the second IoT module, we can now command its GPIOs as simple as we do it for the current one. Blynk Bridge library provides easy methods which are similar with Arduino organic code.

Code for the second ESP module. The one which will be controlled by the temperature alarms

As you can see, this code has nothing special, is almost as simple as the standalone default sketch. The only differences are in the BLYNK_WRITE function call which we use to forward the updates for the VIRTUAL Ports. Other than that, this “slave” module won’t know what hit him :). It will receive commands from both the first ESP or directly trough the Blynk App in a totally transparent way.

Code for the first ESP module. The one which will control the second ESP according to the temperature alarms

This sketch code is just a little bit more complex, but no nothing to worry. Some pieces of code were added over the standalone Blynk sketch in order to gain control over the second esp. Beside the Blynk related code, we also need to add DHT22 Arduino library and the specific code to initialize and make the readings. If you haven’t had the chance to play with DHT temperature and humidity sensors you can find everything you need to know in this arduino temperature example.

In the code piece below you can see how the Blynk Bridge functionality is integrated in the sketch. The BLYNK_CONNECTED function contains the Authorization Token for the second ESP to be controlled. Above this function we declare the bridge1, a variable to hold the BRIDGE associated with Virtual 1 Port (V1). We can actually open as many bridges as virtual ports are available in order to control multiple devices.

WidgetBridge bridge1(V1);
BLYNK_CONNECTED() {
// Place the AuthToken of the second hardware here
bridge1.setAuthToken("***********************");
}

Once we defined the Bridge remote authentication token, we now can command both physical or virtual GPIOs on the second ESP via the bridge1 instance created in the above steps. Code below demonstrates how easy we can do that:

In this example you can see how the first ESP sends integer value 1000 to both digital and virtual ports on the second ESP, if the temperature gets over 28 Celsius degrees. On the ELSE road it also resets with value 0 when drops under 28C. I used value 1000 because ESP8266 has PWM on almost all GPIOs and sending 1 or 0 as ON/OFF doesn’t always work.

Starting from this example you can easily build more complex Internet of Things projects and set your devices free. You can find the original Blynk Bridge INO sketch on the Blynk github widgets branch. Also you can study the blynk bridge documentation on the official blynk website.

Conclusion

If you ask me, this Blynk platform is probably the most valuable resource available for Internet of Things projects. Considering the benefits it provides it really I wouldn’t mind to pay for it. It can really help you in making advanced projects with a high availability and extremely powerful live reports and dashboards. I confess that I spent weeks working to solve issues which Blynk features fixed in minutes, and for that I really recommend you to give it a try if you didn’t already.

If you want to see more methods of how to make esp8266 module talk each other you definitely need to checkout this great ESP8266 topology created by a geek farmer from Europe.

Hoping that this article inspired you, i kindly invite you sharethis article, subscribe my YouTube channel and join the communities on social networks. Please feel free to comment or send suggestions / remarks so i can improve the content quality

One Reply to “Blynk BRIDGE – Another way to Communicate between two ESP8266 modules”

I see you don’t monetize your website, don’t waste your traffic, you can earn additional cash every
month because you’ve got hi quality content. If you want to
know how to make extra $$$, search for: best adsense alternative Wrastain’s tools