Hi,
I am trying to use the ESP-01 as a cheap Wi-Fi shield for my Arduino Mega. For one of my projects, I need to use numerous digital pins and control some signals wirelessly. To do this, I thought to use serial communication between the ESP and the Arduino to give the Arduino some Wi-Fi capabilities.
The ESP works perfectly well and can connect to my Wi-Fi. However, when I try using the software serial in the ESP, it stops working.
Here is the basic test code I have:
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
const char* ssid = "*******7";
const char* pass = "**********t";
SoftwareSerial arduinoSerial(0, 1); // Rx, Tx
void setup() {
Serial.begin(115200);
arduinoSerial.begin(9600);
// Connect to WiFi
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED){
delay(500);
Serial.println("Connecting to Wi-Fi...");
}
Serial.println("Connected to Wi-Fi");
}
void loop() {
arduinoSerial.print(1);
Serial.println("Sent 1");
delay(2000);
arduinoSerial.print(0);
Serial.println("Sent 0");
delay(2000);
}
This code flashes normally onto the ESP, however, when powered, the ESP does nothing. When I remove the software serial lines from this code, eg. arduinoSerial.begin(9600)
, arduinoSerial.print(1)
, etc, the code functions fine.
Is there something I am missing or doing incorrectly?
Any suggestions would be appreciated.
Thanks.