Saturday, December 19, 2020

ESP32 Bluetooth serial example

It's a simple example of ESP32 Bluetooth serial communication, run on ESP32-DevKitC V4.

The video show how it run, to communicate with Python/Raspberry Pi. The Python code is in my another blog: HelloRaspberryPi - Python (on Raspberry Pi) Bluetooth communicate with ESP32 SerialToSerialBT, using pybluez.

To make the ESP32 examples appear in examples list, you have to choose board of ESP32 first. It's ESP32 Wrover Module in may case.

The example available in Arduino IDE MENU > File > Examples > Bluetooth Serial (under Examples for Wrover Module) > SerialToSerialBT.


I make a little bit modification to display its Bluetooth MAC address.
// ref: Examples > BluetoothSerial > SerialToSerialBT

#include "BluetoothSerial.h"
#include "esp_bt_device.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;

void printDeviceAddress() {
 
  const uint8_t* point = esp_bt_dev_get_address();
 
  for (int i = 0; i < 6; i++) {
 
    char str[3];
 
    sprintf(str, "%02X", (int)point[i]);
    Serial.print(str);
 
    if (i < 5){
      Serial.print(":");
    }
 
  }
}

void setup() {
  Serial.begin(115200);
  Serial.println("\n---Start---");
  SerialBT.begin("ESP32test"); //Bluetooth device name
  
  Serial.println("The device started, now you can pair it with bluetooth!");
  Serial.println("Device Name: ESP32test");
  Serial.print("BT MAC: ");
  printDeviceAddress();
  Serial.println();
}

void loop() {
  if (Serial.available()) {
    SerialBT.write(Serial.read());
  }
  if (SerialBT.available()) {
    Serial.write(SerialBT.read());
  }
  delay(20);
}

The function printDeviceAddress() is copy from dfrobot ESP32 Arduino: Getting the Bluetooth Device Address.

Next:


Friday, December 18, 2020

ESP32-DevKitC V4 - ESP32-WROVER-E module, with ESP32-D0WD-V3 embedded

ESP32-DevKitC V4 is a small-sized ESP32-based development board produced by Espressif. Most of the I/O pins are broken out to the pin headers on both sides for easy interfacing. Developers can either connect peripherals with jumper wires or mount ESP32-DevKitC V4 on a breadboard.



To cover a wide range of user requirements, the following versions of ESP32-DevKitC V4 are available with different ESP32 modules:
  • ESP32-WROOM-32E
  • ESP32-WROOM-32UE
  • ESP32-WROOM-32D
  • ESP32-WROOM-32U
  • ESP32-SOLO-1
  • ESP32-WROVER-E
  • ESP32-WROVER-IE
My board is installed with ESP32-WROVER-E module.

ESP32-WROVER-E and ESP32-WROVER-IE are two powerful, generic WiFi-BT-BLE MCU modules. ESP32-WROVER-E comes with a PCB antenna, and ESP32-WROVER-IE with an IPEX antenna. They both feature a 4 MB external SPI flash and an additional 8 MB SPI Pseudo static RAM (PSRAM). 

At the core of the module is the ESP32-D0WD-V3 chip, For details on the part numbers of the ESP32 family of chips, please refer to the document ESP32 Datasheet.

Espressif has released one wafer-level change on ESP32 Series of products (ECO V3). ESP32 ECO V3 User Guide is one of the must see document describes differences between V3 and previous ESP32 silicon wafer revisions.



To install ESP32 on Arduino IDE Boards Manager:

Arduino IDE Menu > File> Preferences
Enter the url in the "Additional Board Manager URLs":

To enter more than one URL, separate it with a comma.

Then:
Menu > Tools > Board > Boards Manager…
Search and install ESP32

related:

Examples (in Arduino framework):

Usefull links:




Saturday, September 5, 2020

Program ESP32-CAM using FTDI adapter


The AI-Thinker ESP32-CAM support OV2640 and OV7670 camera module, my unit come with OS2640.


With ESP32-S module.

This video show how to program AI-Thinker ESP32-CAM in Arduino IDE (with ESP32 Core), using FTDI adapter. 

It have no USB interface on board, and also no button for downloading firmware. So I have to use a FTDI adapter, and a wire to program it.

The FTDI adapter have option to select 3V3 or 5V for VCC. Somebody suggest using 3V3, somebody else suggest 5V. In my case, 5V seem more stable, so I select option of 5V, and connect its VCC pin to ESP32's 5V pin. FTDI's GND to ESP32's GND.

To program ESP32-CAM, using a wire to short circuit between ESP32's GPIO0 and GND.

ESP32's UOT to FTDI RX.

ESP32's UOR to FTDI TX.

Make sure ESP32 is installed in Arduino IDE. To setup ESP32 on Arduino IDE, refer Install ESP32/ESP8266 to Arduino IDE on Ubuntu 20.04, with setup Pythton & serial.

Select board of AI Thinker ESP32-CAM.


Select the USB port connected to your ESP32-CAM.

Open Example > ESP32 > Camera > CameraWebServer


Modify the code:
Select camera model of CAMERA_MODEL_AI_THINKER,
and change ssid and password for your WiFi network. 


Save as another new file. Verify and Upload to ESP32.

After uploaded,
Un-plug USB from FTDI adapter (power-off).
Remove the wire between GPIO0 and GND.
Re-plug USB to FTDI adapter (power-on), to run the ESP32-CAM.

Open Arduino IDE's Serial Monitor and set Baud Rate to 115200.
After ESP32-CAM connect to WiFi network, mark down the IP address.

Use another device, PC, phone or table..., connect to the same WiFi network.
Open browser to visit the IP shown in Serial Monitor.


Reference:
~ AI-Thinker's ESP32-CAM page (in Chinese)



Remark:

If you run the example fail with error:
[E][camera.c:1113] camera_probe(): Detected camera not supported.
[E][camera.c:1379] esp_camera_init(): Camera probe failed with error 0x20004



Most likely it is caused by inn-correct camera model select. Try to select other camera model. It is CAMERA_MODEL_AI_THINKER for my model.