GET HTTP request with ESP01

Hi, i'm new to using ESP01 module and my aim is quite simple, opening a HTTP url whenever a button is pressed, but i cant seem to get it to work

This is the code i have

#include <SoftwareSerial.h>

SoftwareSerial espSerial(2, 3);  // RX, TX

void setup() {
  pinMode(7, INPUT);
  Serial.begin(9600); 
  espSerial.begin(9600);  

  delay(1000);

  espSerial.println("AT+RST");
  delay(2000);
  espSerial.println("AT+CWJAP=\"WIFI\",\"PASSWORD\"");
  delay(2000);
  Serial.println("Upload complete");
}

void loop() {
  if(digitalRead(7) == HIGH) {
    Serial.println("Initiated");
    nya();
  }
  while (espSerial.available()) {
    Serial.write(espSerial.read());
  }
}

void nya() {
  espSerial.println("AT+CIPSTART=\"TCP\",\"EXAMPLE.COM\",80");
  delay(2000);

  espSerial.println("AT+CIPSEND=128");
  delay(1000);
  espSerial.println("GET EXAMPLE_LINK HTTP/1.1");
  espSerial.println("Host: EXAMPLE.COM");
  espSerial.println("Connection: close");
  delay(2000);

  espSerial.println("AT+CIPCLOSE");
  espSerial.println("Nya!");
  delay(2000);
}

However when i execute it, this message pops up in the serial monitor:

initiated

AT+CIPSTART="TCP","EXAMPLE.COM",80

CONNECT

OK

AT+CI

i tried to debug on my own but cant seem to get it to open the http

I would suggest looking at programming the esp8266 in native mode rather than using the painful AT interface. The board files for the esp8266 can be added to the IDE with example sketches for various functions.

The hardware side of programming can be as simple as a classic Arduino(used as a USB to serial interface), breadboard, some resistors and a couple of switches. It is better to spend a couple of bucks on a dedicated programmer or at least a USB serial adapter that supports 3.3v.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.