Thư viện SoftwareSerial cho ESP8266

Thư viện SoftwareSerial cho ESP8266

Tại sao tạo ra thư viện SoftwareSerial cho ESP8266?

Trong một số trường hợp, chúng ta cần dùng nhiều hơn một cổng Serial trong board Arduino. Arduino Mega 2560 có 4 cổng Serial bao gồm cổng lập trình. Trong trường Arduino là Nano có một cổng lập trình đơn và kết là người ta tạo ra thư viện SoftwareSerial. Do có sự không tương thích của các chức năng nhất định, SoftwareSerial cho Arduino không hoạt động trên ESP8266.

Download thư viện EspSoftwareSerial của Plerup

SoftwareSerial cho ESP8266

Bài viết các bạn có thể tham khảo:

Lưu ý

Trong trương hợp các thư viện tạo uart trong code phải được xem xét ở tốc độ cao thì có thể xảy ra lỗi bit do chúng sử dụng ngắt và vi điều khiển của bạn xử lý nhiều tác vụ cùng một lúc. Nên cấu hình tại 9600 bauds, nó có tốc độ tương đối thấp nhưng nó an toàn.

Chú ý: Nếu phần mềm của bạn đang sử dụng thư viện SoftwareSerial cho Arduino, bạn nên tắt nó trước khi cài đặt thư viện SoftwareSerial cho ESP8266.

Code mẫu Arduino 


#include SoftwareSerial mySerial(13, 15, false, 256);
//Mas informacion http://pdacontroles.com/
// More info http://pdacontrolen.com/
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Connect! - Conexion ");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Connect! - Conexion SOFTWARESERIAL");
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}

Tham khảo: pdacontrolen.com

Viết một bình luận

This site uses Akismet to reduce spam. Learn how your comment data is processed.