Home › Forums › Mayfly Data Logger › ESP8266 › Reply To: ESP8266
Sara, thank you for your response. I’m glad to hear it is possible. Here’s what I’ve got thus far.
Mayfly <—-> ESP8266 ESP-01
Rx1 <——-> Tx
Tx1 <——-> Rx
Gnd <——-> Gnd
Sw3 <——-> VCC & CH_PD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
// https://allaboutee.com/2014/12/27/esp8266-arduino-code-and-circuit/ void setup() { Serial.begin(9600); Serial1.begin(115200); // your esp's baud rate might be different pinMode(22, OUTPUT); // TURN SW_3 TO 3.3V https://www.envirodiy.org/topic/hcsr04-sw5/ digitalWrite(22, HIGH); // TURN SW_3 TO 3.3V https://www.envirodiy.org/topic/hcsr04-sw5/ //Serial.print("Here we go..."); } void loop() { //Serial.println("hello"); if(Serial1.available()) // check if the esp is sending a message { while(Serial1.available()) { // The esp has data so display its output to the serial window char c = Serial1.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. //Serial.println("Serial.available"); delay(1000); String command=""; while(Serial.available()) // read the command character by character { // read one character command+=(char)Serial.read(); } Serial.print("Command sent to ESP= "); Serial.println(command); Serial1.println(command); // send the read character to the esp8266 } } |
I attached a screenshot of the Serial Monitor with the results I get back from the ESP when I send AT commands to it. Do I have a baud rate issue?
To test if the ESP was working, I connected it to an Arduino UNO via an Aideepen Adapter Module. The ESP worked and the responses were as they should be.
I’ll continue to play around with my setup and see if I can figure it out. Any insight would be greatly appreciated.
Update:
The second image attached is the Serial Monitor when I changed the code to Serial1.begin(74880);