source

info

Recently acquired a 3.5" Nextion Enhanced display and wanted to see how easy it is to work with. The display board has it's own processor and memory for running pre-compiled files made using the Nextion Editor software. Once uploaded to the board via a microSD card, you can control different elements of the board using a simple serial interface.

I took a previous project which got data from a local Pi-Hole server's API interface and diplayed it onto an OLED screen, and instead just send the data over serial port from the ESP32 to the Nextion board.



The 4 text boxes 'ads, blocked, today & domains' have a colored tile image as the background, and the white text is displayed when sent over serial. For example, the following sent over serial port from the ESP32 to the Nextion board would display 4,000 as the number of ads blocked in the Total Queries tile :

ads.txt="4,000"

The layout is from screenshotting the Pi-Hole admin interface, photoshopping out the numbers, and then saving each colored tile seperately - for each of the 4 text boxes above.



I wanted some way of visiablly showing if the Pi-Hole was enabled or not, lucily the API makes this super simple. The following: http://PIHOLE/admin/api.php?summary would return the following JSON:

{"domains_being_blocked":"184,512","dns_queries_today":"40,090","ads_blocked_today":"9,152","ads_percentage_today":"22.8","unique_domains":"1,762","queries_forwarded":"10,046","queries_cached":"20,868","clients_ever_seen":"14","unique_clients":"14","status":"enabled"}

The ArduinoJson library parses the above reply on the ESP32, allowing us to detect if the Pi-Hole is enabled or disabled.

If status = enabled in the JSON reply, we then send a serial command to the Nextion display to display the correct .png file with the green light as the background for the status text box on the nextion display, else show the red icon background to indicate the Pi-Hole is currently disabled.

Next plan is to add a touch button to the display to enable/disable the Pi-Hole at the press of a button. This is another easy command to do via the https api interface.

/admin/api.php?enable&auth=APIKEY or /admin/api.php?disable&auth=APIKEY

maybe even take input from a text box, to control how many minutes to disable the Pi-Hole before it re-enabled itself. The following would disable the Pi-Hole for 100 seconds, before it was reenabled.

/admin/api.php?disable=100&auth=APIKEY

pics

Simple 4 wire connection connects the Nextion display to the ESP board:



Side note, the board itself is built beautifully, the pictures really dont do justice for how well made this Nextion board is.

