0

I am trying to create a server with a simple webpage using the ESP01s module. My pin connections are as follows:

ESP TX to Arduino Uno Tx pin
ESP RX to Arduino Uno Rx pin
ESP VCC to Uno 3.3V pin
ESP GND to Uno GND
ESP EN  to Uno 3.3V through 10K resistor

I am using the Arduino IDE and serial to USB cable, when I run a blank program I can send AT commands to the ESP module with no issues.

However when I try to run a script to build and deploy the simple webpage, I either get one of two messages in the IDE serial monitor or nothing:

  1. Unreadable characters - jibberish
  2. Boot instructions
load 0x40100000, len 27728, room 16 
tail 0
chksum 0x2a
load 0x3ffe8000, len 2124, room 8 
tail 4
chksum 0x07
load 0x3ffe8850, len 9276, room 4 
tail 8
chksum 0xba
csum 0xba
  1. No output to serial monitor even though code uploads

This is my code:

#include <SoftwareSerial.h>
SoftwareSerial esp8266(0,1); // rx, tx;
#define serialCommunicationSpeed 115200
#define DEBUG true

void setup()

{
  Serial.begin(serialCommunicationSpeed);
  esp8266.begin(serialCommunicationSpeed);
  InitWifiModule();
}

void loop() {

  if (esp8266.available()) {
    if (esp8266.find("+IPD,")) {
      delay(1000);

      int connectionId = esp8266.read() - 48;
      String webpage = "<h1>Capstone Group 45: SolarFi</h1>";
      String cipSend = "AT+CIPSEND=";
      cipSend += connectionId;
      cipSend += ",";
      cipSend += webpage.length();
      cipSend += "\r\n";

      sendData(cipSend, 1000, DEBUG);
      sendData(webpage, 1000, DEBUG);

      String closeCommand = "AT+CIPCLOSE=";
      closeCommand += connectionId;  // append connection id
      closeCommand += "\r\n";
      sendData(closeCommand, 3000, DEBUG);
    }
  }
}

String sendData(String command, const int timeout, boolean debug) {
  String response = "";
  esp8266.print(command);
  long int time = millis();
  while ((time + timeout) > millis()) {
    while (esp8266.available()) {
      char c = esp8266.read();
      response += c;
    }
  }
  if (debug) {
    Serial.print(response);
  }
  return response;
}

void InitWifiModule() {
  sendData("AT+RST\r\n", 2000, DEBUG);
  sendData("AT+CWJAP=\"USERNAME\",\"PASSWORD\"\r\n", 2000, DEBUG);
  delay(3000);
  sendData("AT+CWMODE=1\r\n", 1500, DEBUG);
  delay(1500);
  sendData("AT+CIFSR\r\n", 1500, DEBUG);
  delay(1500);
  sendData("AT+CIPMUX=1\r\n", 1500, DEBUG);
  delay(1500);
  sendData("AT+CIPSERVER=1,80\r\n", 1500, DEBUG);
}
hcheung
  • 3,377
  • 3
  • 11
  • 23
  • Swap your first 2 connections; `ESP TX` connects to `Arduino RX`, and ESP RX to Arduino Tx – chrisbyte Feb 02 '23 at 01:43
  • 1
    1) ESP Tx --> Uno Rx, and ESP Rx --> Uno Tx. 2) Arduino Uno 3.3V may not be able to supply the current required by ESP01. 3) Arduino SoftwareSerial library may not reliable at speed of 115200bps, use lower speed for communicating using SoftwareSerial. 4) Pin 0, 1 is used by Serial for your Serial Monitor, you need to use other pins for your SoftwareSerial. – hcheung Feb 02 '23 at 01:57
  • [AT+CIPSEND documentation](https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/TCP-IP_AT_Commands.html#at-cipsend-send-data-in-the-normal-transmission-mode-or-wi-fi-passthrough-mode). – hlovdal Feb 02 '23 at 23:24
  • 1
    One fundamental problem is that you must [**READ and PARSE**](https://stackoverflow.com/a/20730958/23118) responses you receive back from the modem when you sent an AT command line (which should be terminated with [just `\r`, not `\r\n`](https://stackoverflow.com/a/16994338/23118)). And specifically for CIPSEND it behaves similar to AT+CMGS where you [**MUST wait for the ready prompt**](https://stackoverflow.com/a/15591673/23118) before sending the payload. – hlovdal Feb 02 '23 at 23:28

0 Answers0