Skip to content

Latest commit

 

History

History
361 lines (253 loc) · 9.93 KB

README.md

File metadata and controls

361 lines (253 loc) · 9.93 KB

Arduino-ESPAT-TCP

TCP/UDP Applicaton for Arduino using ESP8266's AT firmware.
You don't need Ethernet card.
You need only ESP8266 module.

Memory usage

Saves Flash and SRAM

UNO+ENC28J60+UIPEthernet+PubSubClient

Sketch uses 25090 bytes (77%) of program storage space. Maximum is 32256 bytes.
Global variables use 1736 bytes (84%) of dynamic memory, leaving 312 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.

UNO+W5100+Ethernet+PubSubClient

Sketch uses 19582 bytes (60%) of program storage space. Maximum is 32256 bytes.
Global variables use 1101 bytes (53%) of dynamic memory, leaving 947 bytes for local variables. Maximum is 2048 bytes.

UNO+ESP01+Software Serial+AT firmware

Sketch uses 9938 bytes (30%) of program storage space. Maximum is 32256 bytes.
Global variables use 897 bytes (43%) of dynamic memory, leaving 1151 bytes for local variables. Maximum is 2048 bytes.

Hardware requirements

  • ESP8266 module like ESP01
    ESP8266 has 1MB FLASH and 4MB FLASH (or more) SoCs, but it doesn't matter.

  • ATmega328/ATmega2560/STM32

  • UART-USB converter

Software requirements

  • Arduino Environment
    Core library is required when using STM32.
    It supports Maple cores and ST cores.

  • ESP8266 AT Firmware
    AT firmware version can be identified by AT version and SDK version.
    AT version V2 added MQTT and HTTP commands.
    However, AT version V2 does not support 1M SoCs like ESP01.
    When using 1M SoCs like ESP01, it is necessary to use AT version V1.
    This repository works with both V1 and V2.
    You can download AT version V1 from here.
    Note
    Some firmware here does not support 1M SoC such as ESP01.
    I used this.

AT+GMR
AT version:1.7.5.0(Oct 20 2021 19:14:04)
SDK version:3.0.5(b29dcd3)
compile time:Oct 20 2021 20:13:50
Bin version(Wroom 02):1.7.5
  • Terminal software such as CoolTerm
    I use TeraTrem.
    You can down load from here.

Applications

MQTT_Publish_ESP01
Simple MQTT Pubish Application.

MQTT_Subscribe_ESP01
Simple MQTT Subscribe Application.

slide1

TCP_Client_ESP01
Simple TCP Socket Client Application.

TCP_Server_ESP01
Simple TCP Socket Server Application.

UDP_Broadcast_Client_ESP01
Simple UDP Socket Client Application using UDP Broadcast.

UDP_Broadcast_Server_ESP01
Simple UDP Socket Server Application using UDP Broadcast.

slide2

NTP_Client_ESP01
Simple NTP Client Application.
It require this library.

SNTP_Client_ESP01
Simple SNTP Client Application.

slide3

SMTP_Client_gmail_ESP01
Simple SMTP Client Application.
You need gmail account.

slide4

Flash AT firmware to ESP01.

The 3.3V output of the UART-USB converter has too little current to be used.
Power is supplied using 5V from the UART-USB converter and 3.3V from the regulator.

  • GPIO2 must be pulled up.
  • GPIO0 must be connected to GND.
  • CH_PD must be pulled up.
  • RESET must be pulled up.

See here for details..

esp01-flash

Setup ESP01 using terminal software such as CoolTerm.

  • GPIO2 must be pulled up.
  • GPIO0 must be pulled up.
  • CH_PD must be pulled up.
  • RESET must be pulled up.

esp01-setup

Connect to ESP01 at 115200 bps using terminal software.

AT+GMR
AT version:1.6.2.0(Apr 13 2018 11:10:59)
SDK version:2.2.1(6ab97e9)
compile time:Jun  7 2018 19:34:26
Bin version(Wroom 02):1.6.2
OK

AT+CWMODE=1

OK
AT+CWLAP
+CWLAP:(3,"Picking",-86,"34:12:98:08:4b:4a",1,-4)
+CWLAP:(4,"ctc-g-fa4a2e",-92,"c0:25:a2:b1:8c:2e",2,3)
+CWLAP:(4,"aterm-e625c0-g",-49,"c0:25:a2:ac:cb:ba",3,15)
+CWLAP:(1,"aterm-e625c0-gw",-48,"c2:25:a2:ac:cb:ba",3,15)

OK

AT+CWJAP="Your AP's SSID","Your AP's password"
WIFI CONNECTED
WIFI GOT IP

OK

AT+CIPSTA?
+CIPSTA:ip:"192.168.10.142"
+CIPSTA:gateway:"192.168.10.1"
+CIPSTA:netmask:"255.255.255.0"

OK
AT+CWQAP

OK

WIFI DISCONNECT

*** UNO ONLY ***
*** Change baudrate to 4800bps ***
*** Because there is no the 2nd UART in UNO ***
*** So UNO use Software Serial with low speed ***

AT+UART_DEF=4800,8,1,0,0

Re-Connect to ESP01 with 4800 bps.

AT firmware has a function that automatically connects to the last connected AP when the module is reset.
Using this function, you can omit the SSID and password.

AT+RST
WIFI CONNECTED
WIFI GOT IP
AT+CIPSTA?
+CIPSTA:ip:"192.168.10.142"
+CIPSTA:gateway:"192.168.10.1"
+CIPSTA:netmask:"255.255.255.0"

OK

If you want to change the AP, execute the following command again.

AT+CWJAP="New AP's SSID","New AP's password"
WIFI CONNECTED
WIFI GOT IP

How to Firmware Upate

1.Make sure TE(terminal equipment) is in sta mode

AT+CWMODE=1

OK

2.Make sure TE got ip address

AT+CIPSTA?
+CIPSTA:ip:"192.168.10.115"
+CIPSTA:gateway:"192.168.10.1"
+CIPSTA:netmask:"255.255.255.0"

OK

3.Let's update

AT+CIUPDATE
+CIPUPDATE:1    found server
+CIPUPDATE:2    connect server
+CIPUPDATE:3    got edition
+CIPUPDATE:4    start start

OK

4.Check firmware version

AT+GMR
AT version:1.7.5.0(Oct 20 2021 19:14:04)
SDK version:3.0.5(b29dcd3)
compile time:Oct 20 2021 20:13:50
Bin version(Wroom 02):1.7.5
OK

Connect ESP01 to UNO.

ESP01(Tx) - UNO(D4)
ESP01(Rx) - UNO(D5)

ESP01-MQTT-UNO

You can't use on-board 3.3V.
An electric current is insufficient.

Connect ESP01 to MEGA2560.

ESP01(Tx) - MEGA(D19)
ESP01(Rx) - MEGA(D18)

ESP01-MQTT-MEGA

You can't use on-board 3.3V.
An electric current is insufficient.

Connect ESP01 to STM32F103(MAPLE Core).

ESP01(Tx) - STM32F103(PA3)
ESP01(Rx) - STM32F103(PA2)

ESP01-MQTT-STM32F103_MAPLE-Core

MAPLE Core.
https://github.com/rogerclarkmelbourne/Arduino_STM32

Connect ESP01 to STM32 NUCLEO(ST Core).

ESP01(Tx) - STM32F103(PA10)
ESP01(Rx) - STM32F103(PA9)

ESP01-MQTT-STM32F103_ST-Core

ST Core.
https://github.com/stm32duino/Arduino_Core_STM32

Connect ESP01 to STM32 F103 BluePill(ST Core).

ESP01(Tx) - STM32F103(PA3)
ESP01(Rx) - STM32F103(PA2)

ESP01-MQTT-BLUEPILL_STM32F103_ST-Core

Serial printing goes to PA9.

Connect ESP01 to STM32 F103 MapleMini(ST Core).

ESP01(Tx) - STM32F103(PA3)
ESP01(Rx) - STM32F103(PA2)

ESP01-MQTT-MAPLEMINI_STM32F103_ST-Core

Serial printing goes to PA9.

STM32F103 development board on which ESP01 can be mounted(ST Core).

ESP01(Tx) - STM32F103(PA3)
ESP01(Rx) - STM32F103(PA2)

ESP01-STM32

Serial printing goes to PA9.

Connect ESP01 to STM32 F303 BlackPill(ST Core).

ESP01(Tx) - STM32F303(PA3)
ESP01(Rx) - STM32F303(PA2)

Serial printing goes to PA9.

Connect ESP01 to STM32 F401 BlackPill(ST Core).

ESP01(Tx) - STM32F401(PA3)
ESP01(Rx) - STM32F401(PA2)

Serial printing goes to PA9.

Connect ESP01 to STM32 F4DISC1(ST Core).

ESP01(Tx) - STM32F4DISC1(PD9)
ESP01(Rx) - STM32F4DISC1(PD8)

I want to Fritzing Part of this board.
Serial printing goes to PA2.

Connect ESP01 to STM32 F407 development board that like DIYMORE F407VGT.

ESP01(Tx) - STM32F407(PA3)
ESP01(Rx) - STM32F407(PA2)

https://stm32-base.org/boards/STM32F407VGT6-diymore
Serial printing goes to PA9.

UART to WiFi module

We can get a module for UART communication.
We can write AT firmware to this.
Although it supplies 5V power, the TTL level of UART is 3.3V.
ESP-UART-MODULE-1

ESP-UART-MODULE-2

ESP01 Adapter board

Only $1 for AliExpress/eBay.
External pin header is 5V,GND,TXD,RXD.
It has a 5V->3.3V regulator and can supply power directly from UNO's 5V.
Although it supplies 5V power, the TTL level of UART is 3.3V.
ESP01-Adapter-3

Use with TFT Shield

UNO compatibles can have a pin header inside the pin socket.
If you do not use SD-CARD, you can freely use digital pins # 10 to # 13 of the TFT shield.
These pins can be used for UART communication with the ESP01.

ESP01-MQTT-UNO-TFT-2

esp01-mqtt-uno-tft