LCD Screen

LCD Screen 3.2" 320 x pixels, 18bit colour LCD Controller ILI9341 controller, connects to ESP32 via SPI bus. Source code resources LCD support for the ESP32 seems a bit rudimentary at the moment, a bit wild west.  You'll need to hunt around for libraries to try and do something nice and useful with the screen. https://github.com/espressif/esp-iot-solution/tree/master/components/spi_devices/lcd    

Read More

Main Loop

Although FreeRTOS is all about creating tasks, you can just use a main loop approach to programms running on it if you want to.  You simply need to ocassionally sleep so the RTOS can drop down to the Idle task, do any housekeeping and reset its watchdog timer.    Here's a working example of a […]

Read More

Production Programming

Programming Adapter You need a suitable programming adapter, see our programming hardware page. Download the Espressif Windows software Download and install "Flash Download Tools (ESP8266 & ESP32)" from: https://www.espressif.com/en/products/hardware/esp32/resources Programming Instructions Run the flash download tool "flash_download_tools_v3.6.5.exe" Select "ESP32 Download Tool" Select the "SPI Download" tab Select the 3 files to program with, enter their start […]

Read More

malloc

Temporary memory example //CREATE TEMPORARY MEMORY BUFFER uint32_t *my_temporary_memory_buffer = malloc(1024 * sizeof(uint32_t)); //Allocate a block of size bytes of memory, returning a pointer to the beginning of the block. Use calloc() to do same but zero initialise the buffer. if (my_temporary_memory_buffer != NULL) { //Use my_temporary_memory_buffer as needed my_temporary_memory_buffer[0] = 1234; //RELEASE TEMPORARY MEMORY […]

Read More

TCP Server

Ethernet TCP Server Example (This example is based on using a wired Ethernet port, the setup and event_handler would need adapting to use for the WiFi port) #include <stdio.h> #include <string.h> #include <sys/fcntl.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_wifi.h" #include "esp_system.h" #include "esp_err.h" #include "esp_event_loop.h" #include "freertos/event_groups.h" #include "esp_event.h" #include "esp_attr.h" #include "esp_log.h" #include "esp_eth.h" #include […]

Read More

Writing to the log

Resources https://dl.espressif.com/doc/esp-idf/latest/api-reference/system/log.html Writing to log Several macros are available for different verbosity levels static const char *TAG = "My applicaiton thing"; ESP_LOGI(TAG, "Info – something happened\n"); ESP_LOGW(TAG, "Warning – something happened\n"); ESP_LOGE(TAG, "Error – something bad happened\n"); ESP_LOGD(TAG, "Debug – something happened\n"); ESP_LOGV(TAG, "Verbose – something happened\n");  

Read More

Event group

Using an event group static EventGroupHandle_t tcpserver_event_group; //Create it tcpserver_event_group = xEventGroupCreate(); //Set the state when say a connection happens or is lost xEventGroupSetBits(tcpserver_event_group, CONNECTED_BIT); xEventGroupClearBits(tcpserver_event_group, CONNECTED_BIT); //Wait for connected xEventGroupWaitBits(tcpserver_event_group, CONNECTED_BIT, false, true, portMAX_DELAY); //Stalls (with timeout)      

Read More

Event handler

You can subscribe to be notified of ESP events using this In your initialise ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); Event handler fucntion //*************************************** //*************************************** //********** ESP EVENT HANDLER ********** //*************************************** //*************************************** //Call this at startup: //ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); static esp_err_t event_handler(void *ctx, system_event_t *event) { switch(event->event_id) { case SYSTEM_EVENT_STA_START: //WiFi connected break; case SYSTEM_EVENT_STA_GOT_IP: //WiFi […]

Read More