OpenSprinkler Forums OpenSprinkler Unified Firmware NodeMCU ESP8266 connecting to OS Pi – Fails with -1 response

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #67682


    I am trying to connect to OS Pi from NodeMCU ESP8266 via the API. I have spent several days without success. Really appreciate anyone who can help me here.

    I recently purchased (within the last month) my OS Pi so have the latest firmware on OS Pi. I am using the following code to connect from ESP8266 to OS Pi and I only get a -1 error. My ESP8266 connects to ThingSpeak and posts data just fine. So, I know the ESP8266 is on the WiFi and able to communicate. Calling any other http site with the http.begin code returns the proper response with out errors. Also, using the GET method in Postman with the same exact URL “http://192.168.X.XX:8080/mp?pw=a6d82bced638de3def1e9bbb4983225c&pid=0&uwt=0” returns a 1 and 200 response – all good. So, I know the OS Pi details are correct for the URL. I just cannot get the ESP8266 to the URL and talk to OS Pi. Please help!! I even submitted a ticket, but was told this is my ESP8266 issue and the ticket was closed without contacting met. Anyone out there who successfully connected to OS Pi from NodeMCU? Really appreciate someone helping me. Thank you in advance.

    #include <ESP8266WiFi.h> // Include the Wi-Fi library
    #include <ESP8266HTTPClient.h>

    const char* ssid = “XXXXXXX”; // The SSID (name) of the Wi-Fi network you want to connect to
    const char* password = “XXXXXX”; // The password of the Wi-Fi network

    const char* host = “http://192.168.X.XX:8080/&#8221;;
    const char* md5hash = “a6d82bced638de3def1e9bbb4983225c”;
    int pid = 0;
    int uwt = 0;

    void setup() {

    Serial.begin(115200); // Start the Serial communication to send messages to the computer
    Serial.println(“********** Program Start : Soil Moisture monitoring using ESP8266 and ThingSpeak IoT cloud”);
    Serial.println(“Wait for WiFi… “);
    Serial.print(“********** connecting to WIFI : “);
    WiFi.begin(ssid, password); // Connect to the network

    int i = 0;
    while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    Serial.print(++i); Serial.print(“.”);

    Serial.println(“Connection established!”);
    Serial.print(“IP address:\t”);
    Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer

    String url = “”;
    url += host;
    url += “/mp?pw=”;
    url += md5hash;
    url += “&pid=”;
    url += pid;
    url += “&uwt=”;
    url += uwt;


    HTTPClient http;


    // start connection and send HTTP header
    int httpResponseCode = http.GET();

    // httpCode will be negative on error
    if(httpResponseCode > 0) {
    // HTTP header has been send and Server response header has been handled
    Serial.printf(“[HTTP] GET… code:%d\n”, httpResponseCode);

    } else {
    Serial.printf(“[HTTP] GET… failed%s\n”);



    void loop() {


    This is the response I see in Serial Monitor:

    Connection established!
    IP address: 192.168.X.XX
    -1[HTTP] GET… failed



    Made more progress and found out the communication failure was due to network issue. Moved both the ESP8266 NodeMCU and the OS Pi to the base home LAN from the Eero network. That fixed it. Have not yet found out why being in the Eero network does not allow these two 2.4GHz devices to communicate with each other. At least I was able to get past the issue and have my sensor talk to the sprinkler and turn on the sprinklers using moisture data. The API works as advertised. Thought I would send in the follow-up in case others have similar issues.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums OpenSprinkler Unified Firmware NodeMCU ESP8266 connecting to OS Pi – Fails with -1 response