Adsense HTML/JavaScript

Showing posts with label ESP32-S2-Saola-1. Show all posts
Showing posts with label ESP32-S2-Saola-1. Show all posts

Tuesday, April 26, 2022

ESP32-S2 (arduino-esp32) display on ILI9341 SPI TFT with Touch, using TFT_eSPI Library.

TFT_eSPI is a Arduino and PlatformIO IDE compatible TFT library optimized for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips.

Connection:


ILI9488
-------
1  - VCC	VCC
2  - GND	GND
3  - CS		34
4  - RESET	38
5  - DC		39
6  - SDI(MOSI)	35
7  - SCK	36
8  - LED	VCC
9  - SDO (MISO)	37
10 - T_CLK	(SCK)
11 - T_CS	40
12 - T_DIN	(MOSI)
13 - T_DO	(MISO)
14 - T_IRQ	no connection
In arduino-esp32, the default pins of ESP32S2 Dev Module for SPI are:
Default SS:         34
Default MOSI:    35
Default MISO:    37
Default SCK:      36

In TFT_eSPI, the SPI bus for the touch controller is shared with the TFT and only an additional chip select line is needed.

Setup TFT_eSPI Library:

This video show how to setup TFT_eSPI library in Arduino IDE, tested on ESP32-S2-Saola-1, with 2.4inch SPI Module ILI9341 SKU:MSP2402 with Touch.


Refer to "Tips" section in the TFT_eSPI page:

If you load a new copy of TFT_eSPI then it will overwrite your setups if they are kept within the TFT_eSPI folder. One way around this is to create a new folder in your Arduino library folder called "TFT_eSPI_Setups". You then place your custom setup.h files in there. After an upgrade simply edit the User_Setup_Select.h file to point to your custom setup file.

You can take this one step further and have your own setup select file and then you only need to replace the Setup.h line reference in User_Setup_Select.h to.

mySetup70_ESP32_S2_ILI9341.h, my custom setup.h for ESP32-S2 using ILI9341.
// Setup for the ESP32 S2 with ILI9341 display
// Note SPI DMA with ESP32 S2 is not currently supported
#define USER_SETUP_ID 70
// See SetupX_Template.h for all options available
#define ILI9341_DRIVER
/*
                    // Typical board default pins
#define TFT_CS   10 //     10 or 34

#define TFT_MOSI 11 //     11 or 35
#define TFT_SCLK 12 //     12 or 36
#define TFT_MISO 13 //     13 or 37

#define TFT_DC   14
#define TFT_RST  15
*/
#define TFT_MISO 37
#define TFT_MOSI 35
#define TFT_SCLK 36
#define TFT_CS   34
#define TFT_DC   39
#define TFT_RST  38

//#define TOUCH_CS 16 // Optional for touch screen
#define TOUCH_CS 40


#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8
#define LOAD_GFXFF

#define SMOOTH_FONT

// FSPI port will be used unless the following is defined
#define USE_HSPI_PORT

//#define SPI_FREQUENCY  27000000
#define SPI_FREQUENCY  40000000   // Maximum for ILI9341

#define SPI_READ_FREQUENCY  6000000 // 6 MHz is the maximum SPI read speed for the ST7789V

#define SPI_TOUCH_FREQUENCY 2500000


Updated User_Setup_Select.h.
// This header file contains a list of user setup files and defines which one the
// compiler uses when the IDE performs a Verify/Compile or Upload.
//
// Users can create configurations for different Espressif boards and TFT displays.
// This makes selecting between hardware setups easy by "uncommenting" one line.

// The advantage of this hardware configuration method is that the examples provided
// with the library should work with different setups immediately without any other
// changes being needed. It also improves the portability of users sketches to other
// hardware configurations and compatible libraries.
//
// Create a shortcut to this file on your desktop to permit quick access for editing.
// Re-compile and upload after making and saving any changes to this file.

// Customised User_Setup files are stored in the "User_Setups" folder.

#ifndef USER_SETUP_LOADED //  Lets PlatformIO users define settings in
                          //  platformio.ini, see notes in "Tools" folder.

// Only ONE line below should be uncommented.  Add extra lines and files as needed.

//#include <User_Setup.h>           // Default setup is root library folder
#include <../TFT_eSPI_Setups/mySetup70_ESP32_S2_ILI9341.h>

//...




Friday, October 29, 2021

arduino-esp32 CameraWebServer example, run on ESP32-S2-Saola-1 with ov2640

This post show how to run arduino-esp32 CameraWebServer example on ESP32-S2-Saola-1 with ov2640 camera.


For convenience, I connect ov2640 pins all in one side of ESP32-S2-Saola-1:

Connection between ESP32-S2-Saola-1 and ov2640

	ov2640
	+-----------+
3V3	|3V3	GND |	GND
IO9	|SIOC	SIOD|	IO1
IO10	|VSYNC	HREF|	IO2
IO11	|PCLK	XCLK|	IO3
IO12	|D9	D8  |	IO4
IO13	|D7	D6  |	IO5
IO14	|D5	D4  |	IO6
IO15	|D3	D2  |	IO7
IO16	|RESET	PWDN|	-
-	|D1	D0  |	-
	+-----------+
		
ESP32-S2-Saola-1
------+
 GND  |	- cam.GND
 5V   |
 IO17 |
 IO16 | - cam.RESET
 IO15 |	- cam.D3
 IO14 |	- cam.D5
 IO13 |	- cam.D7
 IO12 |	- cam.D9
 IO11 |	- cam.PCLK
 IO10 |	- cam.VSYNC
 IO9  |	- cam.SIOC
 IO8  |
 IO7  |	- cam.D2
 IO6  |	- cam.D4
 IO5  |	- cam.D6
 IO4  |	- cam.D8
 IO3  |	- cam.XCLK
 IO2  | - cam.HREF
 IO1  |	- cam.SIOD
 IO0  |
 3V3  |	- cam.3V3
------+
 
*cam.SIOC/SIOD are I2C-like control pins, pull-up resistors are needed.
 I use 2K ohm resistor for it.

To program ESP32-S2 on Arduino IDE, arduino-esp32 2.0.0 is needed. Select board of "ESP32S2 Dev Module".

Load CameraServer example:
Click on Menu : File > Examples > ESP32 > Camera > CameraWebServer

Edit camera_pins.h, update pins definition to match connection:

// for ESP32-S2-Saola-1/ov2640
#define PWDN_GPIO_NUM    -1
#define RESET_GPIO_NUM   16
#define XCLK_GPIO_NUM    3
#define SIOD_GPIO_NUM    1
#define SIOC_GPIO_NUM    9

#define Y9_GPIO_NUM      12
#define Y8_GPIO_NUM      4
#define Y7_GPIO_NUM      13
#define Y6_GPIO_NUM      5
#define Y5_GPIO_NUM      14
#define Y4_GPIO_NUM      6
#define Y3_GPIO_NUM      15
#define Y2_GPIO_NUM      7
#define VSYNC_GPIO_NUM   10
#define HREF_GPIO_NUM    2
#define PCLK_GPIO_NUM    11


Update ssid/password in your main code for your WiFi network.


Upload to board, if fail with error of "frame buffer malloc failed", Select PSRAM option to "Enabled".


If success, you can open browser (in the same WiFi network) to visit the CameraServer.







Tuesday, October 26, 2021

arduino-esp32, drive SSD1306 I2C OLED with ESP32/C3/S2 using esp8266-oled-ssd1306 library


With arduino-esp32 2.0.0 installed on Arduino IDE, this post run examples on ESP32-DevKitC V4/ESP32-S2-Saola-1/ESP32-C3-DevKitM-1 to drive SSD1306 I2C OLED, using esp8266-oled-ssd1306 library.


Open Library Manager in Arduino IDE, install "ESP8266 and ESP32 OLED driver for SSD1306 displays" by ThingPulse, currently 4.2.1. (esp8266-oled-ssd1306)


In the library examples, OLED display is initialized using pre-defined SDA and SCL based on your board's pins_arduino.h.
SSD1306Wire display(0x3c, SDA, SCL);   // ADDRESS, SDA, SCL


for ESP32 Dev Module:
SDA:  21
SCL:  22

for ESP32S2 Dev Module:
SDA:  8
SCL:  9

for ESP32C2 Dev Module:
SDA:  8
SCL:  9

* But on ESP32-C3-DevKitM-1 I used to test for ESP32C2 Dev Module, GPIO8 is connected to onboardRGB LED. (refer to the post "Drive ESP32-C3-DevKitM-1/ESP32-S2-Saola-1 on-board RGB LED (WS2812) in Arduino Framework") So I re-allocate to:
SDA:  19
SCL:  18

same GPIOs assigned in "ESP32-C3/MicroPython + SSD1306 I2C OLED".
SSD1306Wire display(0x3c, 19, 18);   // ADDRESS, SDA, SCL

Also connect ESP32 dev board's 3V3 and GND to SSD1306 VCC and GND.

Monday, October 25, 2021

arduino-esp32, list the pre-defined function pins of ESP32C3/S2 Dev Module

With arduino-esp32 2.0.0 installed on Arduino IDE, the following exercise run on ESP32-C3-DevKitM-1/ESP32-S2-Saola-1 to list the pre-defined function pins of ESP32C3/S2 Dev Module.

This video also show how to locate pins_arduino.h where it defined.


Test on ESP32-C3-DevKitM-1, ESP32-S2-Saola-1 and ESP32-DevKitC V4.

ESP32C3_pins.ino for board of ESP32C3 Dev Module, run on ESP32-C3-DevKitM-1
void setup() {
  // put your setup code here, to run once:
  delay(500);
  Serial.begin(115200);
  delay(500);
  Serial.println("\n\n================================");
  Serial.printf("Chip Model: %s\n", ESP.getChipModel());
  Serial.println("================================");

#ifdef EXTERNAL_NUM_INTERRUPTS
  Serial.printf("EXTERNAL_NUM_INTERRUPTS = %d\n", EXTERNAL_NUM_INTERRUPTS);
#endif
#ifdef NUM_DIGITAL_PINS
  Serial.printf("NUM_DIGITAL_PINS = %d\n", NUM_DIGITAL_PINS);
#endif
#ifdef NUM_ANALOG_INPUTS
  Serial.printf("NUM_ANALOG_INPUTS = %d\n", NUM_ANALOG_INPUTS);
#endif
  Serial.println();
  Serial.printf("Default TX:   %d\n", TX);
  Serial.printf("Default RX:   %d\n", RX);
  Serial.println();
  Serial.printf("Default SDA:  %d\n", SDA);
  Serial.printf("Default SCL:  %d\n", SCL);
  Serial.println();
  Serial.printf("Default SS:   %d\n", SS);
  Serial.printf("Default MOSI: %d\n", MOSI);
  Serial.printf("Default MISO: %d\n", MISO);
  Serial.printf("Default SCK:  %d\n", SCK);
  Serial.println();
  Serial.printf("Default A0:   %d\n", A0);
  Serial.printf("Default A1:   %d\n", A1);
  Serial.printf("Default A2:   %d\n", A2);
  Serial.printf("Default A3:   %d\n", A3);
  Serial.printf("Default A4:   %d\n", A4);
  Serial.printf("Default A5:   %d\n", A5);
  Serial.println("================================");
}

void loop() {
  // put your main code here, to run repeatedly:

}


output:
================================
Chip Model: ESP32-C3
================================
EXTERNAL_NUM_INTERRUPTS = 22
NUM_DIGITAL_PINS = 22
NUM_ANALOG_INPUTS = 6

Default TX:   21
Default RX:   20

Default SDA:  8
Default SCL:  9

Default SS:   7
Default MOSI: 6
Default MISO: 5
Default SCK:  4

Default A0:   0
Default A1:   1
Default A2:   2
Default A3:   3
Default A4:   4
Default A5:   5
================================

ESP32-C3-DevKitM-1 Pin Layout


ESP32S2_pins.ino for board of ESP32S2 Dev Module, run on ESP32-S2-Saola-1
void setup() {
  // put your setup code here, to run once:
  delay(500);
  Serial.begin(115200);
  delay(500);
  Serial.println("\n\n================================");
  Serial.printf("Chip Model: %s\n", ESP.getChipModel());
  Serial.println("================================");

#ifdef EXTERNAL_NUM_INTERRUPTS
  Serial.printf("EXTERNAL_NUM_INTERRUPTS = %d\n", EXTERNAL_NUM_INTERRUPTS);
#endif
#ifdef NUM_DIGITAL_PINS
  Serial.printf("NUM_DIGITAL_PINS = %d\n", NUM_DIGITAL_PINS);
#endif
#ifdef NUM_ANALOG_INPUTS
  Serial.printf("NUM_ANALOG_INPUTS = %d\n", NUM_ANALOG_INPUTS);
#endif
  Serial.println();
  Serial.printf("Default TX:   %d\n", TX);
  Serial.printf("Default RX:   %d\n", RX);
  Serial.println();
  Serial.printf("Default SDA:  %d\n", SDA);
  Serial.printf("Default SCL:  %d\n", SCL);
  Serial.println();
  Serial.printf("Default SS:   %d\n", SS);
  Serial.printf("Default MOSI: %d\n", MOSI);
  Serial.printf("Default MISO: %d\n", MISO);
  Serial.printf("Default SCK:  %d\n", SCK);

  Serial.println();
  Serial.printf("A0\tA1\tA2\tA3\tA4\tA5\tA6\tA7\tA8\tA9\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 A0, A1, A2, A3, A4, A5, A6, A7, A8, A9);
  Serial.println();
  Serial.printf("A10\tA11\tA12\tA13\tA14\tA15\tA16\tA17\tA18\tA19\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 A10, A11, A12, A13, A14, A15, A16, A17, A18, A19);
  Serial.println();

  Serial.printf("T1\tT2\tT3\tT4\tT5\tT6\tT7\tT8\tT9\tT10\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 T1, T2, T3, T4, T5, T6, T7, T8, T9, T10);
  Serial.println();
  Serial.printf("T11\tT12\tT13\tT14\n");
  Serial.printf("%d\t%d\t%d\t%d\n", 
                 T11, T12, T13, T14);
  Serial.println();
  Serial.printf("Default DAC1:  %d\n", DAC1);
  Serial.printf("Default DAC2:  %d\n", DAC2);
  Serial.println("================================");
}

void loop() {
  // put your main code here, to run repeatedly:

}


output:
================================
Chip Model: ESP32-S2
================================
EXTERNAL_NUM_INTERRUPTS = 46
NUM_DIGITAL_PINS = 48
NUM_ANALOG_INPUTS = 20

Default TX:   43
Default RX:   44

Default SDA:  8
Default SCL:  9

Default SS:   34
Default MOSI: 35
Default MISO: 37
Default SCK:  36

A0	A1	A2	A3	A4	A5	A6	A7	A8	A9
1	2	3	4	5	6	7	8	9	10

A10	A11	A12	A13	A14	A15	A16	A17	A18	A19
11	12	13	14	15	16	17	18	19	20

T1	T2	T3	T4	T5	T6	T7	T8	T9	T10
1	2	3	4	5	6	7	8	9	10

T11	T12	T13	T14
11	12	13	14

Default DAC1:  17
Default DAC2:  18
================================


ESP32-S2-Saola-1 Pin Layout


ESP32_pins.ino for board of ESP32 Dev Module, run on ESP32-DevKitC V4
void setup() {
  // put your setup code here, to run once:
  delay(500);
  Serial.begin(115200);
  delay(500);
  Serial.println("\n\n================================");
  Serial.printf("Chip Model: %s\n", ESP.getChipModel());
  Serial.println("================================");

#ifdef EXTERNAL_NUM_INTERRUPTS
  Serial.printf("EXTERNAL_NUM_INTERRUPTS = %d\n", EXTERNAL_NUM_INTERRUPTS);
#endif
#ifdef NUM_DIGITAL_PINS
  Serial.printf("NUM_DIGITAL_PINS = %d\n", NUM_DIGITAL_PINS);
#endif
#ifdef NUM_ANALOG_INPUTS
  Serial.printf("NUM_ANALOG_INPUTS = %d\n", NUM_ANALOG_INPUTS);
#endif
  Serial.println();
  Serial.printf("Default TX:   %d\n", TX);
  Serial.printf("Default RX:   %d\n", RX);
  Serial.println();
  Serial.printf("Default SDA:  %d\n", SDA);
  Serial.printf("Default SCL:  %d\n", SCL);
  Serial.println();
  Serial.printf("Default SS:   %d\n", SS);
  Serial.printf("Default MOSI: %d\n", MOSI);
  Serial.printf("Default MISO: %d\n", MISO);
  Serial.printf("Default SCK:  %d\n", SCK);

  Serial.println();
  Serial.printf("A0\t\t\tA3\tA4\tA5\tA6\tA7\n");
  Serial.printf("%d\t\t\t%d\t%d\t%d\t%d\t%d\n", 
                 A0, A3, A4, A5, A6, A7);
  Serial.println();
  Serial.printf("A10\tA11\tA12\tA13\tA14\tA15\tA16\tA17\tA18\tA19\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 A10, A11, A12, A13, A14, A15, A16, A17, A18, A19);
  Serial.println();

  Serial.printf("T0\tT1\tT2\tT3\tT4\tT5\tT6\tT7\tT8\tT9\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 T0, T1, T2, T3, T4, T5, T6, T7, T8, T9);
  Serial.println();

  Serial.printf("Default DAC1:  %d\n", DAC1);
  Serial.printf("Default DAC2:  %d\n", DAC2);
  Serial.println("================================");
}

void loop() {
  // put your main code here, to run repeatedly:

}

output:
================================
Chip Model: ESP32-D0WDQ5
================================
EXTERNAL_NUM_INTERRUPTS = 16
NUM_DIGITAL_PINS = 40
NUM_ANALOG_INPUTS = 16

Default TX:   1
Default RX:   3

Default SDA:  21
Default SCL:  22

Default SS:   5
Default MOSI: 23
Default MISO: 19
Default SCK:  18

A0			A3	A4	A5	A6	A7
36			39	32	33	34	35

A10	A11	A12	A13	A14	A15	A16	A17	A18	A19
4	0	2	15	13	12	14	27	25	26

T0	T1	T2	T3	T4	T5	T6	T7	T8	T9
4	0	2	15	13	12	14	27	33	32

Default DAC1:  25
Default DAC2:  26
================================


ESP32-DevKitC V4 Pin Layout
source: ESP32-DevKitC V4 Getting Started Guide :Pin Layout

Remark:
Please notice that GPIO8 on ESP32-C3-DevKitM-1 and GPIO18 on ESP32-S2-Saola-1 are connected to onboard RGB LED. Ref last post "Drive ESP32-C3-DevKitM-1/ESP32-S2-Saola-1 on-board RGB LED (WS2812) in Arduino Framework".

Sunday, October 24, 2021

Drive ESP32-C3-DevKitM-1/ESP32-S2-Saola-1 on-board RGB LED (WS2812) in Arduino Framework, with Freenove WS2812 Lib for ESP32.


 According to Espressif documentation:

There is a on-board RGB LED (WS2812) on ESP32-C3-DevKitM-1, driven by GPIO8.
ref: https://docs.espressif.com/projects/esp-idf/en/v4.3.1/esp32c3/hw-reference/esp32c3/user-guide-devkitm-1.html

On ESP32-S2-Saola-1, the on-board RGB LED (WS2812) is driven by GPIO18.
ref: https://docs.espressif.com/projects/esp-idf/en/v4.3.1/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html

"Freenove WS2812 Lib for ESP32" is an Arduino library for WS2812 led on ESP32. To use this library, open the Library Manager in the Arduino IDE and install it from there.


Thursday, October 21, 2021

Install arduino-esp32 2 on Arduino IDE, to program ESP32-C3/S2/S3


Currently, with development release arduino-esp32 2.0.0 installed, you can program ESP32-S2/C3 using Arduino IDE.
 

Install arduino-esp32 2.0.0:
- In Arduino IDE Menu, click File > Preferences

Add ESP32 boards:
- Open Boards Manager
- Search and install esp32 by Espressif system, currently version 2.0.0.

ESP32C3 and ESP32S2 Dev Module are now available in ESP32 Arduino board list.

ESP32C3_info.ino, get chip related info.
#include <Esp.h>

void setup() {
  delay(500);
  Serial.begin(115200);
  delay(500);
  Serial.println("\n\n================================");
  Serial.printf("Chip Model: %s\n", ESP.getChipModel());
  Serial.printf("Chip Revision: %d\n", ESP.getChipRevision());
  Serial.printf("with %d core\n", ESP.getChipCores());
  Serial.printf("Flash Chip Size : %d \n", ESP.getFlashChipSize());
  Serial.printf("Flash Chip Speed : %d \n", ESP.getFlashChipSpeed());

  esp_chip_info_t chip_info;
  esp_chip_info(&chip_info);
  Serial.printf("\nFeatures included:\n %s\n %s\n %s\n %s\n %s\n",
      (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded flash" : "",
      (chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "2.4GHz WiFi" : "",
      (chip_info.features & CHIP_FEATURE_BLE) ? "Bluetooth LE" : "",
      (chip_info.features & CHIP_FEATURE_BT) ? "Bluetooth Classic" : "",
      (chip_info.features & CHIP_FEATURE_IEEE802154) ? "IEEE 802.15.4" : "");
  
  Serial.println();

  Serial.println();
  Serial.println("\n- end of setup() -");

}

void loop() {
  // put your main code here, to run repeatedly:

}



Updated@2022-02-19:

Currently, ESP32 Arduino 2.0.2 is stable. So you can enter Stable release link (https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json) into Additional Board Manager URLs field, instead of Development release link (https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json).







ref:
~ ESP32 Arduino Core’s documentation


Updated@2022-05-12

With arduino-esp32 updated 2.0.3, ESP32-S3 support added.



ESP32 Arduino 2.0.3 release notice


Monday, November 23, 2020

ESP32-S2 dev. board: ESP32-S2-Saola-1 and nanoESP32-S2

ESP32-S2 is a highly integrated, low-power, single-core Wi-Fi Microcontroller SoC, designed to be secure and cost-effective, with a high performance and a rich set of IO capabilities. They are an ideal choice for a wide variety of application scenarios relating to the Internet of Things (IoT), wearable electronics and smart home. (ref: https://www.espressif.com/en/products/socs/esp32-s2)

Currently, it have 6 modules include:

My boards with ESP32-S2 Module: ESP32-S2-Saola-1 and nanoESP32-S2



My ESP32-S2-Saola-1 (with ESP32-S2-WROVER module):




ESP32-S2-Saola-1 is a small-sized ESP32-S2 based development board produced by Espressif.

It currently support:

WROOM: no PSRAM
WROVER: with PSRAM
-I: IPEX Antenna
without -I: PCB Antenna

My unit have ESP32-S2-WROVER (PCB Antenna, with PSRAM) module.


My nanoESP32-S2 (with ESP32-S2-WROVER-I module):




nanoESP32-S2 is another development board of ESP32-S2 produced by museLab. It support the four modules also, ESP32-S2-WROVER, ESP32-S2-WROVER-I, ESP32-S2-WROOM and ESP32-S2-WROOM-I.

One advantage of this board is it have a extra USB port (marked "esp32"), connect to ESP32-S2 chip directly. It is more easy to develop using CircuitPython.

My unit come with ESP32-S2-WROVER-I module (IPEX Antenna, with PSRAM) module.


Next: