this repository is the firmware for [ESP32-S2](https://www.espressif.com/en/products/socs/esp32-s2)-based [WEMOS](https://www.wemos.cc/en/latest/index.html) [S2 mini](https://www.wemos.cc/en/latest/s2/s2_mini.html) board.
connect the GM-1352 to the S2 mini as follows:
- B+ to 5V: to power or get power from the device
- B- to GND: ground reference
- POWER to 16: to wake up the S2 when the device is powered (the S2 will shut down shortly after the GM-1352)
- DATA to 18: this will be the SPI MOSI line to read the measurments
- CS to 33: this will be the SPI CS line to identify transactions
- WR to 35: this will be the SPI SCK line to clock the data bits (not periodic)
I soldered wires to the pads, and broke them out on a 8-pin female header, located above the battery compartment.
this also to easily connect on row of the S2 mini to it on the back of the GM-1352.
now you can power the sound level meter through the S2 mini USB port, and read the measurements over its serial CDC ACM interface.
the firmware uses [ESP-IDF](https://github.com/espressif/esp-idf) [v5.0](https://docs.espressif.com/projects/esp-idf/en/v5.0/esp32s2/index.html).
See [getting started](https://docs.espressif.com/projects/esp-idf/en/v5.0/esp32s2/get-started/linux-macos-setup.html) to install the IDF.
once installed, load the IDF tools:
~~~
get_idf
~~~
to build the firmware:
~~~
idf.py build
~~~
note that the first time it will download additional components (such as [tinyUSB](https://git.cuvoodoo.info/kingkevin/espressif_tinyusb) and [esp_tinyusb](https://git.cuvoodoo.info/kingkevin/espressif_idf-extra-components/src/branch/esp_tinyusb_dfu/usb/esp_tinyusb)).
the firmware supports [USB DFU](https://usb.org/document-library/device-firmware-upgrade-11-new-version-31-aug-2004) flashing.
it is meant to be used along the [ESP32-S2 DFU mode firmware](https://git.cuvoodoo.info/kingkevin/esp32-s2_dfu).
Once the DFU mode firmware is installed (on the `factory` partition), you can flash this firmware (on the `ota0` partition) using `dfu-util`: