Blinker arduino series single-chip microcomputer + ESP 8266 as penetration module IoT

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

  1. Arduino UNO/MEGA 2560 microcontroller
  2. ESP 8266 01S module and its burner (the following is the best one, the cheapest on a certain treasure)
    8266 module
  3. Dupont Line

1.2 Required software

  1. Arduino IED 1.8.5 and above (the higher the better)
  2. After downloading the blinker header file library, paste it into libraries (including blinker routines)
  3. Download the blinker component expansion package to provide Generic 8266 moudle programming options
  4. The bilnker app can be downloaded from the mobile web search
  5. 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

  1. Select Generic ESP 8266 Moudle
    Choose a development board
    2. Select AT firmware file
    Select path
// blinker AT固件代码
#define BLINKER_AT_MQTT

#include <Blinker.h>

void setup()
{
    Blinker.begin();
}

void loop()
{
    Blinker.run();
}
  1. Select serial port upload

Serial 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

  1. Configure blinker (you can skip it if you have a basis) After
    Insert picture description here
    downloading it, press the + sign in the upper right corner to create a new device and
    Insert picture description here
    select arduino

Insert picture description here
Click WIFI access

Please choose Alibaba Cloud hereInsert picture description here
Copy your KEY and return to the device.
Insert picture description here
Click on the loading type example. When we
Insert picture description here
reach this interface, we will return to the IED to prepare the link.

  1. Networking ESP8266 module
    Insert picture description here

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

Insert picture description here
Open the app and it is displayed online.
Insert picture description here
Send information to the app through the serial port,
Insert picture description here
you can see the penetration information
Insert picture description here

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)

  1. 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)

  1. 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
    Insert picture description here
  2. Actual debugging (finally reached the last step)

Click to count
Insert picture description here
Open the serial port of the microcontroller to see the debugging information
Insert picture description here

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.

  1. Blinker developer documentation .

  2. https://blog.csdn.net/crossni/article/details/104627768?utm_source=app.

  3. https://www.arduino.cn/.

Guess you like

Origin blog.csdn.net/chrnhao/article/details/106021103