Connection to Server with WiFiESP and Grove UART Wifi V2 on an Arduino Uno

Hi

What I'm trying to do:
I use an Arduino Uno with a Grove UART Wifi V2 connected to the Serial Port of the Arduino to send a HTTP-POST request to a REST-Endpoint.
What works:
I am able to init the Wifi-Board and to connect the board to an Access Point. I can see the connected board in my Access Point.
What does not work:
When i try to establish the connection (line "if (wificlient.connect(""), the connect-method returns false. The statusCode will be 0.

Does anyone know what is wrong? I couldn't find any error in my code, comparing it to all forum-posts and examples I could found.

Many thanks.

// test grove - uart wifi
// scan ap and display on Grove - OLED 0.96'
// Loovee @ 2015-7-28

#include "Arduino_SensorKit.h"
#include "WiFiEsp.h"

char ssid[] = "SECRET";            // your network SSID (name)
char pass[] = "SECRET";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status


unsigned long lastConnectionTime = 0;         // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 20000L; // delay between updates, in milliseconds

WiFiEspClient wificlient;

void setup()
{
    Serial.begin(115600);
    Oled.begin();
    Oled.setFlipMode(true);
    Oled.setFont(u8x8_font_chroma48medium8_r);
    Oled.setCursor(0, 33);

    Oled.clear();           // clear the screen and set start position to top left corner  
    Oled.println("Add WiFi-Module"); 
    delay(5000);
    WiFi.init(&Serial);
    delay(5000);

      // check for the presence of the shield
    if (WiFi.status() == WL_NO_SHIELD) {
      Oled.print("Wifi shield not found");
      // don't continue
      while (true);
    }

    Oled.clear();
    Oled.setCursor(0, 33);
    Oled.print("Wifi shield ok");
    delay(5000);

    // attempt to connect to WiFi network
    while (status != WL_CONNECTED) {
      Oled.clear();
      Oled.setCursor(0, 33);
      Oled.println("Attempting to connect to WPA SSID: ");
      Oled.println(ssid);
      // Connect to WPA/WPA2 network
      status = WiFi.begin(ssid, pass);
    }

    Oled.clear();
    Oled.setCursor(3, 33);
    Oled.println("Connected!!");

    delay(5000);
    Oled.clear();
    int statusCode = -5;
    if (wificlient.connect("europe-central2-m-242-project.cloudfunctions.net", 80)) {
      Oled.println("GET...");
      String content = "Hey, just testing a post request.";
      wificlient.println("POST https://europe-central2-m-242-project.cloudfunctions.net/datacollectorV1 HTTP/1.1");
      wificlient.println("Host: https://europe-central2-m-242-project.cloudfunctions.net:80");
      wificlient.println("Accept: */*");
      wificlient.println("Content-Length: " + content.length());
      wificlient.println("Content-Type: application/x-www-form-urlencoded");
      wificlient.println();
      wificlient.println(content);
    }
   
    // read the status code and body of the response
    statusCode = wificlient.status();

    Oled.print("Status code: ");
    Oled.println(statusCode);
    delay(5000);
}


void loop()
{


}

I recommend you to use my WiFiEspAT library and the' fake' AT firmware by Jiri Bilek

https://github.com/JAndrassy/WiFiEspAT#getting-started

Thank you for your response, Juraj.

I tried what is described in your github readme. ChangeATBaudRate worked. This means that SoftwareSerial works and that the connection over pins 6 and 7 is also correctly wired (as far as I understood the code).

The firmware version of the board as returned by the sketch is 1.6.0.0.

The sketch CheckFirmware does not finish. It returns "Communication with WiFi module failed!". The returned status of wifi.status() is 255 ("WL_NO_SHIELD").

First, I'm not sure if I have wired the Grove WiFi board correctly, even though the first sketch works and returns the firmware version (does this mean that the wiring is correct?).
Second, I don't know if the version 1.6.0.0 ist sufficient for your library. You only mention 1.7.0.0 upwards.
If this is the case: How can I update the formware version? (note that my WiFi Module is a ESP8285 instead of ESP8266, as most WiFi modules are (Grove - UART Wifi V2 | Seeed Studio Wiki)).

I hope you can help. Thanks in advance.

you can use your Uno as USB to TTL Serial adapter.
upload empty sketch or Blink into Uno so it doesn't use the RX/TX.
wire the Grove WiFi to RX and TX pin of Uno as RX to RX and TX to TX (because the USB chip of Uno is wired to these pins as RX to TX).
then test from Serial monitor if you can communicate with the WiFi module (send AT+GMR from Serial Monitor and it should return the fw version).

AT firmware is in SDK here https://github.com/espressif/ESP8266_NONOS_SDK/releases

esptool is here https://github.com/espressif/esptool#installation--dependencies

to put the WiFi module into flashing mode:

Press and hold button until the red LED indicator turn on which means it is ready to burn firmware.

upload command is

esptool.py write_flash --flash_size 2MB-c1 0x0 boot_v1.7.bin 0x01000 at/1024+1024/user1.2048.new.5.bin 0x1fb000 blank.bin 0x1fc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x1fe000 blank.bin

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