ESP32: Difference between revisions
Jump to navigation
Jump to search
(→End) |
(→idf.py) |
||
Line 230: | Line 230: | ||
== idf.py == | == idf.py == | ||
Per instructions: | |||
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#get-started-get-esp-idf | |||
Pefore starting: | |||
* check that pip is installed | |||
<pre> | |||
ssh pi@... | |||
cd esp | |||
git clone --recursive https://github.com/espressif/esp-idf.git | |||
cd esp-idf | |||
./install.sh | |||
</pre> | |||
= End = | = End = |
Revision as of 15:12, 10 April 2020
= General information and links
Adafruit HUZZA32
- https://en.wikipedia.org/wiki/Adafruit_Industries
- Adafruit HUZZAH32 – ESP32 Feather Board, https://www.adafruit.com/product/3405
- based on ESP-WROOM-32 module, uses ESP32-D0WDQ6 chip, https://en.wikipedia.org/wiki/ESP32
- board available from DigiKey quantity "hundreds" ~CAD$35
- Pinouts & etc: https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/pinouts
- Schematics & etc: https://github.com/adafruit/Adafruit-HUZZAH32-ESP32-Feather-PCB
- USB power connector
- connection for external 3.7 V battery, charged from USB
- serial IO 3.3V RX+TX
- 1x SPI (where is the rest?)
- 1x I2C (where is the rest?)
- 7 GPIO top, shared with 2 DACs and 6 ADCs
- 7 GPIO bottom, shared with 7 ADCs and other functions
- everything is 3.3V, *NOT* 5V safe
- there is ADC1 and ADC2, not clear what it means, ADC voltage range not clear
- ADC1 or ADC2 cannot be used with Wifi (this is unclear)
- ESP32 SD card interface not connected
- ESP32 serial IO connected to USB via USB-serial-bridge chip (the best I can tell)
- power is USB with battery backup, one header pin provides regulated 3.3 V power to user (available current not clear, maybe 250 mA), battery voltage is on A13
- suggested use with Ardiuno BSP (not mongoose OS)
- module schematic: (shows ESP3212 module instead of ESP-WROOM-32) https://cdn-learn.adafruit.com/assets/assets/000/041/630/original/feather_schem.png?1494449413
ESP-WROOM-32 module
- ESP32 chip is a very basic microcontroller, CPU is done by same people who did MIPS CPUs.
- ESP32 is supported by "Mongoose OS", familiar with it as we already use the mongoose web server from same people.
- general page: https://www.espressif.com/en/products/hardware/modules
- product page: https://www.espressif.com/zh-hans/esp-wroom-32/resources (in Chineese)
- data sheet: https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_cn.pdf (in Chineese)
- module data sheet: https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf (English)
- chip data sheet: https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf
Information from the data sheets:
ESP32-D0WDQ6 chip
- dual Xtensa® 32-bit LX6 microprocessors. The internal memory includes:
- 448 KB of ROM for booting and core functions.
- 520 KB of on-chip SRAM for data and instructions.
- 8 KB of SRAM in RTC, which is called RTC FAST Memory and can be used for data storage; it is accessed by the main CPU during RTC Boot from the Deep-sleep mode.
- 8 KB of SRAM in RTC, which is called RTC SLOW Memory and can be accessed by the co-processor during the Deep-sleep mode.
- 1 Kbit of eFuse: 256 bits are used for the system (MAC address and chip configuration) and the remaining 768 bits are reserved for customer applications, including flash-encryption and chip-ID.
- 8 MB or 4 MB QSPI SRAM or Flash (this is the 4 Mbyte flash on the WROOM module?)
- 18 channels of 12-bit SAR ADC, sampling: RTC 200 ksps, DIG 2 Msps, range 0..2450 mV, 6% variation between chips, see data sheet about calibration
- ADC1 ch0..7, ADC2 ch0..9
- Hall sensor (just one? which ADC channel?)
- 2 channels of 8-bit DAC (GPIO25, 26)
- 10 touch-sensor inputs T0..T9
- ULP processor, RTC memory
- 10/100 ethernet MAC
- SD/SDIO/MMC controller 80 MHz, 1, 4 and 8 bits
- SPI/SDIO slave interface
- 3 channels of UART (U0 full modem control, U1, U2 RTS/CTS only)
- 2 channels I2C master or slave
- 2 channels I2S master or slave (I2S0, I2S1)
- 8 channels infra red receive or transmit (RMT_SIG_IN0..7 and _OUT0..7)
- 8 channels pulse counter
- 3 channels PWM controller
- 3 channels of SPI (SPI, HSPI, VSPI) master or slave
- JTAG (4 pins)
- 16 channels LED PWM
- 228 signals, Table 25
- 48 pins, IO_MUX table
- conflict between ADC2 and Wifi (and Bluetooth?)
WROOM module
- Recommended OS is FreeRTOS with LwIP
- Wifi 802.11 b/g/n (802.11n up to 150 Mbps), at 2.4 GHz
- Bluetooth v4.2 BR/EDR and BLE specification
- power 3.3 V, 80 mA typical, up to 500 mA, 1100 mA max
- pins connected to internal SPI flash: SCK/CLK, SDO/SD0, SDI/SD1, SHD/SD2, SWP/SD3 and SCS/CMD
- pins MTDI, GPIO0, GPIO2, MTDO, GPIO5 are ”GPIO_STRAPPING" set the boot mode
- pins IO12, IO13, IO14, IO15 are JTAG (this is not clear)
- pinout map: https://i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2018/08/esp32-pinout-chip-ESP-WROOM-32.png?ssl=1
- pinout map and additional information: https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
Information from adafruit: https://www.adafruit.com/product/3405 and https://learn.adafruit.com/adafruit-huzzah32-esp32-feather
- 240 MHz CPU, 520 kbytes SRAM, Wifi, Bluetooth, 4 Mbyte flash, interface for SD card. - 3x UART - 3x SPI - 2x I2C - 12 ADC inputs - 2 DAC - more goodies - everything is 3.3V, *NOT* 5V safe
Arduino IDE
On RPi3 running CentOS 7.3 (ARM 32 bit)
- install pyserial (CentOS7)
#pip install pyserial ### no "pip" #yum install python-pip ### "package not found" - no EPEL for ARM curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" python get-pip.py pip install pyserial
- install required packages (pyserial, libXrender, libXtst) (Raspbian Feb-2020)
apt-get install python-pip ### will pull many dependancies pip install pyserial ### Successfully installed pyserial-3.4 apt-get install libxrender1 libxtst6
- install arduino:
- download from https://www.arduino.cc/en/main/software, untar: arduino-1.8.12-linuxarm.tar.xz
- xz -d < arduino-1.8.12-linuxarm.tar.xz | tar xvf -
- cd arduino-1.8.12
- ./arduino ### it will bomb because libXtst is missing:
- yum install libXtst
- install ESP32 BSP:
- from https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md
- get URL: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- in arduino:
- go to File->Preferences, add this URL to "Additional board manager URLs"
- go to Tools->Board: Foo->Boards manager..., search for "esp32", it will find only one, say "install", it will down load a bunch of stuff (version 1.0.4)
- go to Tools->Board: Foo, select "Adafruit ESP32 Feather"
- go to Tools->Port select /dev/ttyUSB0
- try a "hello world" example:
- in arduino
- go to File->Examples->Communication->ASCII table
- go to Sketch, do Compile and Upload (ESP32 should be connected)
- compile successful (remember to install pyserial!), download successul, (CentOS7) after "reset using RTS" nothing happens, (Raspbian) after "reset using RTS" the new program runs
- go to Tools->Serial monitor set speed to 9600, hit the reset button on the ESP32, it should start printing the ascii table
- try TFT display example
- follow general instructions here: https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing/tft-graphics-test
- install the libraries they ask for: Adafruit ILI9341, Adafruit GFX, Adafruit_ImageReader, Adafruit_ZeroDMA (each library will install big number of dependant libraries)
- in File->Examples, open Adafruit ILI9341 -> graphicstest_featherwing
- Sketch -> Compile, Upload (success, (CentOS7) after "reset using RTS" nothing happens, (Raspbian) after "reset using RTS" the new program runs
- open Tools -> Serial monitor, set speed to 115200, hit ESP32 reset button, there will be test printed on the console and graphics drawn on the TFT display.
ESP32 DAC
Ardiuno sketch to set: 2.49V on A0 (DAC2) and 1.27V on A1 (DAC1).
#include <driver/dac.h> void setup() { // put your setup code here, to run once: dac_output_enable(DAC_CHANNEL_1); dac_output_voltage(DAC_CHANNEL_1, 100); dac_output_enable(DAC_CHANNEL_2); dac_output_voltage(DAC_CHANNEL_2, 200); }
Espressif IDE and tools
esptool
git repository is here: https://github.com/espressif/esptool
- pip install esptool ### version esptool-2.8
- check that ESP32 is connected
- esptool.py read_mac
pi@raspberrypi:~/.arduino15 $ esptool.py read_mac esptool.py v2.8 Found 2 serial ports Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP32 Chip is ESP32D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: a4:cf:12:7d:0a:24 Uploading stub... Running stub... Stub running... MAC: a4:cf:12:7d:0a:24 Hard resetting via RTS pin...
- esptool.py chip_id ### esp32 has no chip_id, use mac_address instead
- esptool.py flash_id
pi@raspberrypi:~/.arduino15 $ esptool.py flash_id esptool.py v2.8 Found 2 serial ports Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP32 Chip is ESP32D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: a4:cf:12:7d:0a:24 Uploading stub... Running stub... Stub running... Manufacturer: 20 Device: 4016 Detected flash size: 4MB Hard resetting via RTS pin...
- esptool.py read_flash_status
pi@raspberrypi:~/.arduino15 $ esptool.py read_flash_status esptool.py v2.8 Found 2 serial ports Serial port /dev/ttyUSB0 Connecting...... Detecting chip type... ESP32 Chip is ESP32D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: a4:cf:12:7d:0a:24 Uploading stub... Running stub... Stub running... Status value: 0x0200 Hard resetting via RTS pin...
idf.py
Per instructions: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#get-started-get-esp-idf
Pefore starting:
- check that pip is installed
ssh pi@... cd esp git clone --recursive https://github.com/espressif/esp-idf.git cd esp-idf ./install.sh