Esp8266: Difference between revisions
From James's Wiki
(Created page with "File:Esp12e-pinout.png") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[File:Esp12e-pinout.png]] | [[File:Esp12e-pinout.png]] | ||
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() ); } | |||
} |
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() ); } }