Start a new topic

PIC18F with 3,5" nextion

I'm trying to interface with a Nextion display by a PIC18F.


First I made a project in nextion editor and tried in debug mode. If I write (orp.val=100) in debug mode the value of orp is changed in the display.

Now I connected the display to my uC but there starts the difficulty.


At first there is no real information on how the serial protocol must be set, only that it is 8 bits. But what about parity, stop bits, etc?


Just as Rikaine (link) I face the same problems. I can't get it to work.


I use CCS compiler for programming my PIC controller and tried different options such as:


printf(0xff 0xff 0xff "orp.val=50" 0xff 0xff 0xff);

 

putc (0xff);
putc (0xff);
putc (0xff);
printf("orp.val=");
putc (100);
putc (0xff);
putc (0xff);
putc (0xff);

 

   putc (0xff);
   putc (0xff);
   putc (0xff);
   puts ("orp.val=100");
   putc (0xff);
   putc (0xff);
   putc (0xff);

 

   putc (0xff);
   putc (0xff);
   putc (0xff);
   printf("orp.val=100");
   putc (0xff);
   putc (0xff);
   putc (0xff);

 None of the above listed options give a result. Anyone knows what I'm doing wrong?


I monitored my serial communication to see what is sent to the nextion:
0x6F o
0x72 r
0x70 p
0x2E .
0x76 v
0x61 a
0x6C l
0x3D =
0x31 1
0x30 0
0x30 0
0xFF ÿ
0xFF ÿ
0xFF ÿ


The following code is used to generate the serial string:


 

   printf("orp.val=100");
   putc (0xff);
   putc (0xff);
   putc (0xff);

 


Well, finally managed to get it working. One of the major mistakes I made was a wrong declaration of the oscillator in my program of the uc. Because of that the serial communication only was half of what it should be.

The following code works (if everything else is ok) to alter the value of a variable:


printf("orp.val=100");
putc (0xff);
putc (0xff);
putc (0xff);

 

I have a "number" box with the name "orp". By sending the above commands it will change to 100.

You should connect the RX of you uC directly to the TX of your Nextion (no max232 in between). The communication should be 9600B, no parity, 8 bits and 1 stop bit. The signal should not be inverted.

 


1 person likes this
Login or Signup to post a comment