ESP8266

Do we need to program the ESP8266 module to use it with Arduino Uno or it comes with the basic setup which makes it ready to use,that is like plug and play type device.

(deleted)

You'll need a USB-to-Serial converter to program it.

You can either use the preinstalled firmware to control it using AT-commands, like a modem (this is really primitive, not recommended), or you could use firmware that supports running Lua scripts or Micropython scripts. There's also an sdk to write your own firmware.

But I think that the easiest way is using Ivan Grokhotkov's plugin for the Arduino IDE. This allows you to program it like an Arduino, and it has a lot of great libraries for HTTP servers, WiFi connections, UDP, mDNS, a file system etc...

The ESP8266 doesn't use a bootloader the way an Arduino does: the ESP's bootloader is on the chip, not in the external flash memory, and it is enabled when GPIO0 is low while resetting. When it is activated like this, it will accept new firmware over the serial port, and write it to the flash memory. When GPIO0 is high on reset, it will simply run whatever you have at flash address 0x00.

This means you don't have to use some kind of external programmer to burn a new bootloader for a different platform, you can just upload the firmware.

What do you mean program it like an Arduino? Using Arduino IDE's C++ language, include libraries, etc? Are the Lua and Micropython languages drastically different?

I'm still unclear on hardware hookup when programming- is hooking it up to an Uno's Tx/Rx the same thing as running it through an FTDI board? When I have the ESP8266(ESP-01) hooked up to the Uno, hooked up to my PC, uploading from sketch even with ESP8266 board selected, is this uploading through the Uno or is it uploading to the Uno?

Does using the IDE mean an Arduino is involved and the ESP8266 module is not running as a standalone?

Here is a good overview of the options you have for programming an ESP8266. It talks about a specific ESP8266 breakout board (Adafruit Huzzah) but it is generally applicable. https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/overview

I use the Arduino IDE to program these (together with an FTDI/ USB connector).

INTP:
What do you mean program it like an Arduino?
Using Arduino IDE’s C++ language, include libraries, etc?

You can program it using the Arduino IDE’s C++ language, making use of functions like pinMode, digitalWrite, analogRead, Serial.begin etc… On top of that, you get a lot of functions specifically for the ESP8266, that have to do with WiFi, servers, IP, …

INTP:
I’m still unclear on hardware hookup when programming- is hooking it up to an Uno’s Tx/Rx the same thing as running it through an FTDI board?
When I have the ESP8266(ESP-01) hooked up to the Uno, hooked up to my PC, uploading from sketch even with ESP8266 board selected, is this uploading through the Uno or is it uploading to the Uno?

I’ve used a lot of techniques:

  1. Connecting it to the RX/TX pins of an Uno, (using level shifters!) to make use of the ATmega16U2 (USB-to-Serial) it has onboard. Then I connect a 10µF capacitor between reset and ground (watch the polarity) to prevent the Uno from resetting. The ATmega328P of the Uno is not involved at all. (I recommend uploading blink to the Uno beforehand, just to be sure that it is not using the Serial connection.)

In this setup, the ATmega16U2 of the Uno converts the USB connection to the computer to a serial connection to the ESP8266. When uploading a sketch, it is uploaded directly to the ESP.

  1. Using an FTDI converter.
    This is exactly the same, but instead of using the Uno’s USB-to-Serial converter, we use a separate one.

  2. Connecting to a computer’s RS232 port (using level shifters, obviously)
    In this case, you don’t even need a USB-to-Serial converter, since there is a direct UART link between the ESP and the computer.

  3. Using an Arduino/Teensy with USB capabilities. Boards like the Leonardo or Teensies have a USB connection built-in, on the main µ-controller. This emulates a virtual serial port as well, just like the FTDI chip or the ATmega16U2 on the Uno.
    By mirroring this USB virtual port onto Serial1, the hardware serial port on pins 0 and 1 (to which you connect the ESP), you can use it as a Serial bridge, and use it to program the ESP.
    Use level shifters for 5V boards!

The code I use for my Teensy:

void setup() {
Serial.begin(115200);
Serial1.begin(115200);
}

void loop() {
  while(Serial.available()){
    Serial1.write(Serial.read());
  }
  while(Serial1.available()){
    Serial.write(Serial1.read());
  }
}

INTP:
Does using the IDE mean an Arduino is involved and the ESP8266 module is not running as a standalone?

It is standalone. It is actually a System On a Chip (SOC) with a 80-160MHz CPU, 80KB of RAM, 1-4MB of flash, integrated WiFi, quite a lot of I/O etc … So on it’s own, it’s many times more powerful than most Arduino’s.

How I connect my ESP8266:

  • Vcc via a decent 3.3V regulator (>250mA) to a power source (USB, mostly)
  • Ground to the ground of the power source
  • CH_PD to Vcc through a 10K resistor
  • Reset pulled up by a 10K resistor to Vcc
  • A switch between Reset and Ground (to reset the ESP)
  • GPIO15 to ground through a 10K resistor
  • GPIO0 to ground through a 10K resistor and a switch, to upload new firmware
  • Decent bypassing capacitors between Vcc and ground (I use 100µF and 100nF, as close to the chip as possible)

Thanks for all the info. Things are starting to make sense.

Well, the firmware stuff isn't making sense. Is the firmware on the ESP8266 what determines what language it recognizes? For example, is there an "Aruino sketch" firmware I need to find and upload?

INTP: is there an "Aruino sketch" firmware I need to find and upload?

No, Ivan's ESP8266 Arduino IDE plugin compiles it to a binary file that can be executed without the need for any other firmware.

Other platforms, like Lua and Micropython, need a Lua or Python interpreter. Once the interpreter firmware is flashed, you can upload the scripts you want to run (or execute commands directly from a serial terminal).

This is how I wire my ESP8266’s:
ESP8266_Schematic.png

Basically I dont want to use it as like Uno.

I just want it to act as a device/module which will transfer the data

For program to run I will be using Uno.

So in that case I was asking any basic programming will be required to it so that it can understand AT commands used in Arduino Sketch to send the data

Or it comes with the basic setup which is capable of handling it.

NVT123: So in that case I was asking any basic programming will be required to it so that it can understand AT commands used in Arduino Sketch to send the data

My point here was that AT commands are just a really inefficient way to communicate. It would be a lot easier to just send and receive raw values over serial, and let the ESP do all the networking stuff (connect to WiFi, establish a connection to a server, wrap the data in HTTP packets, host a webpage, whatever), so you don't have to worry about all that in your Arduino sketch. Just take a value from the serial port, no questions asked about where it came from, or send a value and just know that it will reach its destination, without having to wonder how it will get there.

NVT123: any basic programming will be required to it so that it can understand AT commands used in Arduino Sketch to send the data

Or it comes with the basic setup which is capable of handling it.

All the ESP8266 modules I've bought come with the AT firmware installed(though sometimes an old version). The DOIT ESP8266 shields come with a custom firmware so you would need to flash the AT firmware on those. So the answer to your question is probably you don't need to do any programming at all to your module. The way to find out is to give it a try. Connect the module to your Arduino correctly, start a serial connection at the correct baud rate(the default is 115200), and send the command AT, you should receive the response OK. AT+GMR should give you the firmware version and some other information. If everything is connected and configured correctly and you're not receiving response that would indicate the AT firmware may not be installed and you will need to do so.

PieterP: It would be a lot easier to just....

Maybe for you, not for a beginner. There are libraries that make it very easy to control an ESP8266 module via AT commands, https://github.com/bportaluri/WiFiEsp is my favorite. Are AT commands less efficient than some custom protocol of your own invention? Possibly, but sometimes it's worth sacrificing some efficiency for simplicity when you're getting started with this stuff. Just getting serial communication with the ESP8266 module working is extremely challenging for many beginners, why make it even more difficult right from the start? That can all come later.

pert: Maybe for you, not for a beginner. There are libraries that make it very easy to control an ESP8266 module via AT commands

Agreed, it may be a bit easier, but then again, there are some great and easy libraries for the ESP8266 too.

But if you're a complete beginner, who isn't confident about serial connections etc, AT may the best option indeed.

PieterP: there are some great and easy libraries for the ESP8266 too.

I agree about that, I'm really on the fence whether directly programming a standalone ESP8266 board using the esp8266 Arduino core or using serial communication between a standard Arduino AVR board and an ESP8266 module/shield running the AT firmware is easiest for a beginner. They each have their own difficulties and the specific application may determine which is more appropriate. In this case since NVT123 has specifically stated they want to take the second approach that question is answered for us.

NVT123: I just want it to act as a device/module which will transfer the data

Look at ESP-Link. By default the ESP8266 just sits and listens on port 23 and transfers everything directly to the serial port (bi-directionally).

pert:
I agree about that, I’m really on the fence whether directly programming a standalone ESP8266 board using the esp8266 Arduino core or using serial communication between a standard Arduino AVR board and an ESP8266 module/shield running the AT firmware is easiest for a beginner. They each have their own difficulties and the specific application may determine which is more appropriate. In this case since NVT123 has specifically stated they want to take the second approach that question is answered for us.

IMHO:

Arduino core by igrr for the ESP8266 is hands-down the winner … “AT” + Arduino is convoluted, firmware version sensitive, and rarely makes any sense in the last 12 months.

I have multiple ESP8266 as Arduino projects published.

Ray

INTP: Thanks for all the info. Things are starting to make sense.

Well, the firmware stuff isn't making sense. Is the firmware on the ESP8266 what determines what language it recognizes? For example, is there an "Aruino sketch" firmware I need to find and upload?

Used as an Arduino, the Lua or AT firmware is overwritten. The compiled sketch is uploaded with native code to manage the RF section and protocol stacks. The linker performs all thd magic with the only downside a bit longer upload time due to the extra code.

You CAN use an ESP8266 without the RF section on and eliminate all the extra power considerations.

Ray