News:

The Savage///Circuits website has been upgraded to a more efficient theme.

Main Menu

ESP32 P4 dev kit quick start

Started by Jeff_T, Feb 16, 2026, 10:33 AM

Previous topic - Next topic

Jeff_T

This dev kit is sold by Waveshare and has four options that each come with different pieces of hardware.

This is the product page https://www.waveshare.com/esp32-p4-module-dev-kit.htm?sku=30560

Kits B and C come with a 7 inch or 10 inch DSI LCD touch screen respectively and the product page describes the pin out and features of the board. The dev kit is not limited to the larger screens , if you want a smaller screen you can still use SPI or I2C

At the bottom of the product page is a link to a Waveshare wiki that helps you set up your environment and provides libraries and examples to get you up and running. The resource file is downloadable and has a folder for Arduino and a folder for ESP-IDF. I am using Arduino IDE so I had to copy the three libraries : displays / GFX_Library_for_Arduino / lvgl and the one lv_conf.h  file to my Arduino libraries folder. I am using the 10 inch display so initially that will be my focus but this should also apply to other displays

Waveshare wiki page https://www.waveshare.com/wiki/ESP32-P4-Module-DEV-KIT

The download also contains a folder of examples to show off the displays, the examples are : AsciiTable / Drawing_board / GFX_ESPWiFiAnalyzer / HelloWorld / LVGLV9_Arduino.

The examples are nice and the one I felt would be most useful for me was the LVGLV9_Arduino, the lvgl library is new to me but I can see there are many online resources, it is open source, has widgets with events and produces good looking gui's

The LVGLV9_Arduino has it's own in built demo's and examples and is basically restricted to portrait mode. So I modified this file so that it could be rotated between portrait and landscape and modified the touch so that it would align with any of the four possible rotated positions. Portrait or landscape is achieved by adjusting the 3 defines ROTATION / SCR_WIDTH / SCR_HEIGHT. I now save this file for future projects.

I am attatching the modified file as text which I called template. Near the end of the program file I marked an area I call the Test Block where we can run tests using lvgl widgets. At the moment there is only a pointer to a lvgl object called label1 and a function called place_widget() this should display a label in the center of the display.

Upload the template code to the ESP32 to observe the results.

As you test different widgets copy and paste the template code to a new file with a new name and always preserve template.ino.

In the IDE
   Board: ESP32P4 Dev Module
   Flash Size: 16MB
   Partition Scheme: Huge APP
   PSRAM: Enabled



Jeff_T

If all goes well with the template displaying the label we can move on to create some buttons with events that give our Arduino programs information from the touch screen.

I want three buttons lined up horizontally, one red one green and one blue. I want all three buttons attached to the same callback event handler. I want a description of the button I press and release to be printed in the serial monitor.

First we will create three pointers to a lvgl object

lv_obj_t * red_btn, * green_btn, * blue_btn;

Next I will show how to create a red button object which we can replicate for the other two buttons.

Create a button:
    red_btn = lv_btn_create(lv_screen_active());
Set the color:
    lv_obj_set_style_bg_color(red_btn, lv_color_make(255, 0, 0), LV_PART_MAIN);
Set the button size:
    lv_obj_set_size(red_btn, 150, 75);
Add the button to the event handler:
    lv_obj_add_event_cb(red_btn, event_handler, LV_EVENT_ALL, NULL);
Place the button at the desired x y coordinates
    lv_obj_align(red_btn, LV_ALIGN_CENTER, -200, 0);

This is the complete place_widget function:

void place_widget(){

    red_btn = lv_btn_create(lv_screen_active());
    lv_obj_set_style_bg_color(red_btn, lv_color_make(255, 0, 0), LV_PART_MAIN);
    lv_obj_set_size(red_btn, 150, 75);
    lv_obj_add_event_cb(red_btn, event_handler, LV_EVENT_ALL, NULL);
    lv_obj_align(red_btn, LV_ALIGN_CENTER, -200, 0);

    green_btn = lv_btn_create(lv_screen_active());
    lv_obj_set_style_bg_color(green_btn, lv_color_make(0, 255, 0), LV_PART_MAIN);
    lv_obj_set_size(green_btn, 150, 75);
    lv_obj_add_event_cb(green_btn, event_handler, LV_EVENT_ALL, NULL);
    lv_obj_align(green_btn, LV_ALIGN_CENTER, 0, 0);

    blue_btn = lv_btn_create(lv_screen_active());
    lv_obj_set_style_bg_color(blue_btn, lv_color_make(0, 0, 255), LV_PART_MAIN);
    lv_obj_set_size(blue_btn, 150, 75);
    lv_obj_add_event_cb(blue_btn, event_handler, LV_EVENT_ALL, NULL);
    lv_obj_align(blue_btn, LV_ALIGN_CENTER, 200, 0);
}

Finally we need the event handler, it simply gets the object name and the object event code. We then use a nested if and else if to look for EVENT_RELEASED and the button name to print to the serial monitor

static void event_handler(lv_event_t * e){ 

    lv_obj_t * name = lv_event_get_target_obj(e);
    lv_event_code_t code = lv_event_get_code(e);

    if (code==LV_EVENT_RELEASED){
    if (name==red_btn){
      Serial.println("Red button");
    }
    else if (name==green_btn){
      Serial.println("Green button");
    }
    else if (name==blue_btn){
      Serial.println("Blue button");
    }
    }
}

The full code file is attached as text and named btn_event.




Jeff_T

#2
The template from post one is ideal for use with the app Squareline Studio, if it's for personal use there is a free version of Squareline Studio.

This app will help you visualize your GUI as you go, you can build a project over several pages with a choice of some pretty good widgets and you end up with 90% of the code written for you.

The following video is an excellent tutorial, the screen size is different and we can replace the initial Arduino code with our template code ( remember to rename it and preserve the original ) apart from that the process is the same.


granz

Jeff,

I seem to remember a post that you made that included a picture of a dev board with an LCD attached, it looked a little like a tablet. This WaveShare thing reminded me of that. If I remember correctly, it was based on an ESP-32. It seems to me that it was pretty low-cost - maybe $30 to $40.

Do you remember that post? And, could you give me the link to that thread again, please?

Jeff_T

#4
@granz could it possibly be the Lilygo T Display S3 it's one of my favorites.

https://lilygo.cc/en-us/products/t-display-s3?

The link is from China @ $9.04 for the basic module without header. It is available from Amazon but I think the best I saw was $23 with free delivery for Prime members.

There is another similar module called the TTGO which used to be popular but I don't have any of those. 

EDIT: I just thought @granz it might have been the M5Stack Tab5, that runs at about $55

https://shop.m5stack.com/products/m5stack-tab5-iot-development-kit-esp32-p4?srsltid=AfmBOorfqjSY0N6YmOG-kuy8DvQAtv3T48Oh-vmcjc4gsmkPI6YvNduW

granz

Yeah, I think that the M5Stack is the one that I was looking for. Thanks.

Jeff_T

@granz the M5Stack Tab5 looks like a nice unit.

I subscribe to a YouTube channel called Volos Projects and he comes up with some really good looking gui designs, one of his videos covers the M5Stack and in it he talks about having a template so I am pretty sure anything I am trying to cover in this thread will also work with the M5Stack you will just need to initialize a different display.

Check him out at this video
https://www.youtube.com/watch?v=BoIAsgQ3fw8&t=123s

granz

Quote from: Jeff_T on Feb 17, 2026, 10:10 AM@granz the M5Stack Tab5 looks like a nice unit.

I subscribe to a YouTube channel called Volos Projects and he comes up with some really good looking gui designs, one of his videos covers the M5Stack and in it he talks about having a template so I am pretty sure anything I am trying to cover in this thread will also work with the M5Stack you will just need to initialize a different display.

Check him out at this video
https://www.youtube.com/watch?v=BoIAsgQ3fw8&t=123s
SQUIRREL! No, no, NO! :P  I already have too many irons in the fire; although this looks cool. I will have to remember this for when I start getting caught up on my project list. :-\

Chris Savage

So, for this following this thread, there is an interesting, if undesirable outcome to tonight's testing of the Waveshare ESP32-P4. My module seems to be faulty. It was running, then it seemed to die. I removed power and let it sit a bit, then ran it some more, and after a short time it died again. After removing the display, it seemed to run for a bit, but again died. Now it won't connect, even if left unpowered for some time.

I'll try again tomorrow and see what happens, then most likely be contacting Waveshare. I'll follow up tomorrow.

                     Bringing concepts to life through engineering.

granz

Sorry to hear that, I hope that you can get it working again.

I have had pretty good success with WaveShare, they seem to produce good quality stuff.

Chris Savage

Quote from: granz on Mar 16, 2026, 07:52 AMSorry to hear that, I hope that you can get it working again. I have had pretty good success with WaveShare, they seem to produce good quality stuff.

Well, something strange happened about an hour after I stopped working on it. I was wrapping up some stuff on the PC (making the post above, contacting Waveshare support) and decided to let the counter program run once more. After it got to 1300+ seconds, I powered it down and connected the display, then downloaded the template again. Five minutes later the display was still on, but I was so tired and had to get to bed that I shut it down. Makes no sense. I had already contacted Waveshare via their support page. I'll see what happens tonight when I can let it run longer.

                     Bringing concepts to life through engineering.

Chris Savage

I did not get a chance to run the board last night. I made dinner, did the dishes and watched a movie. I was so tired after all that I fell asleep. Hoping to re-test it tonight. In the mean time, Waveshare sent me the following with regards to my support ticket:

QuoteWe provide sample programs that you can compile, flash, and test. If you encounter any errors, please send us the log information. https://gitee.com/waveshare/esp32-p4-platform


                     Bringing concepts to life through engineering.

Jeff_T

#12
Hi Chris, most of those files are for use with ESP-IDF the only ones I initially saw for use with Arduino IDE are the ones you already have that you downloaded in the ESP32-P4-Module-DEV-KIT_Demo.zip.

There are 5:
   AsciiTable
   Drawing_board
   GFX_ESPWiFiAnalyzer
   HelloWorld
   LVGL9_Arduino

I might start with the simplest example and work through them until I had one fail.

Here is a link on capturing error data from the Arduino IDE.

https://support.arduino.cc/hc/en-us/articles/4407705216274-Use-verbose-output-in-the-Arduino-IDE

EDIT: there might actually be two scenarios, 1 where it runs and crashes and 2 where after a crash you can no longer upload.

Chris Savage

Quote from: Jeff_T on Mar 17, 2026, 10:25 AMHi Chris, most of those files are for use with ESP-IDF the only ones I initially saw for use with Arduino IDE are the ones you already have that you downloaded in the ESP32-P4-Module-DEV-KIT_Demo.zip.

Yeah, those programs would not seem to be very useful in debugging. I'm not even clear if these make use of the display. Sadly, when I posted my previous message (morning), I forgot I had an appointment that required me to leave work early. By the time we got home, had dinner and I did the dishes, I was too tired to do much and had to come into work today even earlier to make up time from leaving early yesterday and going in late Monday.

Quote from: Jeff_T on Mar 17, 2026, 10:25 AMHere is a link on capturing error data from the Arduino IDE.
EDIT: there might actually be two scenarios, 1 where it runs and crashes and 2 where after a crash you can no longer upload.

I am familiar with the verbose modes. I actually turned off verbose mode for compilation, but turned it on for programming, due to issues with certain boards in the past. I will be trying tonight. I brought my dinner to work since I will be here longer today.

P.S. - There was a really cool demo on the unit when I received it. I can't seem to figure out how to restore the original demo.

                     Bringing concepts to life through engineering.

Jeff_T

#14
@Chris Savage all 5 of the examples will run with the P4 dev kit and a DSI display. The actual display that you use is defined at the head of the sketch, for example

#define CURRENT_SCREEN SCREEN_10_1_DSI_TOUCH_A

for the 10 inch display.

The last example listed in the examples folder, LVGL9_Arduino, is slightly different in the fact it combines the lvgl library with the Arduino GFX Library specifically to show off the lvgl library functions. The lvgl Arduino library included in the zip file comes with two folders one named demos and one named examples that give you the option to try various examples using the sketch in the examples folder. If you look at the includes there are three that are not mentioned in the other 4 examples

#include <lvgl.h>
#include "lv_conf.h"
#include <demos/lv_demos.h>

A version of the program that is shipped with the dev kit is included in the demos folder and is called "widgets".

The various demos or examples can be enabled or disabled inside the Arduino sketch and the lv_conf.h configuration file.

These examples are definitely worth running, if your having issues they could provide pointers to errors in the error log.

SMF spam blocked by CleanTalk