MQTT and ESP-12E

Anyone can give me any suggestion on how to connect the ESP-12E WiFi module with the Arduino Robot and node-red using MQTT? I want to pass the output from the node-red to the ESP-12E and the ESP-12E will receive the output signal and the Arduino Robot will move forward or backward according to the output.
Arduino Robot: https://www.arduino.cc/en/Guide/Robot
ESP-12E: https://www.amazon.com/HiLetgo-Version-NodeMCU-Internet-Development/dp/B010O1G1ES/ref=cm_cr_arp_d_product_top?ie=UTF8

Wile there are probably many folk here using ESP chips, and MQTT, this is really a forum about Node-RED so you may need to be patient or ask around. (I think the basic answer is that esp firmware like ESPeasy or Tasmota are the simplest way to go to get wifi/mqtt/inputs and outputs hooked up.

1 Like

I have several NodeMCU devices around here, all communicating with mqtt. I mostly use Tasmota on my esp devices, but I have a few nodes with custom code and mqtt is handled in the using the pubsub.h library.

The ESP will happily talk to your MQTT broker over wifi. That part is easy and you can use one of the firmwares mentioned or build your own.

To bridge between the ESP and the robot ... if the robot is controlled by an Arduino, then the easy route is to connect the ESP to the Arduino using their serial ports. If the robot is to be controlled directly by the ESP, then you will need to program it the same way as you would an Arduino using the GPIO ports to control the motors - there is a good chance that you would need a relay board of some kind since the ESP itself is unlikely to have the power to control multiple servos directly.

There is a MQTT library called PubSubClient written by @knolleary which with a bit of work might help:

1 Like

To be clear, that is a library for the Arduino IDE. You can use the Arduino IDE to programme ESP8266 devices - there is some initial setup to do though. It is how I - and probably many others here - programme their ESP devices as it is MUCH easier to get started with than the native development tools.

1 Like

Thank you Julian, I should have mentioned that!

Which firmware? You mean the ESPeasy or Tasmota?

The robot is an Arduino Robot which shown below and it has the similar function as Arduino Leonardo so I guess it is controlled by the Arduino?


I plan to connect the RX and TX pins of the ESP with the two digital pins of the robot and control the movement by programming using Arduino Ide? Can this work?

This is a Node-RED forum...

Yes.

Yes.

Thanks for the reply!