Articles Hierarchy

Articles Home » Arduino Projects » ESP / 8266 / 32 as WIFI Arduino

ESP / 8266 / 32 as WIFI Arduino

connect ESP8266
connect ESP32
flash tool
Arduino IDE ESP8266
Arduino IDE ESP32
all in one
PID control
+ + graphic visualization
+ + operation buttons
+ + operation sliders
+ + use ESP file system SPIFFS
+ + temperature sensor

restart from RPI


haha, my desk

i had a small ESP8266 here, still packed,
but now ordered a ESP32
with the idea that i can use it as cheaper wifi arduino

so for the order i tested ( new account / first order ) LAZADA because there was
+ free delivery and
+ ( free ) cash on delivery
and all worked well ( delivery time 4.7 .. 13.7) for about 10 EURO.
see side by side:
old ESP-8266
new ESP-WROOM-32 ( no idea whats the difference to ESP 32S also the boards have that label too)
both with print: NODE MCU

NodeMcu, Wiki ESP12 Wiki ESP32

ESP8266 info and versions
ESP32 spec is old? for my SoC, a other good info is at

so even i see some video instructions about using arduino IDE only i want to understand that new world better, what is the default operation.
possibly uploading by Arduino IDE erases default functionality and i would not know what/how to load default again!

the boards have a USB port ( like the arduinos ) to power the board and
there should run a default program where you can configure its functions by AT commands.
ESP8266 from espressif
ESP32 from espressif
The default baud rate of AT command is 115200
AT commands are ended with a new-line (CR-LF)
, so the serial tool should be set into "New Line Mode"

basic AT commands:
AT __ to check communication
AT+GMR __ to check version
AT+RST __ to reset and see boot info
AT+SYSRAM __ to check RAM

so all i need is a PC ( start with win7 PC ( later RPI )) and a terminal emulator ( start with Arduino IDE or HTerm ) and a USB cable.
for the USB port might need to take a look at
win7 / computer management / device manager / ports (com&lpt) /

connect ESP8266
at first connect ESP8266 a blue LED near wifi antenna blinks 2 times.
first there is no USB response, try again? USB connector..

USB chip? 340 (G or C )
download driver: WCH run CH341SER.EXE

replug ESP8266 and see


AT version:
SDK version:0.9.5



ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 816, room 16
tail 0
chksum 0x8d
load 0x3ffe8000, len 788, room 8
tail 12
chksum 0xcf
ho 0 tail 12 room 4
load 0x3ffe8314, len 288, room 12
tail 4
chksum 0xcf
csum 0xcf

2nd boot version : 1.2
SPI Speed : 40MHz
SPI Mode : QIO
SPI Flash Size : 4Mbit
jump to run user1

Ai-Thinker Technology Co. Ltd.


i press the buttons but can not force a reboot?

try tablet WIFI

check IP with FING

try browser

connect ESP32
at first connect ESP32 a red LED ?pwr? is ON
i see after some seconds a device driver install error? and a
"Other devices" CP2102 USB to UART Bridge Controller but no port??

from silabs i download a zip file ( for my win7 ) 3.8MB and find a CP210x_VCP_Windows\CP210xVCPInstaller_x86.exe for my win7 32bit OS

and now after replug the ESP32 i see com25

with HTerm COM25 connect 115200 / 8 / 1 / n/ send CR LF see

ok, the "what" seems to be related to "NL", so "CR" is ok and on "?"
get ( this time using Arduino monitor )

now i type "op -Q"
:>op -Q
:>sta -Q
:>sta -S

so what did i do? here i found a
SSC Command Reference Parameter Description
-Q Query Wi-Fi mode.
-S Set Wi-Fi mode.

There are 3 Wi-Fi modes:
mode = 1: STA mode
mode = 2: AP mode
mode = 3: STA+AP mode

that is something, so here is not the AT command set loaded,
instead ( RTOS with ) a SSC set
with a missing documentation on "?" or "help"
LOL "rudi" had the same problems here
i have no idea, who loaded that SoC ?espressif" default ESP-32-wroom-32 setup?
or the unknown board producer?
also try from RPI3, this time no driver problems,

now i try use HTERM and press the down left ( of usb port ) button and see that boot msg with very cryptic version system.

a other basic thing ( besides the USB port AT operation "menu" ) is:
the boards should start already as kind of webserver ( or it could be configured and enabled by AT commands ) and then operated via WIFI, the LUA world!

yes, as i now find ( above linked boot log ) and modeinfo AP
there should be a AP: Access Point ( in the air ) i see ESP_81C0A0 from my tablet.
here i see that with a ESP8266 ( what software loaded?) you can connect a phone to the AP ( in that version was a password? i did not need )

and start browser to or
that did not work for me.

so, in both cases my tablet browser could not get a webpage from the AP, i might have a different problem, should try a other device and browser, well also not lucky, laptop see the AP, can connect
( and see in link details that bytes are flowing both directions? )
but 2 browser can not connect to


so still i not find documentation of the board, maker ...
and esp. PINOUT.
compared to many boards with good documentation online,
they have that stupid form factor like the ESP8266 board, 2 pin wider so fit exactly on a breadboard ( means no empty rows left for cable outside the board ( only under the board cables possible )
but the small board also has a disadvantage, there is no space on top for a pin labeling, but i see backside:

so i can search for a fitting pinout. I see that board also at aliexpress where it is indicated as Brand Name: ROBOTLINKING ( wholesale?)
i try my own PINOUT because the front/back thinking is difficult, even on breadboard.
pls see also / copy from / my google sheets updated version!

flash tool
but already at the beginning of ESP i read some story that there where boards without firmware, that for loading a capacitor was missing...
and pressing ( and its timing ) of the "flash" button on the board... not jet find info.

there is a (windows) tool you can download to flash the boards,
espressif git download area or

so now i would need something to UPLOAD.

( this BLOG is not following always the timeline / my working style is chaotic )
as i still miss the LUA world i follow Peter Jennings
and download ESP8266Flasher.exe for Win32 and NodeMcu firmware or newer?
but i understand the flasher comes with a default ( possibly older as the new firmware )
i try a flash and it looks ok, connected a terminal and see no response ( at 9600 or any other db rate ).

Selecting the new firmware not possible as there is no .bin file in the zips,
first need a compilation?
or find the newest AT bin files from espressif

but i could try anyhow the LUA LOADER (what can also call the ESP8266Flasher after you show him the path )

a more complex new environment should be also find a ref. here.
i got confused by all that options, looks like there is a LOGIN ( only possible / needed )
when you buy the PRO version? but also there is a register/login at the community forum what is not connected with the login in the IDE.
also i selected/followed the ATOM editor ( its the main part ) and very big download.

later more...

Arduino IDE & ESP8266 ESP and Arduino IDE
for ESP8266 i follow here what points to using IDE board manager
-1- change preferences

-2- get the tools

-3- select board in IDE

-4- does board info work?

-5- make a info sketch and upload

did you see, the upload was 228kB big??
-6- start the monitor

ahm that works only one time after upload, reload monitor and press down left button "user" ( blue led goes ON now) or down right button "flash" not reboot board / with this not print that info again.
-7- a check with wifi tablet now show new AP, still no webpage.

so i was right, a upload of a empty sketch by arduino IDE change the whole thing, the Ai-Thinker thing is gone, the AT menu lost, the AP config changed but still not work for me.

next step: i see here a arduino sketch for use ESP8266 IO and webserver.
i not like he connect a LED without resistor? to ESP8266 P7 aka arduino pin13 / default blink program/
but i try his webserver / remote led operation program.
- arduino IDE ( i needed to rename path and ino file / kill the spaces )

- browser, firefox give me some IP search B.S.,
IE9 and google chrome (Version 59.0.3071.115 (Official Build) (32-bit)) ok

- and the log in the arduino IDE monitor

no hardware led connected, not check on the GPIO output for real operation, but its ONLINE.
with small beauty work

looks like

code: git

Arduino IDE & ESP32
for ESP32 see Installation and here and win10 and here
looks like the installation is more difficult, as no board-manager support ready up to now.

-1- newest arduino ( i have already )

-2- install git tool
from git download Git-2.13.3-32-bit.exe ( and test for old win7 32bit ) found a git-bash icon and found git-gui ( and make also a link to desktop ) and start.

-3- according manual i created subdirs:
and i noticed that there is no esp8266 ? where that boardmanager installation ended up?
c:\Users\...\Documents\Arduino\libraries\ also nothing

anyhow i try and got a error "target directory already exists" so deleted the /esp32/ path and now it worked and it is been created again...
finding the second step with the double click on git.exe to get the "tools"
again not that easy, a start by command line ended in a error.

-4- start arduino IDE, board select ( section: ESP32 Arduno ) i select "NodeMCU-32S" ( a strange upload speed is preselected?? )
plug in the board find COM25 and try "get board info" for com test.
start monitor and see the boot msg.

-5- i selected the WIFI scan example, the first upload failed, the second
ended with a msg "hard resetting" and i was (wrong) thinking that i need to play with that 2 buttons but nothing show up.
anyhow i restart usb connection and IDE and got the same msg. And when i opened the monitor i see the wifi scan results ( my wifi neighborhood )
OK i am in the game.
also run the simplewifiserver example with some changes.
But with this example and with my modified server from ESP8266 i got many upload fails, but no idea if that's (board or USB ) hardware or software related.

now i work on the webserver with IO operation but run into serveral problems:
-- i need up to 5 uploads until lucky finish,
-- the logic in the simplewebserver example is strange / possibly wrong
while the old ESP8266 webserver i used finally runs here also.

BUT i must check if there ever is a change on the output pin!
OK OFF is 0V, ON is 2.8 ..3.2 V

code: git

all in one
coming next? ESP32 Din Ain Aout test via webserver
also check on these AP examples here and here if i can ever call AP in a browser ( as for STA ( by above arduino IDE examples) it works very good.)

First i start with a version where i can select the board type by compiler switch:
#define useESP32 // or disable with // for ESP8266

#if defined useESP32
#include < WiFi.h >
const int DoutPin = 5; // P5
const int DinPin = 12; // Digital pin to be read
#include < ESP8266WiFi.h >
const int DoutPin = 13; // GPIO13
const int DinPin = 12; // Digital pin to be read

Now while the Ain "A0" for ESP8266 is a 1V 1024 : 10bit ADC
is for the ESP32 adjustable resolution
The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
DAC1 ADC18 P25 Aout1
DAC2 ADC19 P26 Aout2
a 2.6V 255 : 8bit DAC
and the first test of it:
#if defined useESP32
dacWrite(25,127); // 50% output
s += ("AoutPin "); s += ("DAC1"); //DAC1 ADC18 P25
s += (" : 127"); s += ("

i also changed the Arduino IDE ESP32 Upload speed down to 115200 and it works much better.

so for ESP8266 now with Din, Dout, Ain:

and for ESP32 with Din, Dout, Ain, Aout:

i tried a version with FIX IP in STA MODE but failed.
and try to make it compiler switchable between STA and AP MODE also failed,
if ever the original unusable AP was created.

so i take a step back and used that only, and see that the AP with SSID ( and login) worked, but the site was on / called WIFI and browser open not possible, so the "WiFi.config(ip,gateway,subnet);" did not work with current arduino ide ESP8266WiFi.h.

let's dig into that libraries,
-a- while esp8266wifi.h is a good name wifi.h ( from ESP32 ) is bad, because there are other libraries with that name ( and the compiler needs to choose! (one time, at a error condition i see info print that he choose the correct one) )
-b- remember we install esp8266 lib with the boardmanager so i find that lib at
and for ESP32 we made the subdir \espressif\ inside the IDE
now i try again using info from example
and the AP webserver / open by mobile browser / worked first time:

now try to find the correct way to config AP fix IP ( other than the default )
// WiFi.mode(WIFI_AP); //switching to AP mode ? why not need?
WiFi.softAP(ssid, password);
WiFi.softAPConfig(APip,APgateway,APsubnet); // tricky: config should be after begin
// WiFi.begin();
// WiFi.config(ip,gateway,subnet); // tricky: config should be after begin

code: git
start to combine it into one tool,
i already see the webpage with fix ip in AP mode on the mobile, but not the picture?

test for ESP32 AP mode fails at ( after )
even it makes that IP, but server can not start. so a small delay between
WiFi.softAP and WiFi.softAPConfig ( for ESP32 only ) helped.

also make a small Analog function test:
P25 DAC1 and P36 ADC0 connected (and also multimeter )
and operated via [up][down] web page buttons
output 255 (max) give 2.8 .. 3.2 VDC and indicated 2800 .. 4095 on ADC0
output 126 (50%) give 1.6 .. VDC and about 1200 .. 1800 on ADC0
possibly ADC0 ( SVP) not the best channel if ADC3 (SVN) is floating?
i also jumper Din and Dout ( here P5 and P17 ) to see response on web operation

i used RPI3 and install boardmanager ESP8266 get code from my github
upload ok, start NOT.

ok, sorry i got confused with the different boot msg between ?windows IDE? and ?linux IDE? version
the mistake was clearly that i need to put my WIFI login in the code ( as i used a fresh copy from my github)
add i was confused when i found that funny text ( i only see at ?linux? IDE) in the ESP8266 forum and the info was that a power problem could cause that.
well so i try with powered USB HUB / and without /
so it works on RPI3B ( without ext power ) also!
again both pictures with the different looking boot text.

RPI3 Raspbian

code: git

PID control
a minimalistic operator interface for a version with a PID control could look like this.

my latest version of my uPCS ( micro Process Control System ) was a arduino UNO as controller and a Raspberry Pi as webserver ( python flask ) for the Operator Station ( while earlier versions had a RPI desktop application )
now here i try to squeeze webserver operator interface and PID control in a ESP.
starting with ESP32 i copy the control TAB from Arduino UNO code in and connect it with the server HTML page.
not lucky with one ESP32 analog input ( i tested for PID1 input ) P27 ADC17, it is HIGH forever??
a other point you need to understand:
while the first things i tested here are web operated, means i do the IO when a button is pressed (or the page refreshed),
the PID... control has a complete different structure, that PID1, IND1 ..4 are control points what are called by timer,
if you start the monitor on the serial interface ( and diagnostic bits like Diag0 or Diag1 are enabled you see the point execution.
PID1 runs every second, INDs every 5 sec. add all the analog-in have a filter tuning..

keep that in mind when you play and look at the updated web page.
and also load it into ESP8266

there i first worry about if it fits in ( from space), but
[ESP8266] Sketch uses 248129 bytes (23%) [22% without PID] of program storage space. Maximum is 1044464 bytes.
Global variables use 34876 bytes (42%) [40% without PID] of dynamic memory, leaving 47044 bytes for local variables. Maximum is 81920 bytes.

other point is, without the analog IO of ESP8266, what use it can be?
even a DAC is nice to give out a analog 0 .. 3v3 signal, i not know any hardware what can use it, most probably we will use a PWM output ( or servo to move something ).
also for the only ONE analog input A0 ( 0 ..1V ), the PV of PID1 , IND1 ..4 , could come from linked sensors, one wire temperature...

+ + graphic visualization
with rev 1.3 introducing a detail tuning page ( VIEW ONLY )

and try the SVG thing again and as it works here too first the show only ( faceplate ):

as the SVG strings are too long i need to experiment ( to make it snappy )
like use for the text a style definition like with a inline CSS using a class...
w12, w10, w12r ( to adjust the numbers at the right at a specific position x )
but remember, as it is a CSS it will be active for the whole HTML document, not only for one SVG.
+ + operation buttons
__ here i experiment with better buttons, that browser default
anchor ( button ( text )) is not best looking and very difficult from mobile touchscreen
but i am using a browser ( not writing an mobile APP )
when i play HTML i see many links where you can make online button images with text, download them and load / use them in your server,
some links work one time, and when you want make the next button ( other color / text ), they want money.
that would be
anchor ( image ( image file ))
guess what i did? my own function:
HTML-string(anchor( LINK, embedded SVG ( WIDTH, HEIGHT, COLOR, FONTSIZE, TEXT)))

+ + operation sliders
it was heavy to port the jquery sliders but then i got stuck with the request form "GET" thing.
the buttons i use only use URL line whats easy, but for the sliders and their input form i need the full GET info.
and even googling was not easy. but actually i just need to understand that library i am using, show keywords.txt
more info at forum arduino and forum esp
the 2 different color jQuery UI slider, they work nice, just not back to the server,

but let's start with that what is really missing, the form input text / number
( you see it already last picture down right ) is HTML 101, but how to get that value to the server (ESP)
hope PeterP's code will do that; it's about HTTP_POST.
ok, i copy his sketch and get a compiler error:
inString = server.arg("x"); //compiler error: exit status 1 incompatible types in assignment of 'String' to 'char [32]'
now i change
//KLL char inString[32] ;
String inString = server.arg("x");

and i get a success / and print input text in terminal.
but when i started to copy the pieces over i run into:
exit status 1 'class WiFiServer' has no member named 'on'
and i remember, i have been there long ago when i try to do ESP8266 AND ESP32 in one code.
i start WiFiServer server(..) ( for both ) and he start ESP8266WebServer server(80)
so possibly talk a major remake, as the next error is
'class ESP8266WebServer' has no member named 'available'
and besides to do the HTML form input text OR ?number? browser?
and copy the response code
i also have to redo all the button links.
after the testing of SVG button, button GET, and slider POST externally
i start on the main program again, also formatting in 3 columns.
add i included as WEB IO the 2 board push buttons called [FLASH] and [USER]
but when i test at powerup and after upload, the [USER] button works, also the BLUE LED goes ON
when i release the BLUE LED still glows dimm, and the button indication not change back!!
( must be the hardware fiddeling with the UPLOAD function )

even it looks like finished, no, the 2 forms ( OV and SP inputs ) work only sometimes??
i needed to learn 2 things:
-a- catch 2 HTML forms from one page, ( found after nearly 2 weeks )

in setup:
in HTML need:
form action=/DETAIL/SPslider method=post
form action=/DETAIL/OVslider method=post

-b- change a HTML form submit to a SVG image button

in HTML header use
{ visibility: hidden; }
in the form use:
input type=submit id=hiddensubmit
SVG_Button_inline image

i also test from tablet, the slider operation works different, can not move the sliders ( it moves the display only), but they jump by click, as that is not very accurate: anyhow the number input ( and [enter] or [submit button click] ) works very good.
sorry, as that is still not ported to ESP32 i can not make this version public.

use ESP file system SPIFFS
now i wanted to learn about the file system on ESP8266 (3MB?),

IDE project sketch
-1- when arduino IDE is closed, create in your project sketch dir a sub directory called data
-2- i also created a sub dir
-3- and copy in a file

upgrade IDE ( see here )
-1- download from here a tool to upload files to the ESP SPIFFS

-2- copy it to
as arduino-x.x.x\tools\ESP8266FS\tool\esp8266fs.jar

-3- restart IDE

now use the IDE to upload the /data/

it takes long, the project upload is only 300k, the data upload is 3000k ( spiffs image? ) for the real favicon file is 3k only..
use the data in your project:
#include < FS.h >
// use SPIFFS in setup()
if (!SPIFFS.begin())
// Serious problem
dbln(true,"SPIFFS Mount failed");
} else {
dbln(true,"SPIFFS Mount succesfull");
//________________check SPIFFS
Dir dir = SPIFFS.openDir("/");
dbln(true,"SPIFFS content:");
while ( {
String fileName = dir.fileName();
size_t fileSize = dir.fileSize();
db(true,fileName); db(true," ");dbln(true,fileSize);

server.serveStatic("/img", SPIFFS, "/img");
server.serveStatic("/img/favicon.ico", SPIFFS, "/img/favicon.ico");

SPIFFS Mount succesfull
SPIFFS content:
/img/favicon.ico 3262
-3- use it in HTML ... head ...
s += ("< link rel=\"shortcut icon\" href=\"img/favicon.ico\" type=\"image/x-icon\" / >\r\n");

that is my most favorite icon ( i am not a designer / also little bit color blind..) i like it, feel free to use it.

INFO: if you not use all that, also no problem!
html will not find that favicon file but that is a minor error.
but this was just a test for the real thing what i want to do:
i want try to make the 2 tuning SVG files ( while SETUP )
and later just use the file links ( as you do in all HTML image calls )
and that should reduce the string length of the DETAIL page.
if the browser and the ESP webserver can handle the file transfer we will see.
now for the back ground of that:
while the PID_FP_SVG ( in the middle ) needs to be true dynamic
for numbers and bar graphs, ( now even have a 10 sec auto refresh in that page )
the tuning concept of that project is: no online tuning, must change settings in
control.ino tab and upload. so the 2 tuning pictures ( left and right ) are semi dynamic.

in terminal now see:SPIFFS Mount succesfull
make: /img/tuninganalog.svg
make: /img/tuningPID.svg
SPIFFS content:
/img/favicon.ico 3262
/img/tuninganalog.svg 3425
/img/tuningPID.svg 2114
SPIFFS total: 2949250 used: 9789

temperature sensor
as ESP8266 is not so good on analog ( the one A0 pin i not tested until now )
why not use a linked sensor: DS18B20 and here
i used on arduino / and for this PID / already, so should be easy.
you know that form factor problem of that board, well i need access to one side only, ha

the resistor i soldered near the head, the cable is a 4 wire telephone cable use
DALLAS D18B20-pin3 ____red (P6/3v3)
DALLAS D18B20-pin1 ____black (P7/GND)
DALLAS D18B20-pin2 ____yellow (P2/D1/GPIO5)

( photo linked from arduino-info)

restart from RPI
and distracted by work on RPI
first i play with the "better" NOOBS called PINN here
and as you there can see got into the change
as in the first part i tested already to use ARDUINO IDE Monitor on ESP8266 under RPI
i am now at the exact same situation but with my current RPI3 setup (using STRETCH)
means if i want from now on do the ESP development from RPI, i must try the library thing for ESP8266 and ESP32
with the linux version Arduino IDE on the RPI.
the board manager should not depend on the OS, anyhow i want try the old way:git install
cd hardware
mkdir esp8266com
cd esp8266com
git clone esp8266
Download binary tools (you need Python 2.7)
cd esp8266/tools

now i test the ESP_control_PID sketch: esp_control_v13 ( upload from RPI )
___to ESP8266
can compile but not upload

try again with press the left ( of usb port ) [USER] button ( blue led ON ) while compiling; while upload blue led OFF;
while upload the small blue led on the WIFI antenna blink fast.
keep pressed untIl upload 100%.

that is the first time i really need that button press for flash. (AGAIN it's the [USER] button, not the [FLASH] button!!!)

now the version with DETAIL (3 dynamic SVG) plus UP DOWN buttons only

espressif for Arduino IDE linux here
i want do it step by step to check if new system still need it
sudo usermod -a -G dialout $USER
sudo apt-get install git
sudo python
sudo pip install pyserial

mkdir -p ~/Arduino/hardware/espressif
cd ~/Arduino/hardware/espressif
git clone esp32
cd esp32/tools/

warning, this was very fast and looks ok, but later find that compiling not work!

by the way: if i look at the dates at that two git repositories, both very active , last adds only days ago.
now i test the ESP_control_PID sketch: esp_control_v13 ( upload from RPI )
___to ESP32
can not even compile
fork/exec /home/pi/Downloads/arduino-nightly/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++: no such file or directory
Error compiling for board Node32s.

as there is no package provided until now for the Raspberry pi linux Arduino IDE, see:
i copy back to PC and compile and upload there.
update: got a info from Robb Main: i should install again from here ( will do later )

here i test some things

code: git

if you want make a nice web page on ESP server also can use bootstrap

instead of running the ESPs as webservers,
for just building a sensor network i want try: MQTT see here

update: a year later i restart with ESP32 and that was heavy.
after a week i still not had same status like here, but read yourself