st-anything/lib/WiFiEsp/test/EspDebug/EspDebug.ino
Gašper Dobrovoljc ec125f27db
IP Configuration
2023-03-11 15:11:03 +01:00

49 lines
1.0 KiB
C++

// EspDebug - Test sketch for ESP8266 module
#include "Arduino.h"
// Emulate Serial1 on pins 7/6 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
void setup()
{
Serial.begin(115200); // serial port used for debugging
Serial1.begin(9600); // your ESP's baud rate might be different
}
void loop()
{
if(Serial1.available()) // check if the ESP is sending a message
{
while(Serial1.available())
{
int c = Serial1.read(); // read the next character
Serial.write((char)c); // writes data to the serial monitor
}
}
if(Serial.available())
{
// wait to let all the input command in the serial buffer
delay(10);
// read the input command in a string
String cmd = "";
while(Serial.available())
{
cmd += (char)Serial.read();
}
// print the command and send it to the ESP
Serial.println();
Serial.print(">>>> ");
Serial.println(cmd);
// send the read character to the ESP
Serial1.print(cmd);
}
}