Nextion library for Teensy?

Status
Not open for further replies.

CRC

Well-known member
Could someone point me to a library for Nextion displays that is compatible with the Teensy boards. Specifically, I am using a 3.6 and a NX8048K050 Nextion 5" display. I have tried compiling examples from several different libraries but if ends with various compile errors. Perhaps there is a known working one?


......\Arduino\libraries\ITEADLIB_Nextion-master\library.properties:11): Invalid line format, should be 'key=value'

Thanks
 
Last edited:
Why do you need a library? It's really simple to send data and commands back and forth between the Teensy and the Nextion. On the Teensy side, you just need functions to convert the serial data to a string, float, integer, byte, etc.. My loop method is just one long switch case (around 200 cases :)).

Teensy side example:
Code:
			case 78: // N - GetFileListFromSD
			{
				Serial.println("GetFileListFromSD");
				GetFileListFromSD();

				break;
			}
			case 79: // O - Sync Axis Speed
			{
				configSync.speedPercent_Axis_Z = (int)GetSerialFloat(serialId);
				EEPROM.put(eePromAddress_Sync, configSync);
	#ifdef DEBUG
				Serial.print(spindle_SpeedPercent_Char);
				Serial.println(configSync.speedPercent_Axis_Z);
	#endif // DEBUG
				break;
			}

Nextion side:

Code:
print "N" // Ascii 78
  printh FF

Note: I use a single FF to terminate serial packet for the Teensy, Nextion requires three.
 
I just started looking into doing that but I'm doing something incorrectly. I just ran the simulator in simulator/device mode and ran a serial sniffer program to see what the simulator is pushing to the device to see if my interpretation of their command set is correct.

Mainly what I want to do is simply push some text to a text field from Serial2, nothing real fancy for now. I would later like to do some touch screen inputs.
 
It seems the simulator can drive the display fine but when I try to go manual just by copying over the hex it created to a terminal program to send it out (or embedded into a sketch for the Teensy) it doesn't respond.
 
I have the Nextion connected on either Serial1 or Serial3 with a PC connected to Serial. This way I can see what shows on the Nextion and verify what the Teensy is sending and receiving.

If you can't verify communication between the Teensy and the Nextion, check the cable to ensure conductivity and Tx is connected to Rx and vise versa. Connecting Tx to Tx and Rx to Rx may destroy the Nextion (Don't ask how I know :( )

You'll probably need to post your code for a better analysis.
 
It was the baud rate. I thought that it switched it to 115200 when I selected that during the upload process but it didn't. It was still at 9600. :rolleyes:
 
Put this in the PreInitialization Event of page 0 in the Nextion:
Code:
bauds=115200 // Set Baud rate
 
Status
Not open for further replies.
Back
Top