This repository has been archived by the owner on May 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test program to verify an ESP8266 connected to an Uno is sending and receiving commands
- Loading branch information
1 parent
0fd1d64
commit 06aa5d0
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Basic serial communication with ESP8266 | ||
// Uses serial monitor for communication with ESP8266 | ||
// | ||
// Pins | ||
// Arduino pin 2 (RX) to ESP8266 TX | ||
// Arduino pin 3 (TX) to ESP8266 RX | ||
// Connect GND from the Arduino UNO to GND on the ESP8266 | ||
// Pull ESP8266 CH_PD (Also called EN) HIGH (3.3V) | ||
// | ||
// When a command is entered in to the serial monitor on the computer | ||
// the Arduino will relay it to the ESP8266 | ||
// | ||
|
||
#include <SoftwareSerial.h> | ||
SoftwareSerial ESPserial(2, 3); // RX | TX Put your preferred pins here | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); // communication with the host computer | ||
//while (!Serial) { ; } | ||
|
||
// Start the software serial for communication with the ESP8266 | ||
ESPserial.begin(9600); | ||
|
||
Serial.println(""); | ||
Serial.println("Remember to to set Both NL & CR in the serial monitor."); | ||
Serial.println("Ready"); | ||
Serial.println(""); | ||
} | ||
|
||
void loop() | ||
{ | ||
// listen for communication from the ESP8266 and then write it to the serial monitor | ||
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); } | ||
|
||
// listen for user input and send it to the ESP8266 | ||
if ( Serial.available() ) { ESPserial.write( Serial.read() ); } | ||
} |