I have an ESP8266 module attached to an Arduino Uno that is connected to my local network. On the network, at address 192.168.1.13, I have a nodejs/express server running on port 3000. How would I go about posting an eight digit number from the Arduino to the webserver? In my current attempts the server console isn't receiving any data when using AT+CIPSEND while connected to it.
EDIT: My Code is as follows:
#include <SoftwareSerial.h>
const byte rxPin = 9; // Wire this to Tx Pin of ESP8266
const byte txPin = 10; // Wire this to Rx Pin of ESP8266
// We'll use a software serial interface to connect to ESP8266
SoftwareSerial ESP8266 (rxPin, txPin);
void setup() {
Serial.begin(9600);
ESP8266.begin(9600); // Change this to the baudrate used by ESP8266
delay(1000); // Let the module self-initialize
Serial.println("Sending an AT command...");
ESP8266.println("AT+CWMODE=1");
delay(1000);
ESP8266.println("AT+CWJAP=\"username\",\"pass\"");
delay(10000);
ESP8266.println("AT+CIPMODE=1");
delay(1000);
ESP8266.println("AT+CIPSTART=\"TCP\",\"192.168.1.13\test\",3000");
delay(1000);
GetData();
}
void loop() {
while (ESP8266.available()){
String inData = ESP8266.readStringUntil('\n');
Serial.println("Got reponse from ESP8266: " + inData);
}
}
void GetData(){
ESP8266.println("AT+CIPSEND=4");
ESP8266.print("test");
}
and My output is this
Sending an AT command...
Got reponse from ESP8266: AT+CWMODE=1
Got reponse from ESP8266:
Got reponse from ESP8266: OK
Got reponse from ESP8266: AT+CWJAP="surveillancevan4","7073199495"
Got reponse from ESP8266: AT+CIPSEND=4
Got reponse from ESP8266: testI
EDIT 2: I modified my code to this
#include <SoftwareSerial.h>
const byte rxPin = 9; // Wire this to Tx Pin of ESP8266
const byte txPin = 10; // Wire this to Rx Pin of ESP8266
// We'll use a software serial interface to connect to ESP8266
SoftwareSerial ESP8266 (rxPin, txPin);
void setup() {
Serial.begin(9600);
ESP8266.begin(9600); // Change this to the baudrate used by ESP8266
ESP8266.println("AT");
delay(1000);
ESP8266.println("AT+CIPSTART=\"TCP\",\"192.168.1.13\",3000");
delay(20000);
String request = "POST /test HTTP/1.0 \r\n";
ESP8266.println("AT+CIPSEND=19");
delay(5000);
ESP8266.println(request);
}
void loop() {
while (ESP8266.available()){
String inData = ESP8266.readStringUntil('\n');
Serial.println("Got reponse from ESP8266: " + inData);
}
}
and now my output claims it posted successfully, but I'm still not seeing any data in my nodejs server. Here is the output: Got reponse from ESP8266:
AT
Got reponse from ESP8266:
Got reponse from ESP8266: OK
Got reponse from ESP8266: AT+CIPSTART="TCP","192.168.1.13",3000
Got reponse from ESP8266: CONNECT
Got reponse from ESP8266:
Got reponse from ESP8266: O
Got reponse from ESP8266: busy sytes
Got reponse from ESP8266:
Got reponse from ESP8266: SEND OK
I can confirm that it is connecting to my web app because when I run the code on the module without the server running it returns an error.
"192.168.1.13\test\"
should probably be replaced with"192.168.1.13/test\"
.