Using an FTDI to program an ESP8266-01

ESP8266-01 Pin Labels
It took me days to figure out how to program an ESP8266 with an FTDI connector. I finally got it figured out last night. I remember using an Arduino Uno to program them a little over a year ago. I’ll have to try that again sometime soon.
The two FTDI boards(? cards? devices?) that I have look different but, essentially, are the same. I have one 3.3v from Sparkfun.
Sparkfun FTDI FrontSparkfun FTDI Back

On the back side it looks like you’d be able to solder a jumper wire across the little pads to make it either 3.3v or 5v. I am not sure and don’t feel like burning it up just to see.

The second one is from Virtuabotix. It has a switch on the back side so you can choose either 3.3v or 5v. There are also two connectors that you can use, four pins or six pins.
Virtuabotix FTDI FrontVirtuabotix FTDI Back

You actually only have to use four of the pins on the FTDI to program the ESP8266-01, voltage out (VDD or 3.3v), GND, RX, and TX.

I found it much easier to use a little homemade breadboard header while programming or just messing around with the ESP8266-01. The
ESP8266-01 by itself is not breadboard friendly. I ended up taking a row of header pins and cut them into 4 pin lengths. I then glued them together to make a 2×4 header row that I could plug the ESP8266-01 into. I bent the rows of the pins outward, away from the opposite side, and then back vertical so they would fit into a breadboard across that little trough that separates the two sides of the breadboard. You have to keep messing with the angles of the wires to get the pins into the correct position. It doesn’t take too awful much time to get it correct.

There are eight pins on the ESP8266-01. You only need to hook up six of the pins on the ESP8266-01 to four of the FTDI pins.

If you look closely you will notice on the Sparkfun FTDI the six pins are labeled GND, CTS, 3v3, TX0, RX1, and DTR. On the Virtuabotix FTDI the six pins are labeled G, D1, Vdd, Rx, Tx, and Rst. The second set of four pins on the Virtuabotix are labeled Vdd, Gnd, Rx, and Tx. We are going to use only four of the pins on the FTDI. The four pin connection on the Virtuabotix FTDI already has the only ones we need. The ones on the six pin connectors that we will use are ground (G or GND), voltage (3v3, or Vdd), receive (Rx or RX1) and transmit (Tx or TX0). You may have a board that has different pin labeling, but they should be the same and in the same order. That is, if the company followed the same building convention as these two companies.

Since you will need to use six of the pins on the ESP8266-01 and only four of the FTDI pins it is easier to use a breadboard. The pin wiring will be:
FTDI -> ESP8266-01
GND -> GND and GPIO0 (this is ground)
3v3 -> VCC and CH_PD (this is voltage)
RX -> RX
TX -> TX

Both the ground and voltage pins of the FTDI go to two pins on the ESP8266-01.

Once you have the two devices hooked together you can plug in the FTDI to your computer and upload a program to the ESP8266-01.

I used the Arduino IDE to program the ESP8266-01. I am familiar with the Arduino IDE so I use it.

Once you have the USB cable hooked up to your computer, in the Arduino IDE select Tools from the top menu. Select “Generic ESP8266 Module” for the Board. On version 1.6.5 of the Arduino IDE more options will show up under Tools. I have them set as the following:
Flash Mode: “DIO”
Flash Frequency: “40MHz”
Upload Using: “Serial”
CPU Frequency: “80MHz”
Flash Size: “512K (64K SPIFFS)”
Upload Speed; “115200”

For the Port you will need to select the port that your FTDI is using.

I modified the basic BLINK sketch to blink an LED for 1/10 of a second twice and half a second repeatedly. After you have the ESP8266-01 programmed you will need to disconnect the wiring for the FTDI. Then you will need to wire up the ESP8266-01 with battery + to VCC, and battery – to ground. I used two AA batteries for power. Also put a resistor from GPIO2 to an LED and the other leg of the LED to ground. There should also be a jumper between CH_PD and VCC so they both get power from the battery.

Here is a copy of the sketch that I modified slightly (you may use it and modify it):

Turns on an LED on for one tenth of a second
then off for one tenth of a second
then on for one tenth of a second
then off for one tenth of a second
then on for half a second
then off for half of a second

This example code is in the public domain.

// Pin 13 has an LED connected on most Arduino boards.
// Pin 11 has the LED on Teensy 2.0
// Pin 6 has the LED on Teensy++ 2.0
// Pin 13 has the LED on Teensy 3.0
// Pin 2 for the ESP8266-01 and I put the LED on the breadboard
// for this device with a resistor to not burn out the LED.
// give it a name:
int led = 2;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a 1/4 second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(300); // wait for a 1/4 second
digitalWrite(led, HIGH);
digitalWrite(led, LOW);
digitalWrite(led, HIGH);
digitalWrite(led, LOW);

That’s about it for using an FTDI to program an ESP8266-01 using the Arduino software.

Re-learning, since I didn’t document.

I messed with ESP8266 devices a lot just over a year ago. Man, did I have fun. I got to where I could get one to log into my local network (LAN), or log in and get out on the internet. I set one up and logged onto it with my laptop, or my iPhone, to access the HTML page. I set two others up to create their own LAN. One broadcast an SSID and waited to display a web page. The other connected to the LAN, accessed the web page and turned on, or off, an LED. I really understood these little devices.

I recently opened up a little box and found the devices inside. I thought I should revisit them. Uh, I had programmed them with the FTDI device with one of my Raspberry Pis. I had updated the Raspbian and didn’t save the old personal files. Bonkers!

I am going to have to learn all over again. I don’t know of a way to use the Arduino IDE to pull the program back out of a chip into a sketch. (It might be possible, I haven’t checked.)

I got out the Sparkfun Thing and the Adafruit Huzzah that used to talk between each other and found the Sketches I had written. Some of the wires were missing so I had to rebuild. The Huzzah is put onto a mini breadboard and has an on/off button and a tactile switch. The Thing has an LED and a resistor. When you turn on the Thing and then the Huzzah, the Huzzah connects to the Thing. You can tell by looking at the Serial window on the Arduino IDE, or by looking at the little blue LED. The little blue LED will flash after the first initialization flash. When you press the button on the Huzzah, the LED on the Thing will light up. Press the Huzzah’s button and the Things’ LED will will go out. I know it is not much, but it was a learning experience for me.

While I was cleaning up things last year I put these things into a box. Uh Oh! They got forgotten. Luckily I was able to find the old Sketches to prick my memory. They are working fine for now.

Where was the documentation? I had written something about them on one of these pages. I didn’t cover much about them. That was my fault. Had I documented them and saved the sketches online I could have helped others learn and helped me from forgetting what I did at the time.

Super Awesome Sylvia reminded me the other day that you should document for sharing and teaching. Now, while it is still fresh in my mind, I have to document and post the code (sketch), what it means, and pictures of the devices and perhaps a schematic.

That is for tomorrow. I still have cleaning up to do. Liverpool FC is playing tonight at 10pm Pacific Coast time. That’s in an hour.


Making More Things

I have many electronic projects in the works and desires right at the moment. I want to CharliePlex, or MultiPlex a Christmas tree with LEDs. That is the main project in my head at this time.
< < -XX-XX-XX- > >
LED Tree
On Orthodox Christmas night I finished the MultiPlex Christmas Tree. It works great. Over the next couple of days I changed the Arduino to a Pro Mini and put it into a tiny round cheese box. I put Christmas Wrap around it and cotton balls for snow.

The programming has six or so different patterns that the LEDs use. I cut a USB cable so I could use the type-A end for power and soldered the cut end onto the Pro Mini. I just might make some more to sell next Fall for Christmas. I still have to come up with a price. Parts are about $10. There is a lot of time put into it. The programming is all done, so I only have to copy it onto the Arduino.

The video I took of the LED patterns is over 100MB. I have to change the movie to about 64MB to use on this site. I cut a bit of frames out and got it to about 47 megs.

I have also been playing with a 3x3x3 cube and a cheap TFT Touch screen. It has been too much fun.

:-/ For some silly reason I cannot upload an .m4v file. GoDaddy has is forbidden and I haven’t figured out the fix, yet. I’ll post this and get back to it later.
I was able to SFTP the .m4v into the media directory. It should not be this difficult.
Here is a little video of a test sketch on a cheap TFT TouchScreen for Arduino.
TFT TouchScreen

More than fun with ESP8266 modules

Getting a gift of ESP8266 modules is more fun than frustrating.  A few days ago my wife gave me a red box with three ESP8266 modules inside.  These ones came are SparkFun ESP8266 modules .   They are so tiny and only have 8 pins.

First things first

I had to learn how to program them before I could monkey with them.  Connecting an FTDI module to the ESP8266 was pretty easy, but I needed to use a little breadboard to help me along the way.

< < -XX--XX--XX- > >

Well, I started this post quite a while back. I don’t even remember all of what I did at the time. I found those little ESP8266 devices in a box while I was cleaning stuff up, or straightening up my maker area. They are still put together and have batteries taped to them, but not hooked up. I think they have lost their programming because when I hook up the batteries the devices don’t talk with each other. Now I have to learn the programming all over again.

Speaking of learning to program, I have been messing around with some cheap Chinese Arduino UNO boards. My Mac will not recognize them without setting the Mac to not check the driver as legitimate. I don’t want to monkey with the OS that much. The cheap Arduinos do not use FTDI for programming. They use a CH340G or a CH341G chip. I can download the driver and ask my Mac to not check the driver signing. But that sets it up as don’t check any driver signing. I don’t thing I want to have it not check even legitimate drivers. So, I am going to use a Windows laptop, or a Raspberry Pi to program those cheap Arduinos.

Hmmm, I am reading that Adrian Mihalko has patched the driver for Sierra and that it is signed. I will try it out. Well, The read-me says that If-and-only-if the device is still not recognized to disable the System Integrity Protection. Oh, Yeah, just what I don’t want to do.
I installed the drivers and rebooted. They work very well. Now I don’t have to use the Italian made Uno that I bought first, from RadioShack. It was about $35, but I thought I would like to try it. Tried it. Got addicted. Never looked back.

Now I am going to have to get back to the ESP8266 modules and learn to program them again.


Oh, on my work phone I changed the “signature” for when sending an email. It is a iPhone 4s. I know. They don’t have the money to replace it. The previous one started having battery issues. Everyone else is getting an iPhone 6s+ or so. They replaced the 4s with a used 4s that someone else had given up. Hey, the battery lasts longer and it has a OtterBox case. It is tough being the redheaded step-child.
I had offered to purchase a battery and install it, if they would reimburse me the cost of the battery. They didn’t like that idea. Six months later they found another 4s. It lasts almost all day. I can easily deal with that.
Oh Yeah! I kept reading other people’s email signatures and theirs would say, “Sent from my iPhone 6s+”, or “Sent from my iPhone 7”, or “Sent from my Samsung Galaxy 7”. So, now my iPhone 4s signature says, “Sent via ESP8266 Borg Cube”. What else is there? Tetrahedron?