Makerfabs / Project_Touch-Screen-Camera

104 stars 26 forks source link

ESP32 3.5" TFT Touch with Camera

/*
Version:        V6.2
Author:         Vincent
Create Date:    2020/8/19
Note:
    V6.2 : Change Wiki link.
    V6.1 : Update firmware add camera config faq.
    V6.0 : Add WiFi bulletin board demo
    V5.0 : Add Environment Expansion Board
    V4.1 : Add 1 show example.
    V4.0 : Add 4 show example.
    V3.4 : Thanks Lovyan03's change. Greatly speed up the rendering process.
    V3.3 : Change UI direction.
    V3.2 : Added the ability to upload photos to PC through WiFi. 
    V3.1 : Replace the picture with the new hardware.
    V3.0 : Delete many useless code. Add FAQ.
    V2.0 : Change ILI9488 driver,use LovyanGFX lib.Ten times faster than before!!!

*/

ESP32 Touch Camera

[toc]

Makerfabs

Makerfabs home page

Makerfabs Wiki

ESP32 3.5" TFT Touch with Camera

Introduce

Product link : ESP32 Touch Camera(Resistive)

Product link : ESP32 Touch Camera(Capacitive)

Wiki link :ESP32 3.5" TFT Touch with Camera

The ESP32 Touch Camera use ILI9488 screen, which comes with resistive or capacitive screens. Have an OV2640 camera and SD card slot. It can be used as a webcam, an electronic album, or a digital camera. Support for Arduino and MicroPython.

Feature

front

back

Project

Related projects

ESP32 2048 GAME

Implement a 2048 game on "ESP32 Touch Camera".

2048

ESP32 Flappy Bird

Implement a Flappy Bird game on "ESP32 Touch Camera".

Flappy

Project introduction

Four projects were implemented : "Camera", "Touch_Draw", "SD2TFT" and "Receive WiFi Video".

Camera_V2

Touch_Draw_V2

Touch_Draw_V2

SD2TFT

SD2TFT

Receive WiFi Video

Transmit the contents of the monitor to the TFT screen via Wifi.A host computer software is provided to box select the areas of the screen that need to be transferred.

Change from MakePython ESP32 Color LCD で 動画をWiFi受信

wifiscreen

wifi_screen

Compiler Options

If you have any questions,such as how to install the development board, how to download the code, how to install the library. Please refer to :Makerfabs_FAQ

#define NS2009_TOUCH        //Resistive screen driver    
//#define FT6236_TOUCH      //Capacitive screen driver

#ifdef NS2009_TOUCH
#include "NS2009.h"
const int i2c_touch_addr = NS2009_ADDR;
#endif

#ifdef FT6236_TOUCH
#include "FT6236.h"
const int i2c_touch_addr = TOUCH_I2C_ADD;
#endif

complair-option

How To Use ESP32 Touch Camera

14:48:49.096 -> ets Jun  8 2016 00:22:57
14:48:49.096 -> 
14:48:49.096 -> rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
14:48:49.096 -> configsip: 0, SPIWP:0xee
14:48:49.096 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
14:48:49.096 -> mode:DIO, clock div:1
14:48:49.096 -> load:0x3fff0018,len:4
14:48:49.096 -> load:0x3fff001c,len:1100
14:48:49.096 -> load:0x40078000,len:9232
14:48:49.096 -> load:0x40080400,len:6400
14:48:49.096 -> entry 0x400806a8
14:48:50.641 -> ILI9488 Test!
14:48:50.641 -> I2C device found at address 0x38  !
14:48:50.675 -> Card Mount Successed
14:48:50.675 -> SD init over.
14:48:51.397 -> TFT init over.
14:49:10.660 -> Image name:/0write.bmp
14:49:13.859 -> Image name:/1write.bmp

camera_ui

camera_last

camera_sd

V3.2 Upload photos via WiFi

Added the function of sending photos to PC via HTTP protocol by post method.

#define WIFI_MODE
// wait for WiFi connection
WiFi.mode(WIFI_STA);
WiFi.begin("Makerfabs", "20160704");

server

upload_pic

new_ui

V4.0 Show Example

Add 4 example in /Project_Touch-Screen-Camra/example

These examples depend on TFT_eSPI library. You must set "User_Setup.h". Set screen type.

// Only define one driver, the other ones must be commented out
//#define ILI9341_DRIVER
//#define ST7735_DRIVER      // Define additional parameters below for this display
//#define ILI9163_DRIVER     // Define additional parameters below for this display
//#define S6D02A1_DRIVER
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
//#define HX8357D_DRIVER
//#define ILI9481_DRIVER
//#define ILI9486_DRIVER
#define ILI9488_DRIVER     // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
//#define ST7789_DRIVER      // Full configuration option, define additional parameters below for this display
//#define ST7789_2_DRIVER    // Minimal configuration option, define additional parameters below for this display

// For ST7789, ST7735, ILI9163 and GC9A01 ONLY, define the pixel width and height in portrait orientation
// #define TFT_WIDTH  80
// #define TFT_WIDTH  128
// #define TFT_WIDTH  172 // ST7789 172 x 320
//#define TFT_WIDTH  240 // ST7789 240 x 240 and 240 x 320
#define TFT_WIDTH  320
// #define TFT_HEIGHT 160
// #define TFT_HEIGHT 128
// #define TFT_HEIGHT 240 // ST7789 240 x 240
// #define TFT_HEIGHT 320 // ST7789 240 x 320
//#define TFT_HEIGHT 240 // GC9A01 240 x 240
#define TFT_HEIGHT 480

And set pins.

// For 3.5" 9488
// The hardware SPI can be mapped to any pins

#define TFT_MISO 12
#define TFT_MOSI 13
#define TFT_SCLK 14
#define TFT_CS   15  // Chip select control pin
#define TFT_DC    33  // Data Command control pin
#define TFT_RST   26  // Reset pin (could connect to RST pin)

V4.1 Show Example

Add environment monitoring module demo.

V6.0 WiFi bulletin board Demo

Added a WiFi bulletin board app. You can upload and browse files in the SD card through the web page. And the latest uploaded BMP or TXT display on the 3.5-inch screen.

FAQ

Q: Can't Upload!

A: Switch to a good USB cable. Poor USB cable quality can cause ESP32 to reboot or fail to upload. Open the serial monitor, observe serial port information.

Q: The screen is white!

A: The SD card was not mounted successfully, so the program goes into an endless loop. Re-insert the SD card and restart it. Open the serial monitor, The serial port will display the work log.

Q: It doesn't show the picture that was just taken!

A: It may be that after shooting, the SD card was not in good contact, so it could not be stored in the SD card. Playback photos are read inside the SD card photos. Re-insert the SD card and restart it.

Q: Other questions...

A: Re-insert the SD card and restart it. Can solve most problems. (laugh)

Q: Camera direction wrong

A: Depending on the batch of purchased cameras, the picture may be inverted. You can configure the following functions.

Change set_vflip() param to flip camera or set_hmirror() to mirror image.

// Camera setting
void camera_init()
{
    // camera config

    //...

    sensor_t *s = esp_camera_sensor_get();
    // initial sensors are flipped vertically and colors are a bit saturated
    if (s->id.PID == OV2640_PID)
    {
        s->set_vflip(s, 0);   // vertical flip
        s->set_hmirror(s, 0); // Horizontal mirror

        s->set_brightness(s, 0); // up the blightness just a bit
        s->set_saturation(s, 1); // lower the saturation
    }
    // drop down frame size for higher initial frame rate
    s->set_framesize(s, FRAMESIZE_QVGA);

    show_log(2);
}