Nano Every and Nextion, can send but not receive data

Hi Guys

I`m having hard time with the Nano every and Nextion combo. I can send the data to the screen, but no joy with receiving button pressed event despite being selected to send comand on the HMI interface.

Is there any special process for the NANO Every in terms of serial? Despite not having serial1 I`m using this to forward the value to the display. Is this the same approach when receiving the data?

Thanks

#include "Nextion.h"
#define ledPin 13

/*
Declare Nextion buttons  [page id:0,component id:1, component name: "b0"]
*/
NexButton b1 = NexButton(0, 2, "b1"); // "X" Zero Button
NexButton b2 = NexButton(0, 1, "b2"); // "Z" Zero Button
NexText t2 = NexText(0,5,"t2");
NexText t3 = NexText(0,6,"t3");

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

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
nexInit();
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
b1.attachPush(b1PushCallBack);
b1.attachPop(b1PopCallBack);

}
 
void loop() {
  int vin = analogRead(0);
  float float1 = float(vin) / 204;
delay(600);
Serial.println("working");
    Serial1.print("t2.txt=\"");
    Serial1.print(float1);
    Serial1.print("\"");
    Serial1.write(0xff);
    Serial1.write(0xff);
    Serial1.write(0xff);
 
}

void b1PopCallBack(void *ptr) {      
digitalWrite(ledPin, HIGH);
}

void b1PushCallBack(void *ptr) {
 digitalWrite(ledPin, LOW);
}

All Sorted. I was missing
nexLoop(nex_listen_list); in the loop.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.