NodeMCU Amica

From CommonsLab
Jump to: navigation, search
NodeMCU Amica module.
Bottom side of the NodeMCU Amica module.

The nodeMCU Amica is a small module, which hosts an ESP8266 SOC (system-on-chip) on an ESP E-12 module. The Amica module has also a CP1202 USB-UART adapter on board, so that it is easy to communicate to the ESP8266 chip though the MicroUSB connector.

Additionally, the Amica module has an on-board LED, similar to the Arduino. But there are some differences about this LED:

  1. The LED is not connected to pin 13 as on the Arduino UNO, but on the Amica module, the LED is connected to pin D0 (aka LED_BUILTIN, aka GPIO16) rather than to 13.
  2. The LED is connected to + and not to GND, so you need to set the output to LOW in order to activate the LED.

So the blink example would look like this:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the pin LED_BUILTIN (D0/GPIO16 on NodeMCU) as an output.
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Active LOW)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(1000);                      // Wait for two seconds (to demonstrate the active low LED)

Default Communication Settings

The modules usually come preloaded and configured with one of various firmwares:

Ai-Thinker (AT)
With this firmware, the module listens at a baud rate of 115200 bps (or older ones at 57600 bps) for commands in the shape of AT+... to establish WiFi, IP and TCP connections.
Example: (User input in bold.)

Ai-Thinker Technology Co.,Ltd.

With this firmware, the module listens at a baud rate of 9600 bps for commands in the Lua programming language.
Example: (User input in bold.)

NodeMCU 0.9.6 build 20150704  powered by Lua 5.1.4
> wifi.setmode(wifi.STATION)
> wifi.sta.config("TEST-AP","12345678")
> wifi.sta.connect()
> print(wifi.sta.getip())

Changing the Firmware

The module can be changed from the [http:// AT (Ai-Thinker) firmware] to the nodeMCU firmware and back or even to other firmware written in C with, for example, the Arduino IDE.

Flashing with Arduino IDE

You need to import the ESP boards into your Arduino IDE using the Board Manager by adding the link which is given at the Arduino core for ESP code repository. (Currently that is

Using the ESPtool directly

To write new firmware into the flash memory of the module, the Python script espTool can be used:

python --port /dev/ttyUSB0  write_flash 0x00000 /Path/To/The/Firmware.bin

You might have to change /dev/ttyUSB0 to /dev/ttyUSB1 or similar.

List of AT commands (with AI-Thinker firmware)

(Based on info from ElectroDragon.) Baud rate at 115200 baud (older models at 57600) use option 'send new line' or 'carriage return' for each command.

Set Inquiry Test Execute
Syntax: AT+<CommandGoesHere>=<…> AT+<CommandGoesHere>? AT+<CommandGoesHere>=? AT+<CommandGoesHere>
Explanation: Set the WiFi mode to Client Check current mode Return which modes supported -
Command Description Type Set/Execute Inquiry test Parameters and Examples
AT general test basic - - - -
AT+RST restart the module basic - - - There must be no white space!
AT+GMR check firmware version basic - - - -
AT+CWMODE wifi mode wifi AT+CWMODE=<mode> AT+CWMODE? AT+CWMODE=? 1= Sta, 2= AP, 3=both, Sta is the default mode of router, AP is a normal mode for devices
AT+CWJAP join the AP wifi AT+CWJAP =<ssid>,< pwd > AT+CWJAP? - ssid = ssid, pwd = wifi password
AT+CWLAP list the AP wifi AT+CWLAP
AT+CWQAP quit the AP wifi AT+CWQAP - AT+CWQAP=?
AT+CWSAP set the parameters of AP wifi AT+CWSAP= <ssid>,<pwd>,<chl>, <ecn> AT+ CWSAP? ssid, pwd, chl = channel, ecn = encryption; eg. Connect to a WiFi Access-Point: AT+CWJAP="TEST-AP","12345678"; and then check if you are connected: AT+CWJAP?
AT+CWLIF check join devices' IP wifi AT+CWLIF - -
AT+CIPSTATUS get the connection status TCP/IP AT+CIPSTATUS <id>,<type>,<addr>,<port>,<tetype>= client or server mode
AT+CIPSTART set up TCP or UDP connection TCP/IP 1: single connection (+CIPMUX=0) AT+CIPSTART= <type>,<addr>,<port>; 2: multiple connection (+CIPMUX=1) AT+CIPSTART= <id><type>,<addr>, <port> - AT+CIPSTART=? id = 0-4, type = TCP/UDP, addr = IP address, port= port; eg. Connect to another TCP server, set multiple connection first: AT+CIPMUX=1; connect: AT+CIPSTART=4,"TCP","X1.X2.X3.X4",9999
AT+CIPMODE set data transmission mode TCP/IP AT+CIPMODE=<mode> AT+CIPSEND? 0: non-data mode, 1: data mode
AT+CIPSEND send data TCP/IP 1: single connection(+CIPMUX=0) AT+CIPSEND=<length>; 2: multiple connection (+CIPMUX=1) AT+CIPSEND= <id>,<length> AT+CIPSEND=? eg. send data: AT+CIPSEND=4,15 and then enter the data.
AT+CIPMUX set multiple connections TCP/IP AT+CIPMUX=<mode> AT+CIPMUX? 0 for single connection 1 for multiple connections
AT+CIPSERVER set as server TCP/IP AT+CIPSERVER= <mode>[,<port> ] mode 0 to close server mode, mode 1 to open; port = port; eg. turn on as a TCP server: AT+CIPSERVER=1,8888, check the self server IP address: AT+CIFSR=?
AT+CIPSTO Set the server timeout TPC/IP AT+CIPSTO= AT+CIPSTO?
+IPD received data For Single Connection mode(CIPMUX=0): + IPD, <len>:
For Multi Connection mode(CIPMUX=1): + IPD, <id>, <len>: