Difference between revisions of "NEXTIONDisplay"

From Let's Control It
Jump to navigation Jump to search
Line 43: Line 43:
 
Although this is not the place to go into too much detail of the Nextion Editor, the examples help to explain the possibilities of the plugin.
 
Although this is not the place to go into too much detail of the Nextion Editor, the examples help to explain the possibilities of the plugin.
  
Let's assume you would like to have a control panel. It is dead easy to create such a device.
+
Let's assume you would like to have a control panel with several pages. Below is example with three pages. A front page, an info page and a switch page.
 +
To make switching between pages run smoothley, without having to wait for data, Variables can be used.
 +
Several of them are declared and made global on the front page.
 +
One or more timers make sure the control panel dims its backlight and go back to its start screen.
  
 +
[[File:Front-pre.PNG]]
 +
 +
During pre initialisation, the timer is set and enabled. The backlight is set to faint with dim=10.
  
[[File:Front-pre.PNG]]
 
  
 
[[File:Front-post.PNG]]
 
[[File:Front-post.PNG]]

Revision as of 12:52, 27 May 2018

Introduction

WIP.gif

This page is under contruction.
The OLED page is being used as a donor.

Beware.jpg

This is not an ordinary display. You cannot simply write data to it, but first have to create an appropriate interface.
This is a very easy process, when using the free Itead IDE (Just search for Nextion on the web).
It has some good tutorials and once you have created your own display, it is very easy to present data and control devices with it.

The ESP8266 module can be used to control an Serial Nextion Display. Due to its on-board intelligence and the presence of a touch panel, the display can be used to control devices.

Nextion2.jpg

Hardware

The board is connected to a controller by means of 4 wires

Nextion2.jpg

Connect the Nextion Display to a serial port and to +5 V and ground. The Nextion software module provides the use of a Software Serial port. So, it is not required to use the 'native'Tx and Rx ports of the controller. This display works with 5V and can be connected directly to the ESP module.

Connections

 LCD 	 	ESP
 GND 	 	GND
 VCC    	VCC
 Tx		GPIO port acting as Rx
 Rx		GPIO port acting as Tx

In order to get those displays to work properly you need to activate the pull-up of the Tx pin. A quick test is to set the pin to high (1) but for long turn you should enable the pull-up instead. If the pin is missing a pull-up you can add one yourself by soldering a 10k resistor from 3.3V to the pin.


Nextion-WeMos.jpg

Screen preparations

Although this is not the place to go into too much detail of the Nextion Editor, the examples help to explain the possibilities of the plugin.

Let's assume you would like to have a control panel with several pages. Below is example with three pages. A front page, an info page and a switch page. To make switching between pages run smoothley, without having to wait for data, Variables can be used. Several of them are declared and made global on the front page. One or more timers make sure the control panel dims its backlight and go back to its start screen.

Front-pre.PNG

During pre initialisation, the timer is set and enabled. The backlight is set to faint with dim=10.


Front-post.PNG

Front-release.PNG

P1-pre.PNG

P1-post.PNG

Switchesl.PNG

Values.PNG

ESP Easy

Use the device tab on the ESP Easy webinterface and create a new task by editing one of the available tasks. Select "Display - Nextion" from the dropdown box.

Now you first need to prepare your display. It needs to contain textboxes, numerical boxes etc. In the example below, I created variables vHO, vSold and vSolt. Data retrieved from a MQTT tasks can be written to it with:

page0.vHO.txt=[MQTT1#RFLWsTH_h]

where page0.vHO.txt describes the variable in the Nextion display, that I created beforehand.

Check this sample on how to get it done:

NextionSettings.PNG

In the second example

NextionSettings2.PNG

The idx and value fields are used to communicate button presses etc.

This info can be handled in the Rules:

NextionRules.PNG

(The upper (MQTT) IDX field will be stuffed with '1', because it's needs a value. But nothing will be send with this device the second one is to write to a debug text box in Domoticz, but could also be 1)

Commands

Command Value Extra information
Nextion, - Write text messages to OLED screen, ROW for row, COL for starting column, and Text for text.
Nextion,<value> Switch on or off the OLED or to clear the display. During the off state, the content will be updated according to the latest values or states.

Special characters