Не могу передать информацию с esp8266 на arduino uno.
- Войдите на сайт для отправки комментариев
Вс, 13/06/2021 - 01:29
У меня есть esp8266 который я пытаюсь настроить как самостоятельную точку доступа Wi fi + сервер (tcp). ESP8266 соединен к портам 2 3 от ардуино. На самой ардуине, я хочу обрабатывать всю информацию поступившую к esp8266.
Вот так это выглядит сейчас:

То что залито на esp8266:
#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);
}
}
}
На ардуино:
#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;
}
}
Вообщем проблема в том, что не получается прочитать данные с wi fi модуля на ардуино. (Просто мустой монитор порта).
Окей, проблема была в распиновке tx-rx разьемов esp8266 (нужно было поменять их местами). Хотя я точно помню, что делал по разному