Please refer to the instruction of the WiFi ESP8266 and use the Arduino IDE to open the sample program (ESP8266WiFiController.ino) to upload the WiFi control firmware for the ESP8266 moudle.
Install Python3, and download the Python scripts to control the robot.
For Python 3.8 and above, the calling syntax is different for the definition of type. This script is compatible with this, but you need to comment and uncomment several corresponding statements in the script according to the version of Python you have installed. For example, the following script supports Python versions below 3.8:
This script can control only one robot alone, or control multiple robots at the same time, which can be realized by modifying the following statement in example.py:
Refer to the instruction of the WiFi ESP8266 to assign the IP address to the ESP8266 module and then insert it into the main board of the robot. After the robot is powered on normally, you can use python to run the script example.py to control the robot wirelessly. You can modify the following script statements (modify the content of the list) according to your actual needs to make the robot perform various actions:
For currently supported skill action commands, please refer to the code file actions.h (in ESP8266WiFiController).
This module uses ESP8266EX's official model ESP-WROOM-02D, 4MB QSPI Flash. The module is certified by FCC in the United States, CE-RED in Europe, TELEC in Japan, and KC in South Korea.
The module is fully opened, you can program it separately. This is not a simple transparent transmission module.
The module includes an automatic download circuit and a communication module. The automatic download circuit refers to the official recommendation to use 2 S8050 transistors to receive the RTS and DTR signals from the CH340C downloader and trigger the download sequence.
Connect to the NyBoard:
Update sketches through USB downloader:
We use the Arduino as the development environment.
Then open the "Board Manager" and enter ESP8266 or 8266 to search for the board support package:
Download the package ESP8266 by ESP8266 Community.
After the board support package downloaded, we select ESP8266 Board (current version: 2.74) -> Generic ESP8266 Module.
Then we set the parameters:
After configuration, we use the Arduino classic "Blink" program to test the ESP8266 development board.
Open the Blink project, configure the development board, plug the module into the communication module debugging interface of the USB downloader, and download the Blink example.
Compared with the Arduino UNO, the compilation time is slightly longer, after Linking, the download progress will be displayed as a percentage:
The "Blink sketch" uses 257KB of flash and 26.8KB of the SRAM.
There're 3 files in the project:
ESP8266WiFiController.ino: Arduino sketch with server core code.
mainpage.h:welcome page (html) in a char array.
actionpage.h:action controller page (html) in a char array.
Please put them in the folder named "ESP8266WiFiController", then open the ino file and download it to the ESP8266 WiFi module.
After the sketch downloader to the WiFi module, we strongly recommend run it with your USB downloader so you can get the serial output in the Arduino serial monitor.
Open your smartphone WiFi scanner and find an access point named "Bittle-AP" that is not encrypted. Connect it.
If your smartphone automatically optimizes your network connection, it will cut the connection of "Bittle-AP" because there is no Internet connection. Your smartphone may connect to the WiFi with an Internet connection or even use your cellular data.
Your smartphone may auto jump to the "WiFiManager" page when connecting to "Bittle-AP".
If not, please open your browser and enter 192.168.4.1 to enter the WiFi connection configuration page manually.
On the WiFiManager page, Bittle's wireless module will automatically search for all nearby WiFi SSIDs and display them. After you click on your own WiFi SSID and enter the password, Bittle will connect to this network first.
Bittle will print out the IP address assigned by DHCP through the serial port after connecting to the WiFi successfully. You can also configure a fixed IP address in Arduino.
Enter the IP address of the WiFi module, now you can control the Bittle through WiFi!
The sample code is a simple web server example, including 2 HTML pages. The two pages are stored in two header files in the form of string constants. The advantage is to avoid calling the client.print function constantly.
Before we start our web server, we should configure the WiFi to connect to your local area network(LAN). We used to enter the WiFi SSID and password in the program, but it is very inconvenient while we need to change the network environment.
We use the WiFi manager library to configure the WiFi information through web.
Create a new web server and configure port 80 (commonly used HTTP server port)
The HTTP response function is to handle the incoming HTTP requests.
The handleMainPage and handleActionPage response 200 (OK) and corresponding web HTML code for your web browser (client).
The HandleAction function is slightly different. This is an HTTP request processing function with parameter passing. When the parameter is "gyro", the serial port of the WiFi module sends out the command ("g", switch IMU), so that our Bittle will execute the command.
So how is this "gyro" parameter generated and passed? Because we sent such an HTTP request with a value to the server:
The server parses the action parameter by the function and resolves that the name is "gyro".
We can directly enter this URL in the browser and execute it with the keyboard. The more common method is to add a link to the "Walk" button on the ActionPage web page. When the gyro button is pressed, the above URL will be sent to the host.
The complete walk button configuration is as follows:
After parsing the "name" parameter, we send the actionpage again.
We bond the handler method with the corresponding URLs.
Compared to the ATMega328P on the NyBoard, there’re more hardware and software resources on the ESP8266, you can do more experiments with it.
Connect your Bittle to IoT platforms with HTTP restful APIs.
MQTT and node-red.
OTA with WiFi.
Make ESP8266 a strong co-processor for NyBoard for motion data fusion.
URL:. Paste it into the URL of the additional development board in the Arduino preferences.
Project URL:
Parameters | Settings |
Builtin Led | 2 |
Upload Speed | 921600(Auto-negotiation during downloading, 115200 is too slow) |
CPU Frequency | 160MHz |
Flash Size | 4MB |
Reset Method | DTR reset |
lwIP variant | V2 Lower memory |
Erase Flash | Only sketch |