A Webserver running on Arduino Nano ESP Sensor

First Steps

  • Install Serial-USB Drivers for your platform / Mac OsX Catalina: CH340G v1.5 drivers from Github
  • Download and install Arduino Studio IDE
  • Connect board, then open Arduino Studio and configure the connection
  • Set the board type to “Arduino Nano”
  • Set the correct port
  • Set the correct board
  • Optional: Install additional libraries with library manager

Hello World

void setup() {
Serial.begin(19200);
Serial.println("Hello World!");
}
void loop() {}

Exploring AT Commands

#include <NanoESP.h>
#include <SoftwareSerial.h>
NanoESP nanoesp = NanoESP();void setup() {
Serial.begin(19200);
nanoesp.init();
nanoesp.serialDebug();
}
void loop() {}
  • AT - starts a command
  • AT+COMMAND=? - Test, see the list of command options
  • AT+COMMAND? - Query, see the current configuration
  • AT+COMMAND= - Set, define parameters
  • AT+COMMAND - Execute
11:40:24.985 -> AT+GMR11:40:24.985 -> AT version:0.22.0.0(Mar 20 2015 10:04:26)
11:40:24.985 -> SDK version:1.0.0
11:40:25.022 -> compile time:Mar 20 2015 11:00:32
11:40:25.022 ->
11:40:25.022 -> OK
11:43:13.284 -> AT+CWLAP12:43:15.393 -> +CWLAP:(3,"SSID1",-62,"e0:28:6d:7c:95:58",1)
12:43:15.393 -> +CWLAP:(3,"SSID2",-54,"b0:4e:26:66:31:d4",1)
12:43:15.430 -> +CWLAP:(4,"SSID3",-90,"dc:53:7c:4f:3d:ef",1)
12:43:15.467 -> +CWLAP:(3,"SSID4",-89,"a8:d3:f7:da:67:5b",5)

Configure WLAN Access

11:50:24.244 -> AT+CWMODE?11:50:24.244 -> +CWMODE:1
11:50:24.244 ->
11:50:24.244 -> OK
11:50:41.438 -> AT+CWMODE=?
11:50:41.438 -> +CWMODE:(1-3)
11:50:41.438 ->
11:50:41.438 -> OK
12:13:01.595 -> AT+CWJAP="SSID","PASSWORD"
12:13:04.654 ->
12:13:04.654 -> OK
12:14:55.202 -> AT+CIFSR
12:14:55.202 -> +CIFSR:STAIP,"192.168.2.108"
12:14:55.237 -> +CIFSR:STAMAC,"18:fe:34:cf:9a:b5"
12:14:55.274 ->
12:14:55.274 -> OK

Simple TCP Server

/* P03 - TCP Server
*
* See https://github.com/FKainka/NanoESP/blob/master/examples/BASICS/TCP-Server/TCP-Server.ino
*/
#include <NanoESP.h>
#include <SoftwareSerial.h>
#define SSID ""
#define PASSWORD ""
NanoESP nanoesp = NanoESP();void setup() {
Serial.begin(19200);
nanoesp.init();
//Connects with your WiFi
if (nanoesp.configWifi(STATION, SSID, PASSWORD)) { //AP Mode: Module creates WiFi
Serial.println("Wifi ready");
}
else {
Serial.println("Wifi not ready");
}
//Print IP in Terminal
Serial.println(nanoesp.getIp());
//Starts TCP-Server on Port 80
if (nanoesp.startTcpServer(80)) {
Serial.println("TCP Server ready");
}
else {
Serial.println("TCP Server not ready");
}
}
void loop() {
nanoesp.serialDebug();
}
13:47:20.167 -> 0,CONNECT
13:47:20.167 ->
13:47:20.167 -> +IPD,0,346:GET / HTTP/1.1
13:47:20.205 -> Host: 192.168.2.108
13:47:20.205 -> User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:74.0) Gecko/20100101 Firefox/74.0
13:47:20.276 -> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
13:47:20.311 -> Accept-Language: en-US,en;q=0.5
13:47:20.311 -> Accept-Encoding: gzip, deflate
13:47:20.348 -> DNT: 1
13:47:20.348 -> Connection: keep-alive
13:47:20.348 -> Upgrade-Insecure-Requests: 1

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store