I am isolating the ATMega328P from the Arduino Uno. I have used it for many other projects, so it does work as intended. Also, I have used my ESP8266-01 for other projects and works great (including serial communication).
I am trying to get the ESP8266-01 to make the ATMega328P pin 13 blink an LED. That is all.
When the ESP8266 is hooked to the TX/RX of the arduino board, the program works exactly as intended. I hook it up the exact same way to the ATMega328P and it doesn't work.
I am using baud rate of 9600 for the communication and using a 16MHz crystal for the ATMega328P.
simulate this circuit – Schematic created using CircuitLab
The controller is getting 3.3v from the supply as well. And pin 13 is supposed to turn on/off depending on the serial value. Below is the code for the ESP8266:
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(9600);
}
void loop() {
delay(10000);
Serial.write("LED ON");
delay(10000);
Serial.write("LED OFF");
}
And below is the code for the ATMega328P:
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3);
void setup()
{
Serial.begin(9600);
esp8266.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
if(esp8266.available())
{
String command = "";
while(esp8266.available())
{
command += (char)esp8266.read();
}
if(command == "LED ON") {
digitalWrite(13, HIGH);
}
if(command == "LED OFF") {
digitalWrite(13, LOW);
}
}
delay(500);
}
As stated, they work great separately, but when I try serial communication with them together, it doesn't work.
P.S. I usually set my ESP8266 baud rate to 115200, but the ATMega328P, I believe, needs to run at 9600 because of the 16MHz clock frequency. Not sure about this part, though.
EDIT: