Cannot read from nextion display then send data to another esp

Hello, I am having some problems sending data to another esp. I have a problem sending data to another esp. I have a nextion lcd that prints each
time a button is pressed, afyer I press that button I am going to send it over to another esp(i am using two way communication since i am also
having to recrive data from that other esp. the esp with the screen attached is going to send the state of the buttons and recrive the dht22
sensor readings which i’ve not yet implementated) I can send data from the esp which will have the dht22 sensors(I will call it the electronics
box) to the esp with the screen with no problem but if I try and send data from the esp with the screen to the electroics box it will not
send, the button state isn’t even printing in the serial monitor. The stationpoint.ino is the code for the electronics box and the buttontest.ino
file is for the esp and the screen.

Buttontest.ino:

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>

//defing boolens for the state of the rgb strip/relays
bool red1=false;
bool green1=false;
bool blue1=false;
bool red2=false;
bool green2=false;
bool blue2=false;
bool relay1=false;
bool relay2=false;

//wifi stuff 
WiFiServer server(80);
IPAddress IP(192, 168, 4, 15);
IPAddress mask = (255, 255, 255, 0);

void setup() {
 Serial.begin(9600);
 //wifi part
 WiFi.mode(WIFI_AP);
 WiFi.softAP("Wemos_AP", "Wemos_comm");
 WiFi.softAPConfig(IP, IP, mask);
 server.begin();
 Serial.println();
 Serial.println("accesspoint_bare_01.ino");
 Serial.println("Server started.");
 Serial.print("IP: "); Serial.println(WiFi.softAPIP());
 Serial.print("MAC:"); Serial.println(WiFi.softAPmacAddress());
}


void loop() {
 //wifi stuff again
 WiFiClient client = server.available();
 if (!client) {
   return;
 }
 String request = client.readStringUntil('\r');
 //Serial.println("********************************"); //hhhhhhhhhhhhhhhhhhhhhhhh
 //Serial.println("From the station: " + request); //hhhhhhhhhhhhhhhhhhh
 client.flush();
 //Serial.print("Byte sent to the station: ");
 //Serial.println(client.println(request + "ca" + "\r"));
 if (Serial.available() > 0) {
   String Received = Serial.readString();
   if (int(Received[0]) == 1) {
     //Serial.println("Red1"); //hhhhhhhhhhhhhhhhhhhhhhh
     //Serial.print("Byte sent to the station: "); //hhhhhhhhhhhhhhhhhhhhhhhhh
     client.println("Red1\r");
   }
   if (int(Received[0]) == 2) {
     Serial.println("Green1");
   }
   if (int(Received[0]) == 3) {
     Serial.println("Blue1");
   }
   if (int(Received[0]) == 4) {
     Serial.println("Red2");
   }
   if (int(Received[0]) == 5) {
     Serial.println("Green2");
   }
   if (int(Received[0]) == 6) {
     Serial.println("Blue2");
   }
   if (int(Received[0]) == 7) {
     Serial.println("Relay1");
   }
   if (int(Received[0]) == 8) {
     Serial.println("Relay2");
   }
 }


}

stationpoint.ino:

#include <ESP8266WiFi.h>
byte ledPin = 2;
char ssid[] = "Wemos_AP";           // SSID of your AP
char pass[] = "Wemos_comm";         // password of your AP
IPAddress server(192,168,4,15);     // IP address of the AP
WiFiClient client;
void setup() {
 Serial.begin(9600);
 WiFi.mode(WIFI_STA);
 WiFi.begin(ssid, pass);           // connects to the WiFi AP
 Serial.println();
 Serial.println("Connection to the AP");
 while (WiFi.status() != WL_CONNECTED) {
   Serial.print(".");
   delay(500);
 }
 Serial.println();
 Serial.println("Connected");
 Serial.println("station_bare_01.ino");
 Serial.print("LocalIP:"); Serial.println(WiFi.localIP());
 Serial.println("MAC:" + WiFi.macAddress());
 Serial.print("Gateway:"); Serial.println(WiFi.gatewayIP());
 Serial.print("AP MAC:"); Serial.println(WiFi.BSSIDstr());
 pinMode(ledPin, OUTPUT);
}
void loop() {
 client.connect(server, 80);
 digitalWrite(ledPin, LOW);
 Serial.println("********************************");
 Serial.print("Byte sent to the AP: ");
 Serial.println(client.print("here would go the temp data IF WE HAD SOMEE\r"));
 String answer = client.readStringUntil('\r');
 Serial.println("From the AP: " + answer);
 client.flush();
 digitalWrite(ledPin, HIGH);
 client.stop();
 delay(2000);
}

Mind you, I was able to read the state of the buttons from the esp before adding the communication stuff in there. I am in desperate neeb for help, been working on this for 5 hours and still cannot get it working. Thanks!

Welcome to the Arduino fora.
Before you do anything else please take a moment to read General guidance
And How to use this forum
Especially item #7 on posting code.

Also,
I have never managed to get software serial to work with an ESP8266, as far as I was able to work out the interrupts needed for WiFi make a mess of the timings software serial needs.

I can't see anything in your code that looks like it would communicate successfully with a Nextion.

Support for Nextion on these fora is pretty much as follows:
You can follow the methods I set out in using Nextion displays with Arduino. My methods do not use the Nextion libraries, so while I am happy to offer help on using my methods I cannot offer anything very helpful for any Nextion library.
The original Nextion libraries are full of bugs. There is a link from my tutorial to some improved Nextion libraries created by Ray Livingston, I suggest those might be worth trying if you prefer to use a library.
There's also Seithan who has also developed his own ways of dealing with Nextion displays, you can find his methods in his tutorial on how to write code with Nextion and Arduino.
Beyond that the odd person occasionally offers a bit of help but not much.

Thanks for reaching out, I wasn’t able to find that option while making the forum but will edit it, my bad.
In the nextion software, the buttons print a value and the esp reads that value, as seen în this video: https://youtu.be/akpF9TbvNss

I would be more than happy of you could help me detect when the button is being pressed(I have two oages each having some buttons)

I would be more than happy of you could help me detect when the button is being pressed(I have two oages each having some buttons)

I already have; it's in my tutorial.

hi, modified the code a bit but it is still not working, can you spot an error? The code compiles just fine but it doesn’t print “red1” when I press b0. Here is the new code(I am using an esp8266 and it’s rx and tx pins to connect it)

#include <doxygen.h>
#include <NexButton.h>
#include <NexCheckbox.h>
#include <NexConfig.h>
#include <NexCrop.h>
#include <NexDualStateButton.h>
#include <NexGauge.h>
#include <NexGpio.h>
#include <NexHardware.h>
#include <NexHotspot.h>
#include <NexNumber.h>
#include <NexObject.h>
#include <NexPage.h>
#include <NexPicture.h>
#include <NexProgressBar.h>
#include <NexRadio.h>
#include <NexRtc.h>
#include <NexScrolltext.h>
#include <NexSlider.h>
#include <NexText.h>
#include <NexTimer.h>
#include <Nextion.h>
#include <NexTouch.h>
#include <NexUpload.h>
#include <NexVariable.h>
#include <NexWaveform.h>

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
//definding butons 
//NexButton name = NexButton(page, id, "name")
NexButton b0 = NexButton(1, 2, "b0");

NexTouch *nex_listen_list[] = {
  &b0,
  NULL
  };

//object name pushcallback(void *ptr)

void b0PushCallback(void *ptr) {
  Serial.println("Red1");
  }
//wifi stuff 
WiFiServer server(80);
IPAddress IP(192, 168, 4, 15);
IPAddress mask = (255, 255, 255, 0);

void setup() {
  Serial.begin(9600);
  //wifi part
  WiFi.mode(WIFI_AP);
  WiFi.softAP("Wemos_AP", "Wemos_comm");
  WiFi.softAPConfig(IP, IP, mask);
  server.begin();
  Serial.println();
  Serial.println("accesspoint_bare_01.ino");
  Serial.println("Server started.");
  Serial.print("IP: "); Serial.println(WiFi.softAPIP());
  Serial.print("MAC:"); Serial.println(WiFi.softAPmacAddress());
  //nextion sutff
  b0.attachPush(b0PushCallback);
}

void loop() {
  nexLoop(nex_listen_list);
  //wifi stuff again
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
  String request = client.readStringUntil('\r');
  Serial.println("********************************");
  Serial.println("From the station: " + request);
  client.flush();
  //Serial.print("Byte sent to the station: ");
  //Serial.println(client.println("IamAlive\r"));
  }

Sorry, as I said in reply #1, I don't use the Nextion libraries, as you are using them I can't help.