硬件准备:
1:USB转TTL下载器一个(图1);
2:ESP8266 01S 模块一个,由安信可公司开发(图2);
软件环境:Arduino IDE环境。
软件开发环境很重要,我们需要用到很多SDK。我们暂时做不到对每一个设备的驱动都很了解,但是有了SDK,我们可以对模块进行二次开发等工作。完成更高一级的业务流程。
需要加载esp8266库文件(图5),并在文件->首选项(图4)中添加如下地址,用来下载esp8266的arduino库文件:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
到这里我们的基础环境就编辑好了。
下面我们写一段简单的代码:
这段代码有程序的初始化,有程序的运行过程,两段。
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
Serial.print("connecting to ");
Serial.println();
Serial.print(Serial);
Serial.println();
if(!Serial) {
// wait for serial port to connect. Needed for native USB
Serial.print("Serial isnot connected 串口还没有连接上了");
}
else{
Serial.print("Serial connected串口已经连接上");
}
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is active low on the ESP-01)
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000);
}
学无止境,记录点滴的开发经验。转行,兴趣都不容易,欢迎喜欢开发,喜欢DIY的朋友。