So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Secretasianman7
#72777 Hi! Hoping I can get some help. I have a basic understanding of arduinos and arduino code. Nevertheless, I decided to take the plunge with buying myself a few esp8266 -01s's along with some other microelectronics to try and take on a project I've had in the back of my head forever.

Here's whats going on. As of right now, I've got one esp8266 running off of one of these https://www.aliexpress.com/item/OPEN-SM ... 0.0.y300un

I've got code running on the esp so that I can open the serial monitor on the esp and dependent on whether I type a 1 or a 2 into the serial monitor the built-in LED on the esp will either turn on or off. This is working fine. Here's the code

#define LED_BUILTIN 2


void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
Serial.begin(115200);
while (!Serial);
Serial.println("Input 1 to turn LED on and 2 for off");
delay(1000);
}

// the loop function runs over and over again forever
void loop() {
if (Serial.available())
{
int state = Serial.parseInt();
if (state == 1)
{
digitalWrite(LED_BUILTIN, LOW);
Serial.println("LED ON");
}
if (state == 2)
{
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("LED OFF");
}
}
}



However, when I try to plug in that very same ESP into my arduino circuit, pic included, (https://imgur.com/buwdO6m) I get no response from the esp's LED when I type into the nano's serial monitor.

This is the code I have running on the nano

#include <SoftwareSerial.h>
SoftwareSerial ESPserial(3, 2); // RX | TX

void setup()
{
Serial.begin(9600); // communication with the host computer
//while (!Serial) { ; }

// Start the software serial for communication with the ESP8266
ESPserial.begin(9600);

Serial.println("");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
Serial.println("");
}

void loop()
{
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }

// listen for user input and send it to the ESP8266
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}

I've been tearing my hair out all day trying to figure out what's going on, I'm almost positive I've got my wires properly hooked up. I've got an external power supply dropped down to 3.3v supplying the wifi board. apart from that the only things plugged into my esp right now are power, ground, tx, rx, and rst. plugging CH_PD, or in my case, EN into 3.3v on the arduino doesnt seem to help either. Anyways, I'm past my area of understanding with this stuff so I'm hoping someone can help me get sorted and on the right track again.
User avatar
By icons
#72797 I am not a pro but looking at it you got your baut rate mismatched, one says on software serial is 9600 the other on serial monitor is 115200, don't they have to match/be the same? Also I think the connections should be rx on esp to tx on arduino serial and tx esp to rx on nabo serial.
User avatar
By Secretasianman7
#72806
icons wrote:I am not a pro but looking at it you got your baut rate mismatched, one says on software serial is 9600 the other on serial monitor is 115200, don't they have to match/be the same? Also I think the connections should be rx on esp to tx on arduino serial and tx esp to rx on nabo serial.


what you are seeing there, is two different experiments, thats why the baud rate is different per each code. The first code has a baud rate of 115200 because the chip is directly attached to the serial port. however, when you switch to software serial, at least from everything I've gathered so far, you cant do a baud rate higher than 9600 when interfacing through software serial. Thats the fastest it can go.

Regarding your comments on the tx/rx setup, the reason I have it that way is because the software serial tx and rx ports go to their opposites respectively on the esp chip. so software serial rx goes to esp tx and vice versa. Im pretty sure that rx goes to tx and tx to rx, not rx to rx, tx to tx. but i could be wrong. i'm obviously doing SOMETHING wrong because I cant get this setup to work.