Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Brenno Leal
#53411 hi!

Im new using arduino + esp8266.

Im using an external source for esp8266 and an arduino connected to my notebook.
I am seeing my ESP8266 connected to my wifi network and im able to ping it with sucess. Buttttt.... When i create a tcp package, i get the error: Create TCP err

lets check the code:
Code: Select all    if (wifi.createTCP(0,HOST_NAME, HOST_PORT)) {
        Serial.print("create tcp ok\r\n");
    } else {
        Serial.print("create tcp err\r\n");
    }


What im doing wrong?
User avatar
By Pimby
#87156
Brenno Leal wrote:hi!

Im new using arduino + esp8266.

Im using an external source for esp8266 and an arduino connected to my notebook.
I am seeing my ESP8266 connected to my wifi network and im able to ping it with sucess. Buttttt.... When i create a tcp package, i get the error: Create TCP err

lets check the code:
Code: Select all    if (wifi.createTCP(0,HOST_NAME, HOST_PORT)) {
        Serial.print("create tcp ok\r\n");
    } else {
        Serial.print("create tcp err\r\n");
    }


What im doing wrong?


am also new am stuck here too, can someone show me how to troubleshoot this . am trying to send data to mysql database on local host here is my code

Code: Select all#include "ESP8266.h"

#define SSID        "don"
#define PASSWORD    "qwertyuiop"
#define HOST_NAME   "127,0,0,1"
#define HOST_PORT   (80)

ESP8266 wifi(Serial1,9600);

void setup(void)
{
    Serial.begin(9600);
    Serial.print("setup begin\r\n");

    Serial.print("FW Version:");
    Serial.println(wifi.getVersion().c_str());

    if (wifi.setOprToStationSoftAP()) {
        Serial.print("to station + softap ok\r\n");
    } else {
        Serial.print("to station + softap err\r\n");
    }

    if (wifi.joinAP(SSID, PASSWORD)) {
        Serial.print("Join AP success\r\n");

        Serial.print("IP:");
        Serial.println( wifi.getLocalIP().c_str());       
    } else {
        Serial.print("Join AP failure\r\n");
    }

    if (wifi.disableMUX()) {
        Serial.print("single ok\r\n");
    } else {
        Serial.print("single err\r\n");
    }

    Serial.print("setup end\r\n");
}

void loop(void)
{
    uint8_t buffer[1024] = {0};
    /*data = 256;*/

    if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
        Serial.print("create tcp ok\r\n");
    } else {
        Serial.print("create tcp err\r\n");
    }

    char *message = "GET /write_data.php?value=105 HTTP/1.1\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n";
    wifi.send((const uint8_t*)message, strlen(message));

    uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
    if (len > 0) {
        Serial.print("Received:[");
        for(uint32_t i = 0; i < len; i++) {
            Serial.print((char)buffer[i]);
        }
        Serial.print("]\r\n");
    }

    if (wifi.releaseTCP()) {
        Serial.print("release tcp ok\r\n");
    } else {
        Serial.print("release tcp err\r\n");
    }

    delay(5000);
}