-->
Page 1 of 2

ESP8266 and Arduino Interfacing

PostPosted: Fri Mar 11, 2022 6:01 am
by SuomyNonaPatri
I have connected Arduino with ESP8266 with

Arduino pin 2 connected to ESP's Tx Arduino pin 3 connected to ESP's Rx via Voltage Divider Arduino GND connected to ESP's GND Arduino 3v3 connected to ESP's CH_PD

I have powered ESP8266 using 1117 Voltage regulator

When I initially bought ESp8266 it working but now it shows an endless stream of garbage values...

The arduino is programmed with the following code

#include <SoftwareSerial.h>

SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
Serial.begin(9600);
esp8266.begin(9600); // your esp's baud rate might be different
}

void loop()
{
if(esp8266.available()) // check if the esp is sending a message
{
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
Serial.write(c);
}
}



if(Serial.available())
{
// the following delay is required because otherwise the arduino will read the first letter of the command but not the rest
// In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it
// but we want to send everything at the same time.
delay(1000);

String command="";

while(Serial.available()) // read the command character by character
{
// read one character
command+=(char)Serial.read();
}
esp8266.println(command); // send the read omegle shagle character to the esp8266
}
}

Re: ESP8266 and Arduino Interfacing

PostPosted: Sat Mar 12, 2022 7:44 pm
by Inq720
You probably have a great reason. But I'm just curious... why are you connecting an ESP to and Arduino? About the only reason I can think of is the Arduino has a lot of analog pins.

Otherwise, it's kind of like towing a horse buggy with a Porsche.

Re: ESP8266 and Arduino Interfacing

PostPosted: Fri Mar 18, 2022 7:52 am
by QuickFix
SalinaSJames wrote:So.. how do I talk to the damn thing? :')

I suggest you get yourself a NodeMCU or Wemos first (they're almost as cheap as a separate module); once you get the hang of working with a development board like these, you understand how the ESP8266 actually ticks and you could switch to a separate module.

If you still want to talk to a module, you can do so by using an USB - UART convertor at 3.3V levels, not through an Arduino board (please note: don't power an ESP using such a convertor, since they won't be able to produce the necessary current).

Like mentioned: you don't actually need an Arduino to ESP solution, since the ESP is capable of doing everything on its own; the only things different/lacking on the ESP is the higher number of GPIO and analog ports.

Re: ESP8266 and Arduino Interfacing

PostPosted: Fri Mar 18, 2022 8:52 am
by Inq720
First, is this the same person with two accounts (SuomyNonaPatri & SalinaSJames) or two people having the same type of problem?

I'm going to take a WAG that when one said, "preflashed ESP8266" they're using it as the plain, pre-configure device using the AT command set and want to know how to interact with it to JUST supply WiFi for the Arduino. I guess if you really need that many pins (Mega 2560 - 54 digital, 16 Analog) - Robot, 3D Printer, etc then that's a great reason. If that's the case, then I won't be much help... using the AT command might as well be Morse Code communication.

If that's not, maybe they don't know about the ESP Core Library and actually programming the ESP. And... that at 80 MHz will walk off and leave a Mega 2560 in the dust AND also handle the WiFi duties.

The respective O.P.s should let us know which path they're wanting to tackle... or we'd be leading them down a path that won't really help them.