Arduino Nano + ESP-01 Module


1.0.7 11.03.2016
Add a watchdog which resets the WLAN module when it hangs.

1.0.6 10.03.2016
Add system clock initialization code for Xmega controllers.

1.0.5 09.03.2016
Improved timing and source code structure.

1.0.4 08.03.2016
The correct line-feed format for the WLAN module is now auto-detected. Debugging via SERIAL_ECHO option is now disabled by default.

1.0.3 07.03.2016
Reduced RAM usage a lot and improved stability.

1.0.2 05.03.2016
Add hardware layouts for Arduino Uno, Crumb328, Crumb644, Crumb128 and Crumb2561.

1.0.1 05.03.2016
AT and I/O commands can now be executed on both WLAN and USB.

1.0.0 03.03.2016
First release

Start page   Deutsche Fassung dieser Seite

I/O Interface Modules for WLAN

Remote control your self-made electronic devices via WLAN by using an AVR microcontroller board plus a WLAN module. This is a great solution since recent computers don't have any traditional parallel port anymore. You get 16 to 82 controllable Pins depending on the microcontroller type. And you can have even more with the help of some cheap shift registers.

Simple text commands provide access to the I/O ports, so you don't need any special driver or library. It works out of the box with almost any programming language and any operating system, for example PC, Samrtphones, Tablets, Raspberry Pi, and so on.

The C Compiler for the microcontroller is free availabe for Windows (e.g. GNU Toolchain), Linux (avr-gcc) and Mac OS. The example app "ioModule" for PC and smartphones can be compiled with Qt Creator.

Download source code and schematics, compiled binaries (hex files).

How it works

After one initial setup of the network parameters, connect to the wireless device on port 23. I prefer the Netcat (nc) program for testing. Send some text commands and receive the answers.

For example, the following command sets the pin PC3 to high level:

Send: oPC3,1
Response: Ok

And this command queries port D in hexadecimal format:

Send: iPD
Response: PD=60

You will find the whole command set below. You can execute about 4 commands per second.

Circuit Diagram

The Crumb644 module does not have the interal 1k series resistor between USB-UART Tx and AVR Rx. The manual correction is difficult because of the small parts.

I noticed that fake Arduino Nano with CH340 chip have often problems to receive data from the USB interface. You may work around this design error by removing the "Rx" LED.

The original Arduino Boards are always sold with a Bootloader. Also Crumb modules provide that as an optional feature.


Test with Netcat:

The example app "ioModule" controls two LEDs:

Command Set

Digital I/O

You control the module with four basic commands, which are d, p, o and i.

These commands can be used on a single I/O line (PB7), a port (PB) or all ports together by a single command:

PB7 and PB are examples, all ports are accessible in the same way. When accessing all ports together, the size of the hexadecimal number depends on the size of the AVR, referring to the ports: DDCCBBAA or HHGGFFEEDDCCBBAA.

The commands for single pins support characters as an alternative to 0 and 1:

The commands d, p and o respond always with "Ok". The i command responds this way:

Analog Inputs

The available references depend on the capabilities of the Mikrocontroller:

Example for the r command:

The a command expects the channel number of the analog input, for example:

Input Extension

A shift register may be used to enhance the number of inputs. I call these additional inputs "Port X". They can be read using the i command:

The length of the hexadecimal number depends on the size of the shift register (8-32 bits).

Output Extension

The number of outputs can be enhanced with a shift register. I call these additional outputs "Port Y". The o command writes to that port:

Again, the length of the hexadecimal number depends on the size of the shift register (8-32 bits). The current status of port Y can be read out by the command i.

The Commands d and p are not available on the port extensions!

Special Commands

The ATZ command performs a hardware reset of the WLAN module.

In addition, you may execute any AT command that the WLAN module understands (except AT+CIPSEND). However, you can only receive the first line of each response. The following command sequence configures the WLAN connection of the ESP module: