The code I used was from online and I tried using it to send data to firebase through web server. But the ouput I get from serial monitor was just "ATE0" which means there's something wrong. Hence, I can't proceed in solving this issue.

I tried several resources online to match my current problem.

I hope someone can help me

Thank you :)

#include <SoftwareSerial.h>;
SoftwareSerial Serial1(10, 11);
#include "DHT.h"
#define Terra "terra1"
#define DHTPIN 2    

#define DHTTYPE DHT22   


//const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2; eyagagana soy

int j=0;
int prev=0;
int pres=0;
String status="";
String buff(64);
String getStr(128);

void setup() {

//  Serial.println(F("Humiture and Soil Moisture Sensors"));

   if (!connectWiFi()) {
    Serial.println("Can not connect to the WiFi.");
    while (true)
      ; // do nothing
  Serial.println("OK, Connected to WiFi.");


void loop() {
  else if(j<0)


  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
//  if (isnan(h) || isnan(t) || isnan(f)) {
//    Serial.println(F("Failed to read from DHT sensor!"));
//    return;
//  }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

//  Serial.print(F("Humidity: "));
//  Serial.print(h);
//  Serial.print(F("%  Temperature: "));
//  Serial.print(t);
//  Serial.print(F("°C "));
//  Serial.print(("Soil Moisture: "));
//  Serial.print(j);
// Serial.println("%");

// connect to server
  if (sendCommand("AT+CIPSTART=\"TCP\",\"https://terraduino.000webhostapp.com\",80")) {
    Serial.println("connected to Cloud");
    // build HTTP request
    getStr = "GET /upload.php?terra=";
    getStr += Terra;
    getStr += "&j=";
    getStr += j;
    getStr += "&t=";
    getStr += t;
    getStr += "&h=";
    getStr += h;
    getStr += " HTTP/1.1\r\n";
    getStr += "Host: https://terraduino.000webhostapp.com\r\n\r\n";
    // open send buffer
    buff = "AT+CIPSEND=";
    buff += getStr.length();
    if (sendCommand(buff.c_str()) && Serial1.find(">")) { // AT firmware is ready to accept data
      // send HTTP request
      // print HTTP response
      if (Serial1.find("+IPD,")) { // response received
        int l = Serial1.parseInt();
        while (l > 0) {
          if (Serial1.available()) {
      } else {
        Serial.println("no response");
    } else {
      Serial.println("send error");
  } else {
    Serial.println("Error connecting");
bool connectWiFi() {
  if (!sendCommand("ATE0")) // echo off
    return false;
  if (!sendCommand("AT+CIPMUX=0")) // set single connection mode
    return false;
  if (!sendCommand("AT+CWMODE=1")) // set STA mode
    return false;

  return sendCommand("AT+CWJAP=\"I Pronounce you Man and Wifi\",\"-PX?*[email protected]\"");
bool sendCommand(const char* cmd) {
  while (true) {
    buff = Serial1.readStringUntil('\n');
    if (buff.length() > 0) {
      if (buff == "OK" || buff == "SEND OK" || buff == "ALREADY CONNECTED")
        return true;
      if (buff == "ERROR" || buff == "FAIL" || buff == "SEND FAIL")
        return false;
  • ESP boards are definitely nothing for beginners. The problem with them is that they might have very different Firmware versions on them. You can for example not be sure what baud rate they are using. So, you have to find out which baud rate the Serial interface uses. You configured 9600 Bit/sec but most of the boards need 115200. Event ESP Gurus do flushing the ESP with a well define firmware: e.g. medium.com/@aallan/… Commented Oct 29, 2019 at 15:20
  • It would be a good idea to also add the complete output of the arduino to the question. The output helps us to follow the program and how it executes. Commented Oct 29, 2019 at 15:23
  • thank you sir, the output was just "ATE0" Commented Oct 29, 2019 at 15:47
  • did you set the baud rate of AT firmware to 9600 baud? (btw, I wrote this version of sendCommand function)
    – Juraj
    Commented Oct 29, 2019 at 17:16
  • not yet sir, awsome! Commented Oct 30, 2019 at 12:54

1 Answer 1


I would say you are trapped in the sendCommand function. You print the cmd (cmd="ATE0") variable to the terminal and then send the command to the ESP over Serial1 = software serial. Serial1 is configured with a baud rate of 9600 (Serial1.begin(9600)) it depends on your ESP but that might be wrong. A common value is 115200 (Serial1.begin(115200)). But because that can vary from board to board, it could also be wrong.

If I'm right and you configured a wrong baud rate, the command can not be understood by the ESP and even the newline after the command might be missing for it.

So the ESP send nothing back and the 'buff.length()' equals to 0. Then the while(true) runs and runs and runs ... .

  • yes, this was the idea. But I can't go back with the AT Commands, I checked all the wires and process done well. output are just some internal information and unknown random symbols printed in serial monitor Commented Oct 30, 2019 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.