Back in December I had ordered and received an Olimex MOD-WIFI-ESP8266-DEV. I posted some overview and setup information.
- It Worked for Me - Olimex MOD-WIFI-ESP8266-DEV
- Olimex MOD-WIFI-ESP8266-DEV - Hardware Setup
- Olimex MOD-WIFI-ESP8266-DEV - Software Setup
Now I have developed some examples that demonstrate native programming of the ESP8266 in c. The examples were built on Windows using Cygwin64 and the Unofficial Development Kit for Expressif ESP8266.
The examples contain a good bit of documentation in the hopes that they will help other people with their projects.
The basic flow of an ESP8266 program using the Espressif SDK is an event / callback model. The user defines a set of callbacks in user_init.c. The callbacks are triggered when events such as a timer also setup in user_init.c expires.
Another example is a callback that is triggered when a connection is made to the ESP8266 by a client. This callback can take action based on the connection and may in turn setup additional callbacks.
The example code is on GitHub at digitalhack / dhESP8266.
Hello Digitalhack Example
The first example is a take on the standard helloworld. I demonstrates use of the user_init.c function for setting up the program, a timer and timer callback function ands printing output to UART0 and UART1.
UART0 is a full UART with both TX and RX that is used to load your code to the ESP8266. UART1 only has a TX signal and is used for debug messages.
Screen capture from Cygwin of make and flashing the code to the esp8266.
UART0 Output from Example
UART1 Output from Example
Basic Connect Example
This example shows how to setup the ESP8266 to connect to a wireless access point. The ssid and password for the wireless network are in user_config.h in the examples include file.
UART1 Output from Example
Once you see the ip address the EXP8266 has acquired on the debug line (UART1) you should be able to ping the ip address and get a response.
Simple Server Example
This example shows how to setup a very simple server. When a user telnets to the ESP8266 they are prompted for a name. Once this is entered it is echoed name back to the user before disconnecting. It demonstrates the callbacks necessary to for TCP communication.
UART1 Output from Example
Cygwin screen capture of a session.
The example code is on GitHub at digitalhack / dhESP8266.
1 comment:
In ssRecvCb(), there is no guarantee that *data is a zer-terminated "string".
Post a Comment