0

This question already has an answer here:

I bought an Arduino Mega 2650 alongside a couple of ESP8266 chips hoping to make a wireless project take off.

Using the basic serial passthrough code

void setup() {
    Serial.begin(9600);
    Serial1.begin(115200);
    Serial.write("Starting");
}

void loop() {
    if (Serial.available()) {      // If anything comes in Serial (USB),
       Serial1.write(Serial.read());   // read it and send it out Serial1 (pins 0 & 1)
    }

    if (Serial1.available()) {     // If anything comes in Serial1 (pins 0 & 1)
       Serial.write(Serial1.read());   // read it and send it out Serial (USB)
    }
}

updated to use a 115200 baud rate which it seems my version of the 8266 is programmed to use, I encounter this problem when trying to issue it commands:

Starting
AT

ERROR

Looking around I found that this could be caused by the chip not getting enough power. So I hooked it up to a small power breakout board breakout board with a small 12 power supply I used to have connected to something else. After doing that all it does is spit out question marks even when I dont send anything. Weird part is the TX pin on the arduino thats going crazy? As if I am sending it to myself without a prompt from the ESP board. This only happens when I'm connected to that breakout supply.

nothing

Other oddity: If I have all my wires except for VCC/CH_PD connected everything is fine, but the second I connect them to that power supply everything goes crazy and my TX pin starts flashing up a storm (can it be a voltage issue that also transfers to my Arduino board as well?)

marked as duplicate by Juraj, Glorfindel, MatsK, Dmitry Grigoryev, VE7JRO Aug 22 at 21:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • set Both NL & CR line ending in one of the Serial Monitor comboboxes – Juraj Aug 4 at 19:16
  • Many questions are open here: Are you sure the baud rate of the ESP8266 is 115200? Show us the code or firmware running on it please? Where are the voltage divider resistors to protect the ESP8266 receiving 5V from the Arduino Mega's UART TX line? What does is show when you read the ESP8266 serial to 74880, which is the baud rate of the first-stage bootloader? – Maximilian Gerhardt Aug 4 at 19:23
  • You are also making the mistake of reading from serial at 115200 baud and sending it to the other at a much lower 9600 baud. When the ESP8266 will send a stream of data and you write it byte-wise to the 9600 serial, it takes too much time for writing it, and you will loose incoming data. You must set the serial you're outputting to at least as high or higher than its input. – Maximilian Gerhardt Aug 4 at 19:25
  • @MaximilianGerhardt From power supply to VCC and from Arduino TX to ESP RX I have a 1/2kohm voltage divider to turn 5v -> ~3.3v. I've tried every baud rate now, and the only one that gave me anything other than question marks was 115200. I havent touched the code or firmware, I cant even establish a serial connection to start looking into that. – Xander May Aug 4 at 21:04
  • 1
    Was using the wrong commands, please write an answer and I will mark it as correct :) – Xander May Aug 5 at 20:24