Thursday, April 25, 2019

Arduino Uno + ESP8266-05 Basic code for setting ESP-05 over Arduino IDE console

/*
 * Uses Arduino Due to redirect terminal commands to the ESP8266
 * USB cable connected to PROGRAMMING port of Due
 * ESP8266 connected to UART 1 of Due
 * 
 * http://startingelectronics.org/articles/ESP8266-testing/
 * 
 * Date: 5 December 2016    Author: W. Smith
 */
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(3, 2); // RX | TX

void setup() {
  Serial.begin(74880);   // USB serial port of Due (PROGRAMMING)
  ESPserial.begin(74880);  // ESP8266 on Serial Port 1 of Due (UART 1)
}

char rx_byte = 0;

void loop() {
  // send terminal byte to ESP8266
  if (Serial.available() > 0) {
    rx_byte = Serial.read();
    ESPserial.print(rx_byte);
  }
  // send ESP8266 byte to terminal
  if (ESPserial.available() > 0) {
    rx_byte = ESPserial.read();
    Serial.print(rx_byte);
  }
}

No comments:

Post a Comment