Arduino Blinker ESP8266 as a penetration module
I wanted to do a few arduino IoT to participate in the competition, but most of them were too difficult, and the editing was quite troublesome, and the level was limited, so I finally saw that blinker on the arduino Chinese developer platform, and finally decided Try to do it.First, I used the wifiduino board, realized the buttons, and a series of basic functions.Later, due to the limitation of too few pins, I decided to use mega2560+ESP8266 as a penetration module, so that more sensors were added.
1. Experiment preparation
1.1 Hardware preparation
If you want to use UNO/MEGA+Blinker+ESP 8266+Blinker+Internet of Things, you need to prepare the following materials
- Arduino UNO/MEGA 2560 microcontroller
- ESP 8266 01S module and its burner (the following is the best one, the cheapest on a certain treasure)
- Dupont Line
1.2 Required software
- Arduino IED 1.8.5 and above (the higher the better)
- After downloading the blinker header file library, paste it into libraries (including blinker routines)
- Download the blinker component expansion package to provide Generic 8266 moudle programming options
- The bilnker app can be downloaded from the mobile web search
- Below is the 2.3 Baidu cloud link self-collection
Link: https://pan.baidu.com/s/1iIMgWuyEoUBQ1nlKJ1Xrzw .
Extraction code: 6uvw
2. Experimental steps
2.1 Burn through components for ESP 8266
- Select Generic ESP 8266 Moudle
2. Select AT firmware file
// blinker AT固件代码
#define BLINKER_AT_MQTT
#include <Blinker.h>
void setup()
{
Blinker.begin();
}
void loop()
{
Blinker.run();
}
- Select serial port upload
Note: Many friends are unsuccessful in burning here, it is recommended to replace the IED with a higher version, or change to a burner
- Configure blinker (you can skip it if you have a basis) After
downloading it, press the + sign in the upper right corner to create a new device and
select arduino
Click WIFI access
Please choose Alibaba Cloud here
Copy your KEY and return to the device.
Click on the loading type example. When we
reach this interface, we will return to the IED to prepare the link.
- Networking ESP8266 module
1. If the programming is successful, open the serial port and power on, it will display BLINKER-WIFI (if not displayed, press the reset button
2. Enter the command AT+BLINKER_WIFI=0, "API key", "wifi name", "wifi password" at the serial port
3. Example: AT+BLINKER_WIFI=0,3f8b2d5b6cf0,ch,66666666
returns a lot of numbers to indicate successful penetration
Open the app and it is displayed online.
Send information to the app through the serial port,
you can see the penetration information
2.2 Interaction with ARDUINO MCU
Okay, do you think this is over? This is just the beginning. We only completed penetration, but BLINKER can't be controlled through the single-chip microcomputer. How to interact with the single-chip microcomputer, I have seen the official website for a long time (do not spray)
- Burn the penetration program of the development board
This is the official code of hello blinker after the change
#define BLINKER_WIFI
#include <Blinker.h>
char auth[] = "********"; //自己的API KEY
char ssid[] = "*****"; //自己的wifi 名
char pswd[] = "************"; //自己的WIFI密码
// 新建组件对象
BlinkerButton Button1("btn-abc");
BlinkerNumber Number1("num-abc");
int counter = 0;
// 按下按键即会执行该函数
void button1_callback(const String & state)
{
BLINKER_LOG("get button state: ", state);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
// 如果未绑定的组件被触发,则会执行其中内容
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
counter++;
Number1.print(counter);
}
void setup()
{
// 初始化串口
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
// 初始化有LED的IO
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
// 初始化blinker
Blinker.begin(auth, ssid, pswd,15,14);
Blinker.attachData(dataRead);
Button1.attach(button1_callback);
}
void loop() {
Blinker.run();
}
The point is this sentence
Blinker.begin(auth, ssid, pswd,15,14); 15 is RX 14 is TX
The last two numbers inside are the serial pin numbers of your MCU to be connected
Note: If I use the Serial3 UNO of mega 2560, the last two numbers are changed to 0,1 (soft serial port is recommended)
- Wiring
Connect the TX RX of the ESP8266 module with the serial port pins you set up in the previous microcontroller (don't forget to connect the serial port in reverse)
After selecting the ESP 8266-01S module to configure the network, unplug the burner, remove the module, connect to the microcontroller, and re-power on will reconnect to the network
- Actual debugging (finally reached the last step)
Click to count
Open the serial port of the microcontroller to see the debugging information
3. Supplemental links
The first one below is the official developer documentation. The
second one is an article by a big guy I learned at the beginning. The
third one is the Ardunio developer community
. The IoT module can learn from the basics of BLINKER.