Iam trying to set up the arduino uno
with the wifi module ESP8266
. I use this schematic setup:
I have followed this tutorial: Tutorial ESP8266
Thereby I removed the Mega328P Chip
like it says above, I can communicate trough my terminal in the arduino IDE
with the ESP-module
but when I want to upload an simple test file like this:
#include <SoftwareSerial.h>
SoftwareSerial ESP8266(0, 1); // RX = 8 en TX = 9
boolean FAIL_8266 = false;
void setup() {
// put your setup code here, to run once:
do {
ESP8266.begin(115200); // start communicatie met esp8266
//Wait Serial Monitor to start
while (!Serial);
ESP8266.print("AT\r\n");
delay(500);
if (ESP8266.find("OK")){
ESP8266.print("ready");
}
} while (FAIL_8266);
}
void loop() {
// put your main code here, to run repeatedly:
}
Than it keeps throwing me this error: avrdude: stk500_getsync() attempt x of x: not in sync: resp=0x20
is it because I removed the Mega328P Chip
?
Thereby I've tried the test code from the tutorial here is an link to the code: LINK.
There it keeps saying that Serial2 was not declared in scope
I'll hope someone can help me out on this one and run an simple test script to communicate with the ESP8266 WIFI Module
2 Answers 2
You must have your microcontroller in place if you are uploading code to it.
You can talk to ESP8266 via serial monitor because you are connected directly to the pins of your USB-UART bridge.
Place your uC back, change this line of code:
SoftwareSerial ESP8266(0, 1);
to this one:
SoftwareSerial ESP8266(8, 9);
and change your wires accordingly(what was on pin 0, now connect to pin 8, pin 1 to pin 9). Now your Atmega can talk to ESP8266 after you upload the code.
btw. "Serial2" is Serial port for more advance Arduino boards, it won't work on Atmega328 based board.
-
I did put the chip back and switched the 0,1 pins to 8 and 9 but when I run the code it doesn't print ready..Sireini– Sireini2016年11月04日 17:15:50 +00:00Commented Nov 4, 2016 at 17:15
-
@Beginnerprogrammer you are printing
ready
back to the ESP8266 not to the PC.gre_gor– gre_gor2016年11月04日 20:06:37 +00:00Commented Nov 4, 2016 at 20:06 -
No, ATmega328 has to be either removed or held under reset and
TX to TX
&RX to RX
is OK. See my comment under the question.Chupo_cro– Chupo_cro2016年12月05日 21:25:20 +00:00Commented Dec 5, 2016 at 21:25
The first, most obvious issue (besides needing the MCU on the Arduino board!) is that you need to cross-connect the RX and TX lines between the two boards. You have both RXes connected together, and both TXes connected together. The ESP's RX has to listen to the Arduino's TX, and vice-versa.
An easy way to remember which ESP pins are RX and TX is that the pin nearest the free ends of the antenna is the RX pin; the TX pin is diagonally opposite it.
A second, potential problem, is that the ESP board may draw more power than the Arduino's 3.3v regulator can provide. If it is making brief and not too frequent transmissions, you may get away with it, but the ESP can easily out-draw the regulator and it's 3.3v supply will sag.
-
That is not the case,
TX to TX
&RX to RX
in this case is OK. See my comment under the question.Chupo_cro– Chupo_cro2016年12月05日 21:26:18 +00:00Commented Dec 5, 2016 at 21:26
Explore related questions
See similar questions with these tags.
USB --> RS232 IC
. In that case ATmega328 has to be either removed or held under reset and the connection between Arduino board and ESP8266 must beTX to TX
andRX to RX
. Se my detailed explanation here.