Difference between revisions of "NEXTIONDisplay"

From Let's Control It
Jump to: navigation, search
(Special characters)
(Screen preparations)
(5 intermediate revisions by the same user not shown)
Line 39: Line 39:
  
 
[[File:Nextion-WeMos.jpg]]
 
[[File: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.
 +
 +
[[File:Front-pre.PNG]]
 +
 +
During pre initialisation, the timer is set to 0 msec and disabled. The backlight is set to faint with dim=10.<br/>
 +
 +
When timer tm0 fires, the backlight is set to very faint, the panel goes to page 0 (front page) and the timer is disabled. When tm1 fires, some data is written to various info boxes.<br/>
 +
 +
 +
[[File:Tim0.PNG]] <br/>
 +
 +
[[File:Tim1.PNG]]<br/>
 +
 +
[[File:Front-post.PNG]]<br/>
 +
 +
[[File:Front-release.PNG]]<br/>
 +
 +
[[File:P1-pre.PNG]]<br/>
 +
 +
[[File:P1-post.PNG]]<br/>
 +
 +
[[File:Switchesl.PNG]]<br/>
 +
 +
[[File:Values.PNG]]<br/>
  
 
= ESP Easy =
 
= ESP Easy =

Revision as of 13:59, 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 to 0 msec and disabled. The backlight is set to faint with dim=10.

When timer tm0 fires, the backlight is set to very faint, the panel goes to page 0 (front page) and the timer is disabled. When tm1 fires, some data is written to various info boxes.


Tim0.PNG

Tim1.PNG

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 =