I am using ARM's mbed compiler to program my STM32 Nucleo. I am also using an ESP8266 as my WiFi module.
My connections are as such:
- Rx of the ESP8266 is connected to D8 on the Nucleo.
- Tx of the ESP8266 is connected to D2 on the Nucleo.
- Gnd of the ESP8266 to the gnd on the board. All other pins of the ESP8266 are connected to 3.3V on the Nucleo.
The following is my mbed code:
#include "mbed.h"
Serial esp(D8, D2);
DigitalOut myled(LED1);
void flush(void) {
while (esp.readable()) {
(void)esp.getc();
}
}
int main() {
esp.baud (115200);
char server[]="GET /update?key=NR************2Z&field1=7";
flush();
esp.printf("AT+RST\r\n");
wait(2);
esp.printf("AT+CWMODE=1\r\n");
wait(3);
esp.printf("AT+CWJAP=\"Harsha\",\"*****\"\r\n");
wait(3);
esp.printf("AT+CIPMUX=1\r\n");
wait(3);
esp.printf("AT+CIPSTART=4,\"TCP\",\"184.106.153.149\",80\r\n");
wait(3);
esp.printf("AT+CIPSEND=4,%d\r\n", sizeof(server)+2);
wait(2);
esp.printf("%s\r\n", server);
wait(3);
esp.printf("AT+CIPCLOSE\r\n");
while(1) {
myled = 1;
wait(0.1);
myled = 0;
wait(0.1);
}
return 0;
}
I am able to connect to my WiFi hotspot which means there is no problem with the connection. But the data I pass is not updated in Thingspeak at all. I have also tried it including HTTP/1.0 and HTTP/1.1 in the 'server' string, still nothing. Am I missing something?