Nextion picture

hello guys, i need help with ihm nextion.

I need a program that keeps an image (p0) hidden on the screen, until the serial receives the character c, when it receives the image it is visible, now someone will touch the image and it sends a character d through the serial and the return will hide the image again.
I’ve tried with several libraries but I couldn’t.

Can you show what you tried :wink: ?
Seeing your code (even when not working) we can get a feeling how to help best.

You also need to clarify where the characters are coming from and how you intend to control the display (i.e. which controller and how you've got it wired to the display).
Also which Nextion HMI display are you using?

In the most basic setup you won't even need an external controller for that but can do it with the display natively.
For that you'd use the recmod command to directly communicate with the display and use its inbuilt scripting language to act accordingly.

i am using an ihm NX4024K032 011 3.2POL.

And I’m controlling it via esp32.

when the image is on the screen and I press a hexadecimal code appears on the serial monitor, that is, it is communicating and it is sending the image code, but when I try to send the esp32 command to the screen I do not get a return.

here is one of the programs I’m using

#include <SoftwareSerial.h>
#include <Nextion.h>

SoftwareSerial nextion(3, 1);// Nextion TX to pin 2 and RX to pin 3 of Arduino

Nextion myNextion(nextion, 9600); //create a Nextion object named myNextion using the nextion serial port @ 9600bps

void setup() {
  Serial.begin(9600);
  myNextion.init(); // send the initialization commands for Page 0
}

void loop() {
    myNextion.sendCommand("p0.picc=2");     
  }
}

Unfortunately this is not an ESP32 forum but dedicated to Particle devices. You'll probable be better served in an ESP or Arduino forum.

However, I noticed you are not calling myNextion.loop() (or nexLoop() depending on library) which would typically be required for the Arduino library for these display as it deals with reading and dispatching the communication from the device to the controller and subsequently to the respective event handler callbacks.

BTW, there is one closing curly brace too many in that snippet :wink:

A quick Google search for "nextion library esp32" rendered this

2 Likes

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