Unable communicate with Nextion Display with Photon

Hello


I have wired Nextion to my Photon From the Nextion Library I have using the Button code here is the link to the code

I have already tested the Serial1 TX and RX using serial Monitor and IT is working . However I still get No Output or changes on my Nextion Display

Hi,

This is just a quick look over your code, but what jumps out is that there is no Serial.begin(); statement in the void setup()

https://docs.particle.io/reference/firmware/photon/#serial

Second thing to check is the logic level of the two I think the photon is 3.3v, don’t know about the Nextion.

Give them a check.

Liam

I suppose you have also flashed the correct firmware to the display, right?

Thank you so much VideoLiam for reviewing the code I did make changes in my CompButton.cpp code and added Serial.Begin(); I also reviewed the Voltage level shift comment thatScruffR made here Although the comments are made with Particle Electron in mind, It may also apply to Particle Photon. To check I did connect
the common ground for both Nextion and Photon and only one Pin from Nextion goes to USBTTL all the other pins Now go to Photon
The Problem was identified when the up and down arrow did not scroll through the list Here is the video link
So As part of Troubleshooting, Where the problem is communication between Photon TX and RX with Nextion is. I use the CompButton code from Nextion Library the library does not require Serial.Begin() However looking at Particle documentation I understand if you are using photon to communicate to Nextion Serial.Begin(); required in the code. If one uses Nextion by Itself, the Button does work here is thelink to the video that is able to increment the Number

To answer ScruffR question Yest I have Flash Photon 0.7.0 using Particle CLI command Particle Update from Dos Command Prompt. I also modified the CompButton.cpp and saved it as SerialBegin.cpp after adding Serial.Begin(); before the printing to Serial
I then Flash the photon using particle flash --usb SerialBegin.bin that was compiled using SerialBegin.cpp

However the number will not increase in value so the communication between Photon and Nextion via RX and TX is still a mystery to me.

One other problem I notice is Power will NOT stay powered ON when I use USBTTL to power both Photon and Nextion, Perhaps resistor are needed in the circuit to make sure there is enough amps for photon to stay powered on when powered through Vin and GND pin of Photon right above TX pin

I can vouch for the Nextion displays to work with 3.3V logic levels, so no level shifiting required for RX/TX.
But it’s another thing when it comes to Vcc for the display. The display needs to be suppied 5V on the 5V pin and since the Electron - when only powered by the LiPo - won’t be able to source that 5V you’d need to add a step-up converter.
Same goes for the Photon, but only for the unlikely event that you are running it off a LiPo (or other sub-5V source).

Serial.begin() is not required for a long time now. Since the device OS uses it for logging, Serial.begin() is called by it.

My question was rather aimed at the display - whether you flashed the correct TFT file (that also sends the touch event to the controller - this needs to be enabled in Nextion Editor) to the display.

If you could provide the HMI file (via GitHub, Dropbox or similar platform) and your current source code I can have a look.

Can you show a full diagram of your current wiring too?

BUT, in order to find out whether the HW setup is correct, testing with some known to work firmware (on both sides) would be a good start - after all, that’s what the samples are for.

BTW, is your Nextion display set to the correct baudrate?
You can set the default baudrate. Once you have done that, you’ll need to apply that baudrate via the nexInit() command.
The display shows you its default baudrate when you flash new firmware via SD. If it’s anything but 9600 you need need to use apply it like this e.g. nexInit(115200).

Hi ScruffR

Thank you for your response, much appreciate your willingness to help me.
Here is the diagram!


Please note that if I unplug the MicroUSB port from particle It does not stay powered on via USB windows 10 connection via USBTTl +5V and GND pin connected to Vin and GND on Photon

Another Note about the software code is that the debug is enabled and the function nexInit() displays string “recvRetCommandFinished err” twice on the serial monitor.

Here is the link to all the code files includes the .cpp are slight modication of the .ino file from the ITEAD nextion library. TFT was generated from downloaded the .HMI file for ITEAD_Nextion from Git and changed the orientation to fit in 2.4 inch. The SerialBegin.cpp is same as CompButton.cpp expect for the line 47 that has SerialBegin() in it. Which I understand now is Not required because of the upgrade in the system firmware One last thing to note is the Particle firmware version is 0.7.0 and the build is compiled locally and you use DFU to load the .bin file.

I’d not share the red line between the USBTTL and the Photon.

That’s probably due to the fact that the 5V output of the USBTTL device can’t source enough current to drive both the Photon and the display. If you did the TX/RX test on the Photon and it worked as expected, it’s not the Photon.

But what is that device for anyway? For your current tests you should probably remove that device from the setup to avoid any distortion of your test results.

The video you uploaded suggests that you must have changed some more than only the screen orientation and size.

With what toolchain are you building locally?

BTW, have you noticed my comment about selecting the correct baudrate for your display?


Update:
I have run your code with your HMI file on a display that definetly runs on 9600 baud and it works as expected. So I’m sure either you have the wrong baudrate or your HW is defective.

I came across this video by a chap called Andreas

Andreas Spiess Nextion Video

He does an intro video on the Nextion video. Worth the ten minutes watch. You might have skipped a minor step. Some times it worth stepping back from a problem and taking it from the top. Also if you have an Arduino handy you verify the hardware…

Liam

Some notes on the video

  • 2:37 while the default baudrate for an out-the-box display is 9600, once you had called bauds=xxxx (remote or internally) on the display that xxxx (up to 115200) will become the new default baudrate for the display. Also calling baud=xxxx will change the baudrate temporarily for that session.
  • 5:40 the statement that the SD card mustnot have any other file than only the one whatever.TFT file on is not correct either - you can have multiple files and directories on the SD card, but only one TFT file is allowed in the root directory of the card.