Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Nextion library for Teensy?

  1. #1

    Nextion library for Teensy?

    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 by CRC; 11-19-2019 at 12:45 AM.

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    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.

  7. #7
    Put this in the PreInitialization Event of page 0 in the Nextion:
    Code:
    bauds=115200 // Set Baud rate

  8. #8
    Quote Originally Posted by Elf View Post
    Put this in the PreInitialization Event of page 0 in the Nextion:
    Code:
    bauds=115200 // Set Baud rate
    Excellent. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •