Reputation: 1813
I am trying to connect a ESP8266-01 that I had for a while to my Arduino UNO r3. Using the ESP8266 is new to me. I used this site as a reference.
My connection as follows:
Arduino -> ESP8266
TX -> RX
RX -> TX
5V -> Resistor -> VCC, CH_PD
GND -> GND
I am trying to do a quick test to connect to the ESP8266
void setup() {
// put your setup code here, to run once:
Serial2.begin(9600);
Serial.begin(115200);
}
void loop() {
while(Serial2.available()) Serial.write(Serial2.read());
while(Serial.available()) Serial2.write(Serial.read());
}
I get this error:
Arduino: 1.6.9 (Windows 7), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None"
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -hardware "C:\Users\Lappy\AppData\Local\Arduino15\packages" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -tools "C:\Users\Lappy\AppData\Local\Arduino15\packages" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\Lappy\Documents\Arduino\libraries" -fqbn=esp8266:esp8266:generic:CpuFrequency=80,FlashFreq=40,FlashMode=dio,UploadSpeed=115200,FlashSize=512K64,ResetMethod=ck,Debug=Disabled,DebugLevel=None____ -vid-pid=0X2341_0X0043 -ide-version=10609 -build-path "C:\Users\Lappy\AppData\Local\Temp\build020cff5e75da0458cfe8ecc88a163002.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Lappy\Box Sync\Arduino\wifi_door_opener\wifi_door_opener.ino"
Board generic (platform esp8266, package esp8266) is unknown
Error compiling for board Generic ESP8266 Module.
Upvotes: 1
Views: 5410
Reputation: 162
You use Serial2.begin an Serial.begin but the Arduino Uno R3 has only one UART (digital pins 0 & 1)! In contrast, the link you are referring to works with the Arduino Mega which has 4 UARTs. So in this case you need to define 2 pins as SoftwareSerial and include the library like this:
#include <SoftwareSerial.h>
SoftwareSerial ESP8266(2,3)
void setup(){
do something;
}
This makes digital pin 2 of your Arduino as another Rx pin and digital pin 3 als another Tx pin.
And (as mentioned from cranphin already) you need to check your wirings. The Arduino Uno works with 5V but the ESP8266 works with 3.3V (3.0V - 3.6V as you can see here under documentation in the datasheet)!
So what you need to do:
You can use an external 3.3V power supply for your ESP8266 or you can take the 5V pin from your Arduino Uno and convert it to 3.3V (voltage divider, LD1117V33, ...). Some people connect the ESP8266 directly to the 3.3V pin of the Arduino but in my case it did not work. But you can give it a try...
And you need to consider that the Arduino sends via the UART pins on 5V. So make sure you add an voltage divider (e.g. 4.7kohm and 10kohm) in the recieving line of the ESP8266. The ESP8266 sends on his Tx line with 3.3V which is recognised by the Arduino as a logical HIGH. So theres no need of protection.
Here is my solution of wiring:
AND:
You need to choose the right settings in the Arduino IDE. Your error looks like you chose the
Generic ESP8266 Modul
But you need to select your Arduino Uno.
So go to Tools
--> Board
--> Arduino/Genuino Uno
and make sure to use the right port.
Interesting information:
It is possible to upload a sketch directly to the ESP8266 but therefor you need more wirings and it's not that easy ..
Upvotes: 0
Reputation: 1611
Another issue, but not the one you've run into (YET), is that your wiring says:
5V -> Resistor -> VCC, CH_PD
This really freaks me out! :)
It might be ok, you mention a site which I can't check right now, but it seems your trying to lower the voltage from 5v to 3.3v by using a single resistor. That seems Very unreliable for a device which will draw a highly variable load (meaning the ESP might see anything from 5v to well under 3.3v).
Oh, an very similary, this:
TX -> RX
RX -> TX
Seems like a bad idea too, I assume the UNO data lines are 5v? ESP expects 3.3v, high chance of frying it :)
Upvotes: 1