# Keyestudio ESP32 Easy Coding Board Software Tutorial


## 1. Brief Description
Keyestudio ESP32 Easy Coding Board is an open source instructional application board equipped with 520KB dynamic memory, 4MB flash memory and 240MHz dual-core processor to easily run a variety of real-time operating systems such as freeRTOS. Its low-power Bluetooth and WiFi capabilities are excellent for wireless communication.
Its powerful functions and configurations are useful in a variety of areas, including but not limited to STEAM teaching, IOT, smart control projects, as well as DIY creative works.
The Board integrates multiple sensors for projects without any external device. The on-board temperature and humidity sensor monitors the indoor and outdoor ambient temperature and humidity in real time; the six-axis acceleration gyroscope obtains the motion posture and acceleration for motion sensing; the photoresistor captures the intensity of ambient light; SD card interface saves the detected data; microphone detects ambient sound, and the buzzer plays music. Button A and B, 7 touch button can be used as switches or triggers. At last, the 5*5 RGB matrix with endless dimming, displays numbers, letters and patterns.


ESP32 board provides gold-finger expansion, including all IO ports, 19 digital channels, 7 analog channels, which support I2C, UART, SPI and other interfaces.

In addition, it supports many programming languages, like Arduino, MicroPython and KidsBlock3.0 graphical programming. It is also compatible with the development environment of other boards and is suitable for users at different programming levels.
**Compared with Micro:bit board:**
| |  |  |
| :---------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
| Name | ESP32 Easy Coding Board | Micro:bit V2 |
| Recommended group | primary, junior, **senior** high | primary, junior high |
| Processor | **ESP-WROOM-32** | nRF52833-QIAA |
| Dimensions | 52*51mm | 52*43mm |
| Memory capacity | **SRAM:520KB
Flash:4MB** | SRAM:16KB
Flash:256KB |
| Support language | KidsBlock3.0
C/C++
microPython | JavaScript
C/C++
microPython |
| I/O ports | 19 digital I/O ports
6 analog input ports
**13 PWM ports** | 19 digital I/O ports
6 analog input ports |
| Communication | 1. Bluetooth Low Energy 4.2
**2. wireless Wifi** | Bluetooth Low Energy |
| On-board function | 1. 2-channel button
**2. 7-channel touch input
**3. 3-axis acceleration
4. 3-axis gyroscope
5. light sensor
**6. 5*5 RGB matrix
7. temperature and humidity sensor
8. SD card module
9. passive buzzer
10. mini microphone
11. power supply detection**
**12. I2C interface (2.54 headers)** | 1. 2-channel button
2. 3-channel touch input
3. 3-axis acceleration
4. 3-axis magnetometer
5. light sensor
6. 5*5 LED matrix
7. temperature sensor |
| Introductory | ★★★★★ | ★★★★★ |
| Practicability | ★★★★★ | ★★ |
| Extensibility | ★★★★ | ★★★ |
## 2. Technical Specifications
- Power supply: USB power, DC power (PH2.0), Goldfinger I/O port power
- Operating voltage: 3.3V
- Operating current: 100mA
- ESP32 main control:
- Processor: ESP32-D0WDQ6 (dual-core)
- Main frequency: up to 240MHZ
- SRAM: 520KB
- Flash: 4MB
- WiFi protocol: 802.11 b/g/n (802.11n, speed up to 150 Mbps)
- WiFi operating frequency range: 2412 ~ 2484 MHz
- Bluetooth protocol: Compliant with Bluetooth v4.2BR /EDR and BLE standards
- Bluetooth RF: NZIF receiver with -97 dBm sensitivity
- Bluetooth audio: CVSD and SBC audio
- On-board resources:
- 2-way digital buttons (A and B)
- MPU6050 Six-axis acceleration gyroscope
- Maximum rotation speed: 2000°/s
- Acceleration range: ±2g, ±4g, ±8g, ±16g
- Light sensor: phototransistor ALS-PT19-315C
- Microphone: 4013-SMD
- Buzzer: MLT-8530AAC3V
- 25 RGB: WS2812-2020 RGB-LED
- Temperature and humidity sensor: AHT20
- SD card expansion interface
- Power detection module: INA180A1IDBVR
- I2C expansion port (2.54 headers)
- Extension interfaces:
- 19-channel digital I/O (partially multiplexed with on-board resources)
- two 8-bit DAC (io25, io26)
- 7 touch pins (io2, io4, io12, io13, io15, io27, io32)
- 13 PWM pins (io2, io4, io5, io12, io15, io16, io18, io19, io23, io25, io26, io27, io32)
- 3-channel UART device (any pin), support for hardware flow control and DMA
- 2-channel I2C devices (any pin), support master/slave mode
- Infrared remote control (any pin) 8-channel IR transceiver, support different waveform standards.
## 3. Programming
### 3.1. Arduino
Main interface:

#### Arduino IDE Download/Installation/Using
##### A. Windows
Step 1: visit Arduino official: [https://www.arduino.cc/](https://www.arduino.cc/)
Step 2: Click “**SOFTWARE**”.

Step 3: choose an appropriate version. Here we demonstrate on Windows.
Click “**Windows** win 10 and newer 64 bits”

Step 4: Click “**JUST DOWNLOAD**”

Step 5: the .exe file we have downloaded:

Step 6: choose “arduino-ide_2.2.1_Windows_64bit.exe” and “**Open**”

Step 7: “**I Agree**”

Step 8: “**Next**”

Step 9: ①click “**Browse..**” to choose a path for Arduino IDE; ②“**Install**”

Step 10: wait.

Step 11: tick “**Run Arduino IDE**” and “**Finish**”

##### B. MAC
Similar to Windows, choose an appropriate version to install.

#### Board Driver
##### Install CH340 Driver on WIN System
Driver download: [https://fs.keyestudio.com/CH340-WINDOWS](https://fs.keyestudio.com/CH340-WINDOWS)
Windows 10 (and later systems) boasts their own drivers, so there is no need to install additional drivers.
Connect the control board to your computer. Click Computer-- Properties -- Device Manager, as shown below. This indicates a successful connection, so the installation of driver is not required.

If the following situation occurs, you need to manually install the driver.

Click to select “Update driver”. And then the driver will start to install.

Tap "Browse my computer for drivers".

Find the downloaded “usb_ch341_3.1.2009.06” or “cp210x“ and click Next.

After finishing installing, click "Close" and the serial port number will show up.

The driver is successfully installed! Click Computer-- Properties -- Device Manager to check:

##### Install CH340 Driver on MAC System
**Step 1**: Download the driver from the Website and extract the file to the local installation directory.

**Step 2**: For details about how to install the driver in pkg format by default, see Step 3. If OS X 11.0 or later does not support Rosetta, refer to Step 4 to install the dmg driver.
Before installation, please forward to “System Preferences” -> “Security & Privacy” -> “General” page, below the title “Allow apps downloaded from:” choose the choice 2 -> “Mac App Store and identified developers”, then the driver will work normally.

**Step 3**: To install the driver in pkg format, tap the driver file → Continue→ Install


Then the installation will be successful.


To install the pkg format driver on OS X 11.0 and later: Open “LaunchPad” → “CH34xVCPDriver” → Install.

When using OS X 10.9 to OS X 10.15, click “Restart” to restart your computer, and perform the following steps after the restart.

**Step 4**: To install the dmg driver, tap the dmg file and drag “CH34xVCPDriver” to enter the application folder in the operating system.

Then open “LaunchPad” → “CH34xVCPDriver” → Install.

Then the installation will be successful.

When inserting the CH340 control board into the USB port, open System Report -> Hardware ->USB. On the right is USB Device Tree. If the USB device is working properly, you will find a device whose “Vendor ID” is [0x1a86].

Open “Terminal” program under Applications-Utilities folder and type the command “ls /dev/tty*”.

You should see the “tty.wchusbserialx” where “x” is the assigned device number similar to Windows COM port assignment.
------
#### Arduino IDE on ESP32 Board
##### Windows
In arduino IDE “Tools”——>“Board”, there is no ESP32 board, because we have not loaded it yet.
Install ESP32:
Open Arduino IDE, click “**File** ——>**Preferences**”, and copy and paste the link in Additional boards manager URLs: https://espressif.github.io/arduino-esp32/package_esp32_index.json. And click OK

Choose the board icon.

Search ESP32 to install the latest version. **During installation, please ensure that the network is stable. If the installation fails, reinstall it.**

Choose corresponding ESP32 board model.

Choose the correct COM port. You can check it in Device Manager. If there are a lot of COM ports and you do not know which one is correct, unplug the development board and a COM port will disappear. And this is the required port. If there is no COM, please check whether the driver is installed.

Herein, our COM port is COM3, so we choose “Tools”→ “Port”→ “COM3”.

After that, try an example code that prints “Hello Keyestudio!” per second on the serial monitor.
Here is the code:
```c
/*
keyestudio
Print “Hello Keyestudio!”
http://www.keyestudio.com
*/
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //Set the serial port baud rate to 9600
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Hello Keyestudio!"); //Serial port printing
delay(1000); //Delay of 1 second
}
```

Click  to upload the code and you will see:

If “————……..————……..” appears, please press the on-board “**Boot**” button. This is a solution for only Keyestudio ESP32 development board (excluding Keyestudio Plus ESP32).
Click  to open the serial monitor and set baud rate to 9600, and you can see “Hello Keyestudio!”

1. “Toggle Autoscroll”: Set whether the print window follows printing
2. “Toggle Timestamp”: Set whether to display print time
3. “Clear Output”: Clear data in the print window
4. Serial input box
5. Serial transmission format
6. Set the baud rate, click to select the baud rate
7. print box
Here is all of uploading, please return to the main tutorial to learn how to add libraries. Without library, IDE will report an error.
##### MAC
Install ESP32:
Open Arduino IDE and click “**Arduino IDE** ——>**Preferences**”. Copy and paste the link in Additional boards manager URLs: https://espressif.github.io/arduino-esp32/package_esp32_index.json. And click OK.

Choose the board icon.

Search ESP32 to install the latest version. **During installation, please ensure that the network is stable. If the installation fails, reinstall it.**

Successfully installed:

Choose corresponding ESP32 board model.

Choose the correct COM port. You can check it in Device Manager. If there are a lot of COM ports and you do not know which one is correct, unplug the development board and a COM port will disappear. And this is the required port. If there is no COM, please check whether the driver is installed.
In “Tools”–>“Port”, choose “/dev/cu.usbderial-0001”.

After that, try an example code that prints “Hello Keyestudio!” per second on the serial monitor.

Here is the code:
```c
/*
keyestudio
Print “Hello Keyestudio!”
http://www.keyestudio.com
*/
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //Set the serial port baud rate to 9600
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Hello Keyestudio!"); //Serial port printing
delay(1000); //Delay of 1 second
}
```
Click  to upload the code and you will see:

If “————……..————……..” appears, please press the on-board “**Boot**” button. This is a solution for only Keyestudio ESP32 development board (excluding Keyestudio Plus ESP32).
Click  to open the serial monitor and set baud rate to 9600, and you can see “Hello Keyestudio!”

1. “Toggle Autoscroll”: Set whether the print window follows printing
2. “Toggle Timestamp”: Set whether to display print time
3. “Clear Output”: Clear data in the print window
4. Serial input box
5. Serial transmission format
6. Set the baud rate, click to select the baud rate
7. print box
Here is all of uploading, please return to the main tutorial to learn how to add libraries. Without library, IDE will report an error.
------
### 3.2. MicroPython
Main interface:

#### Download and Install Thonny
Thonny is a free and open source software platform with small size, simple interface, simple operation and rich functions. It is a Python IDE suitable for beginners. In this tutorial, we use this IDE to develop a ESP32. Thonny supports multiple operating systems including Windows, Mac OS, Linux.
##### Download Thonny:
1). Enter the website:[https://thonny.org](https://thonny.org) to download the latest version of Thonny.
2). Thonny open-source code library:[https://github.com/thonny/thonny](https://github.com/thonny/thonny).
| System | Download link |
| MAC OS: | https://github.com/thonny/thonny/releases/download/v3.2.7/thonny-3.2.7.pkg |
| Windows: | https://github.com/thonny/thonny/releases/download/v3.2.7/thonny-3.2.7.exe |
| Linux: | Latest version: Binary bundle for PC (Thonny+Python): bash <(wget -O - https://thonny.org/installer-for-linux) With pip: pip3 install thonny Distro packages (may not be the latest version): Debian, Rasbian, Ubuntu, Mint and others: sudo apt install thonny Fedora: sudo dnf install thonny |