TheRelentlessDev

All things tech with a sprinkle of make

NAVIGATION - SEARCH

Using an ESP8266 as a WiFi-serial bridge to an Arduino Uno

Introduction

I have in the past on several occasions used the JY-MCU (linvor) and HC-06 Bluetooth modules to connect to everything from Arduino to my quad-copters flight controllers. It offers a nice simple way to get a serial monitor up onto devices that are difficult to reach. Also in the case of quad-copters having a wire dangling from a flying vehicle provides for a bad time. Many flight controllers provide an interface to update variables on the fly (pun intended). So, being able to do this remotely is a very nice capability. In most cases Bluetooth is sufficient.

The only issue with Bluetooth is the range. It works well for short distances. Wifi, on the other hand, using a decent antenna can provide a much larger range than is achievable using Bluetooth. This extra range is great if you need to update variables or read telemetry data from a quadcopter or a microcontroller that is in a hard to reach location.

Requirements

1 x ESP8266 ESP-07

1 X 3.3V 5V TTL Bi-directional Logic Level Converter

1 X Mini Solderless Prototype Breadboard

1 X Arduino Uno (or compatible)

Various Jumper Cables

Depending on your variation on the ESP8266 you are using you might need an ISP. I use the AT AVRISP AVR ISP mkII. A simple USB to serial converter will probably be adequate.

Getting things ready

Before we can start connecting everything you will need to flash jeelabs' esp-link to your ESP8266. There are numerous instructions on how to do this and depending on the ESP8266 chip you are using this may or may not be easy. 

My Arduino currently has a version of GRBL running on it as it came from an old CNC machine of mine. This will be used to test the comms via the serial bridge. You could of course just flash the Arduino with something more simple like an echo program that just repeats everything that is sent to it over the serial link. But whatever suites you.

Once you have the firmware installed we can now start wiring up all the components.

Wiring it all up

 

     

As is perfectly clear on the above images, one can plainly see how to wire it all up (just joking). It might be a bit more clear in the image below:

Some things to note:

  • The Arduino is being used to power the ESP8266 chip using the 3V output.
  • The devices are sharing a common ground.
  • From the level shift converter, the TX is connected to the RX and the RX is connected to the Tx.

If it's not obvious why a level shift converter is required, then let me expound: The reason is the Arduino operates at 5v and the ESP8266 operates at 3V. I didn't feel like letting the magic smoke go out of my ESP8266 just yet so haven't tested if it will work. Maybe if someone else knows whether it is possible to use something like a resistor from the Arduino TX (out 5V) to the ESP8266 RX side (in 3V), please leave a comment. The RX on the Arduino should read anything above 3V as a high, so it may work.

Powering it all up

Okay, so all the devices are flashed with their respective firmware, and the devices have been powered up. After a few seconds, you should see a new wifi hotspot pop up from the ESP8266. Connect to the hotspot. There should be no password required.

If all went well you can navigate to the address: http://192.168.4.1

You should see a page like below:

There are options to connect the ESP8266 to your Wifi and access it like that. For my purposes a direct Wifi link is adequate. Change the pin assignment to reflect the following configuration and click the change button:

The above setting should now be in effect. Open a telnet client, I use the built-in Windows one. If you don't see it, you will have to add it via the windows optional features dialogue. It generally is not installed by default. An alternative option is the putty client. 

Open the serial connection to IP 192.168.4.1 on port 23.

Executing the $$ command on GRBL returns the current configuration.

As you can see from above all is working and we have just successfully connected our wifi-serial bridge and managed to send and receive data.

WINING SPINNING :)

The next step would be to update firmware OTA. If anyone is interested maybe I will do this as a later article. I would think that the reset line is important so that it can trigger the micro to go into programming mode.

Disclaimer: I am not an electronics engineer. Everything I do regarding electronics is self-taught either through reading or just burning out things.

Resources:

  1. GitHub. 2019. jeelabs/esp-link [ONLINE] Available at https://github.com/jeelabs/esp-link. [Accessed 18 June 2019].

Add comment