Nextion Display - Sending Data

Hi Everyone,

I am currently trying to have my Nextion Display (NX8048P070) display whether my bluetooth is connected.
I have all the code working that shows what state the bluetooth is, its now sending this result to the display...

 if (BTState == HIGH && prevBTState == LOW) {
      prevBTState == HIGH;
      Serial1.print(F("BTState.txt=\""));
      Serial1.print(F("Connected"));
      Serial1.print(F("\""));
      Serial1.write(0xff);
      Serial1.write(0xff);
      Serial1.write(0xff);
    } else if (BTState == LOW && prevBTState == HIGH) {
      prevBTState == LOW;
      Serial1.print(F("BTState.txt=\""));
      Serial1.print(F("Disconnected"));
      Serial1.print(F("\""));
      Serial1.write(0xff);
      Serial1.write(0xff);
      Serial1.write(0xff);
    }

i have followed the guide PerryBebbington has made which has been very helpful, but i cant seem to get mine to display in my text box, selected in picture below:

All Pins are wired up correctly, as i am able to send data to the Arduino from the display and it reads that successfully.

Any help as to why this may not be working would be most appreciated :grinning:

Update

I have manage to get it to send to display on text box t1, which eventually be for runtime, but it wont send to the text box i want it to BTState.

Is it a simple case of it doesnt like the name?

I have used various custom names for text boxes and so far have not found one it objects to. You could try first just creating a new text box and use the default name, then if that works try changing the name.

My guess is that you have a simple mistake somewhere that you can't see because you have been looking at it too long. A single incorrect character will mean it won't work. If you are still struggling tomorrow post your full non working code and I'll have a look. Do you know for sure that the else if actually gets executed? Put some serial prints in to the serial monitor to prove it.

More...
I don't see that you need so many conditions in the else if, I think you just need else.

i have created a new text box and that seems to work.
As you said it could just be a case of looking at it too long.

The reason i put more conditions in was to reduce the need for data to keep being sent to the display, only send if there was a change in state.

1 Like

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