Esp8266: Difference between revisions
From James's Wiki
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
; // wait for serial port to connect. Needed for native USB port only | ; // wait for serial port to connect. Needed for native USB port only | ||
} | } | ||
Serial.println("Startup Complete."); | Serial.println("Startup Complete."); | ||
} | } | ||
void loop() { | void loop() { | ||
// put your main code here, to run repeatedly: | // put your main code here, to run repeatedly: |
Revision as of 07:41, 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 (!Serial) { ; // 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() ); } }