Chat freely about anything...

User avatar
By Ian Phill
#41464 Hello boys. I need to sent some AT command to ESP8266 from the module Arduino "https://github.com/esp8266/arduino", for example

AT+CIPSTART="TCP","x",80\r\n
AT+CIPSEND=x\r\n
GET ....

In many examples i see that some people use "Serial", but I don't know how use it. Could you help me. Please

This is my code
#include <ESP8266WiFi.h>

const char* ssid = "";
const char* pass = "";

WiFiClient client;

void setup() {
//start conection
Serial.begin(115200);
Serial.println("Conecting to: ");
Serial.println(ssid);
WiFi.begin(ssid, pass);

while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

Serial.println("Conecting to WiFi Net");
Serial.print("The IP is");
Serial.println(WiFi.localIP());
}

void loop() {
if (client.connect("thingspeak.com", 80) > 0)
{
//create start command
String startcommand = "AT+CIPSTART=\"TCP\",\"thingspeak.com\",80";
Serial.println(startcommand);

//create request command
String sendcommand = "GET http://api.thingspeak.com/apps/thinghtt ... U25MX5O06Y HTTP/1.0\r\n\r\n\r\n";//works for most cases
Serial.println(sendcommand);

//send
Serial.print("AT+CIPSEND=");
Serial.println(sendcommand.length());

delay(1000);
}
else {
Serial.println("Connection Error");
}
}

I want to get this
<html><body>
<span class="about-stat"><b>49,830</b> subscribers</span>
<span class="about-stat"> &bull; <b>6,560,832</b> views</span>
<br>
<span class="about-stat">Joined May 14, 2009</span>
</body></html>

and this is what brings me back
AT+CIPSEND=97
AT+CIPSTART="TCP","thingspeak.com",80
GET http://api.thingspeak.com/apps/thinghtt ... U25MX5O06Y HTTP/1.0
User avatar
By Bergenheis
#41468 Are you running the sketch on an arduino and just want to use the ESP as a WiFi connection? If that is the case then you can send AT commands to the ESP RX pin (and receive the response from the TX pin).

Most arduinos (Uno, nano etc) only have one hardware serial connection (pin 0: RX and pin 1: TX) which are used to upload sketches and for viewing output on the serial monitor (with serial.print()). You can't simultaneously use these pins to communicate with the ESP, but you can set up a software serial on some other GPIO pins.

E.g. using pins 10 and 11:

#include <SoftwareSerial.h> // Software Serial to interface with ESP8266 to free up hardware serial for debugging
SoftwareSerial ESP8266(10,11); // RX (goes to TX on ESP), TX (goes to RX on ESP).

Set the baud rate:

ESP8266.begin(115200); // (I've found 115200 is maybe a bit fast, and not really necessary when only sending simple commands)

Then send data to the ESP using:

ESP8266.println("AT+RST");

Use if(ESP8266.find("OK")) to check the output.