Esp 01S
Esp 01S
All esp8266 arduino compatible modules must be powered with DC current from any kind of
source that can deliver stable 3.3V and at least 250mA. Also logic signal is rated at 3.3v and the
RX channel should be protected by a 3.3v divisor step-down. You should be careful when using
this module with Arduino or other boards which supplies 5v, because this module usually do not
come with overpower protection and can be easily destroyed.
After doing this connection you can use the following command to trigger the deep sleep mode:
ESP.deepSleep(sleepTimeInSeconds * 1000000);
Talking with ESP-01 (AT / LUA / Arduino)
ESP8266-01 gives you many methods to communicate with it through the RX/TX pins or over the
air (OTA). The differences are not only in hardware but can be also in what kind of firmware is
flashed out of the box. No matter what firmware comes default installed, you should be able to
flash your preferred firmware by following the firmware flashing instruction from the datasheet.
This module can be programmed using LUA code, Arduino code or directly through AT
commands and this gives us more freedom when embedding this device in our projects. Also,
there are few python firmware modes but i haven’t had the chance to test them. I personally
choose to work with Arduino because of the past experience and tones of libraries available.
As it comes, out of the box, this module is ready to talk via AT commands without any other extra
settings or configurations. There are many software applications which you can use to
communicate via AT and have tones of readymade tools and functions which will make
everything easier. I used ESPlorer and i totally recommend it, you can find it here. After booting,
to be able to use AT commands, module should display “ready” on the serial monitor.
Few basic AT commands examples:
AT – response OK
AT+CWLAP – list nearby available WiFi networks
AT+GMR – check the firmware version
AT+CWJAP=” <access_point_name>”,”<password>” – join WiFi network using credentials
AT+CIFSR – get current allocated IP address
In order to be able to talk with the ESP8266 arduino compatible module, you need to choose a
way to connect it with your computer. You can communicate with the module via standard Serial
communication RS232 by using an Arduino board as a proxy/bridge
Arduino Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial
driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a
USB-to-serial converter. In order to use Arduino as a bridge, first you need to load an empty
program on it. After doing that, you need to make the following connections in order to work:
UNO ESP-01S
RX RX
TX TX
3.3V 3.3V
GND GND
RST RST
CH_PD OR EN 3.3V
After that you should be able to see data and send AT commands in Serial Monitor by
selecting Arduino’s COM port, setting a proper baudrate, default should be 115200, and make the
additional settings to read “Both NL & CR
Firmware Over The Air (FOTA) solution in every embedded DIY or commercial project is a
highly desirable if not a required feature today, when every project core needs to scalable. So the
possibility to upload your code from a remote computer via Wi-Fi connection rather then Serial is
a high advantage in every project. First you need FOTA needs needs prerequisites. First firmware
upload needs to be done via Serial, and if the OTA routines are correctly implemented in the
program next uploads can be done over the air.
Because the module needs to be exposed wirelessly, the chance to being hacked and loaded with
maleficent code exists. You can improve your security by setting custom port and password.
Check functionalities from the ArduinoOTA library that may help you to boost security. Because
of the complexity of this procedures we will cover the full story in a future article, but for now be
aware that this option exists and it works pretty good.
Another way to connect the esp8266 arduino module to computer is to use a TTL or FTDI USB-
to-serial dedicated module. There are plenty of them on the market and there are quite cheap, but
make no mistake, here quality does matter. You may encounter problems when working with it if
ending up with a cheap one because of the differences in connections and also driver
compatibility.
Most used TTL / FTDI converters chips are CH340G, CP2102 and FT232RL. I personally used
the first two ones and i have no problem when loading programs. Following connections need to
be done:
ESP-01S TTL/FTDI
RX TX
TX RX
VCC 3.3V
GND GND
RST 3.3V/Float
CH_PD OR EN 3.3V
I highly recommend you not to use the TTL 3.3v power supply because most of them are not able
to provide enough power to handle the esp8266 arduino compatible device. The embedded
voltage regulator used on this module are not the happiest choice and you may get in trouble if it
cannot support ESP peeks. If you choose to use an external power supply don’t forget to setup a
common ground in order to have a working circuit.
You can find TTL modules that have TX rated at 3.3v, if not, you shod step-down the TX channel
to protect your ESP-01 module. You can see bellow a wiring scheme between ESP-01 and
CP2102 which includes a reset button connected to ground, and also GPIO0 for boot switch.
After resetting the module in Download code from UART you should see a message containing
“boot mode: [1,6]” in the serial monitor, if you are on the correct baudrate. A wrong baudrate
setting will display garbage text / characters or nothing at all. After that you should be able to
upload your sketch to ESP8266. When upload is done, module should reset itself. Don’t forget to
pull HIGH the GPI0 or the module will get in Download mode again and you will not be able to
see it working. The module can be rebooted at any time by pulling REST pin to LOW. After each
reset it will follow the boot sequence and program loading.
Once the ESP8266 board is installed and activated in Arduino IDE, you will be able to include
all ESP WiFi libraries and examples that comes with the package. The most used library is
ESP8266WiFi which offers many implementation examples like WiFiClient, WiFiServer,
WiFiAccessPoint etc. You can find allot of projects examples over the internet, I for example,
found great ideas on arduino.cc projecthub. Here is a simple Arduino blink example which you
can use to test the esp module with the built in LED:
/*
ESP8266 Arduino Blink by Simon Peter
Blink the blue LED on the ESP-01 module
This example code is in the public domain
Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is acive low on the ESP-01)
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000); // Wait for two seconds (to demonstrate the active low LED)
}
Off course, after that you can try a more complex example by loading a ESP8266 Arduino WiFi
Client example program that sends data via WiFi to the data.spakfun.com iot platform:
/*
* This sketch sends data via HTTP GET requests to data.sparkfun.com service.
*
* You need to get streamId and privateKey at data.sparkfun.com and paste them
* below. Or just customize this script to talk to other HTTP servers.
* ESP8266 Arduino example
*/
#include <ESP8266WiFi.h>
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
int value = 0;
void loop() {
delay(5000);
++value;
Serial.print("connecting to ");
Serial.println(host);
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
}
Or if you need to make a server in your network, you can try ESP8266 Arduino Wifi Server
example program:
/*
* This sketch demonstrates how to set up a simple HTTP-like server.
* The server will set a GPIO pin depending on the request
* http://server_ip/gpio/0 will set the GPIO2 low,
* http://server_ip/gpio/1 will set the GPIO2 high
* server_ip is the IP address of the ESP8266 Arduino module, will be
* printed to Serial when the module is connected.
*/
#include <ESP8266WiFi.h>
// prepare GPIO2
pinMode(2, OUTPUT);
digitalWrite(2, 0);
WiFi.begin(ssid, password);
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
client.flush();
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.softAP(ssid, password);
void loop() {
server.handleClient();
}