Hey all,
How do i install Nextion Display on a Particle Electron?
What pinout do i use? or How do i set the pins?
Do i need external power supply on 5VDC for the Nextion Display?
On GITHub we do have the Nextion Arduino library https://github.com/itead/ITEADLIB_Arduino_Nextion .
In particle web IDE we do also find the Nextion Arduino library: ITEADLIB_NEXTION? https://build.particle.io/libs/ITEADLIB_Nextion/0.0.13
Where can i find some Nextion examples that works, so i can test a setupd with Particle Electron + Nextion Display?
Thanks
Meg Zamani
ScruffR
February 24, 2017, 5:04pm
2
The library comes with examples (just scroll down or hit the GitHub icon) and the pins to use are Vin, GND, RX, TX.
One odd thing with the examples is that an immediate build seems to fail.
After a short while or a minor change (e.g. #include "Nextion.h"
to #include <Nextion.h>
) building usually works - no clue why that is.
2 Likes
@ScruffR
Thx for reply.
So the setup will be like this:
(Nextion Arduino) --> (Particle Electron)
GND --> GND
Rx --> Rx
Tx --> Tx
+5V --> Vin
And then i do change:
From: #include "Nextion.h"
--> to #include <Nextion.h>
What do i do, if i allerede have installed a “RS232-ttl converter max3232 module” to Rx - Tx pin on the Particle as a “Serial1” ?
Rx should go to Tx, and Tx should go to Rx.
(Nextion Arduino) --> (Particle Electron)
GND --> GND
Rx --> Tx
Tx --> Rx
+5V --> Vin
1 Like
Ahh okay.
and can i have two devices installed on same pin Tx Rx on Particle Electron ?
One the RS232-ttl converter max3232 module and 2nd the Nextion Display
ScruffR
February 24, 2017, 8:51pm
6
With an Electron you have two more serial interfaces (Serial4
& Serial5
) at your hands.
https://docs.particle.io/reference/firmware/electron/#serial
Unfortunately this early release version of the lib doesn’t allow for easy use of these, but I’ll implement a workaround soon.
My original endeavour to wrap this in a proper C++ library got stalled by other things, but with that you should be able to even use ParticleSoftSerial
.
Meanwhile you may be able to move your max3232 to one of the alternative interfaces or have to wait for my workaround.
1 Like
ScruffR
February 27, 2017, 8:46am
7
@MegZamani , could you try the versino 0.0.14 of my lib with an Electron on an alternative interface?
You should be able to do this when adding these lines before the library include statement.
#include "Serial4/Serial4.h"
// use Serial4 on Electron ( C3[TX] & C2[RX] )
#define nexSerial Serial4
Hey @ScruffR
Thx for reply.
It sounds good with the new version 0.0.14 serial interface.
I have now tried some few things. but i do still have some very basic simple problems.
I do now have a total clean Electron with Nextion.
I did upload the simple file “CompButton_v0_32.tft” via SD card to the display - All okay
Boot-up okay, i do now see the button on the display. “Button 1” and when i click it, it gets green, and no more. :-/
#include "Serial4/Serial4.h"
// use Serial4 on Electron ( C3[TX] & C2[RX] )
#define nexSerial Serial4
#include <Nextion.h>
And im trying a very simple examples the “CompButton”
/**
* @example CompButton.ino
*
* @par How to Use
* This example shows that when the button component on the Nextion screen is released,
* the text of this button will plus one every time.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @updated 2016/12/25 bring HMI up to v0.32 to avoid too old issues
* @convert by Patrick Martin, no other changes made
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "Nextion.h"
This file has been truncated. show original
Hardware setup is:
(Nextion Arduino) --> (Particle Electron)
Rx --> Tx
Tx --> Rx
MicroUSB power supply --> (Nextion Arduino)
GND --> GND
+5V --> +5V
Display: NX8048K050
https://www.itead.cc/wiki/NX8048K050
ScruffR
February 27, 2017, 6:57pm
9
I think I have to try this myself then.
I’ll report back when I know more.
BTW, if you power the Electron via USB you can power the display off Vin & GND.
But if you need a seperate power supply, make sure to have the Electron’s GND tied to the common ground level.
@ScruffR
I have tried to power up the Display via the Vin & GND from Electron, it looks like it do not have much power for a 5" display.
Okay super @MegZamani - i did tied Electron’s GND at the same point, as the external power supply GND.
Yes… All my power to the circuit should have a common ground.
So the frist test with serial --> (Particle Electron Tx-Rx) to display - WORKING
2nd test - nexSerial Serial4 on Electron ( C3[TX] & C2[RX] )
(Nextion Arduino) --> (Particle Electron)
Rx --> Tx
Tx --> Rx
GND --> GND (external power supply)
MicroUSB power supply (external power supply) --> (Nextion Arduino) --> (Particle Electron)
GND --> GND (external power supply) --> GND (Particle Electron)
+5V --> +5V (Particle Electron)
ScruffR
February 27, 2017, 7:33pm
11
Powering the display via Vin would require a good 5V supply via USB since the LiPo would only give you about 3.7V on Vin.
Just to clarify you have got this set up like this
Nextion --> Electron
Rx --> C2
Tx --> C3
GND --> GND
This setup working - Okay
Display:
Nextion --> Electron
Rx --> Tx
Tx --> Rx
GND --> GND
+5V --> Vin
Code:
#include <Nextion.h>
2nd setup - Trying to use Serial4 on Electron ( C3[TX] & C2[RX] )
https://docs.particle.io/reference/firmware/electron/#begin--1
Display:
Nextion --> Electron
Rx --> Tx (C3)
Tx --> Rx (C2)
GND --> GND
+5V --> Vin
Code:
#include "Serial4/Serial4.h"
// use Serial4 on Electron ( C3[TX] & C2[RX] )
#define nexSerial Serial4
#include <Nextion.h>
2nd Do not working right.
ScruffR
February 28, 2017, 9:27am
13
As it seems the build sequence causes the #define nexSerial Serial4
line to be ignored when compiling the library modules.
So I’ll have to go the long way round to support alternative interfaces.
ScruffR
February 28, 2017, 11:49am
14
@MegZamani , I have just published v0.0.15 of the lib which should now work (I tested it this time ;-))
Now you will always - even with Serial1
- need a (global) line that looks like this in your code.
USARTSerial& nexSerial = Serial1;
//
// or respectively
//
//#include "Serial4/Serial4.h"
//USARTSerial& nexSerial = Serial4;
//
//#include "Serial4/Serial4.h"
//USARTSerial& nexSerial = Serial5;
4 Likes