Esp8266: Difference between revisions
From James's Wiki
No edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
} | } | ||
Serial1.begin(9600); | Serial1.begin(9600); | ||
while (! | while (!Serial1) { | ||
; // wait for serial port to connect. Needed for native USB port only | ; // wait for serial port to connect. Needed for native USB port only | ||
} | } | ||
Latest revision as of 07:46, 7 October 2018
here is the code to forward data from one serial port to another on a arduino mega to communicate with the esp8266
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial1.begin(9600);
while (!Serial1) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Startup Complete.");
}
void loop() {
// put your main code here, to run repeatedly:
if ( Serial1.available() ) { Serial.write( Serial1.read() ); }
if ( Serial.available() ) { Serial1.write( Serial.read() ); }
}