1

I have esp8266. Which I am trying to set up to be a self-contained access point and server (tcp). ESP8266 is connected to ports 2,3 of Arduino Uno. On Arduino, I want to process all information coming into esp8266. Here is my current connection diagram:

enter image description here

And a simple code like this:

ESP8266

/* Create a WiFi access point and provide a web server on it. */
#include<SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>

/* Set these to your desired credentials. */
const char *ssid = "JP_TestAP";

int status = WL_IDLE_STATUS;
boolean alreadyConnected = false; // whether or not the client was connected previously

WiFiServer server(23);
WiFiClient client;

void setup()
{
   delay(1000);
   Serial.begin(9600);
   Serial.println();
   Serial.print("Configuring access point...");
   /* You can remove the password parameter if you want the AP to be open. */
   WiFi.softAP(ssid);
   delay(200);
   IPAddress myIP = WiFi.softAPIP();
   Serial.print("AP IP address: ");
   Serial.println(myIP);

   Serial.println("\nStarting server...");
  // start the server:
  server.begin();
}

void loop()
{
  // wait for a new client:
  if (!client) {
      client = server.available();
  } 
  else
  {
     if (client.status() == CLOSED) {
      client.stop();
      Serial.println("connection closed !");
    }   
    if (!alreadyConnected) // when the client sends the first byte, say hello:
    {
      // clead out the input buffer:
      client.flush();
      Serial.println("We have a new client");
      client.println("Hello, client!");
      alreadyConnected = true;
    }

    if (client.available() > 0) {
      // read the bytes incoming from the client:
      char thisChar = client.read();
      // echo the bytes back to the client:
      server.write(thisChar);
      // echo the bytes to the server as well:
      Serial.print(thisChar);
    }
  }
}

Arduino Uno

#include<SoftwareSerial.h>
SoftwareSerial esp8266(2,3);
String message = "";
bool messageReady = false;
void setup() {
  // put your setup code here, to run once:
 Serial.begin(115200);
esp8266.begin(9600);
}

void loop() {
  while(esp8266.available() > 0) {
    message = esp8266.readString();
    messageReady = true;
  }
  if(messageReady) {
    Serial.println(message);
    messageReady = false;
    return;
  }

}

Unfortunately, I am not receiving any information from the ESP8266 (just a clear log on monitor port). I don't understand where the mistake.

4
  • 1
    ESP Rx to Uno 3, ESP Tx to Uno 2. – hcheung Jun 12 at 13:32
  • @hcheung what did you mean? – ArtemiZ Studio Jun 12 at 19:44
  • i think i already have same connection, which you mention – ArtemiZ Studio Jun 12 at 20:54
  • @hcheung okay, sorry. I tested. now it works. (i tested many variants, how i can miss that?, maybe when i tested "right version" smth whent wrong with Arduino IDE) – ArtemiZ Studio Jun 12 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.