Initial setup guide - dalathegreat/Battery-Emulator GitHub Wiki
How to compile the software 💻
- Download the Arduino IDE: https://www.arduino.cc/en/software
- Open the Arduino IDE.
- Click
File
menu ->Preferences
->Additional Development
->Additional Board Manager URLs
-> Enter the URL in the input box:https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
and click OK. - Click
Tools
menu ->Board: "...."
->Boards Manager...
, install theesp32
package byEspressif Systems
(notArduino ESP32 Boards
), then pressClose
.
NOTE: The version depends on which release of Battery-Emulator you are running!
- ⚠️ Make sure to use a 2.x.x version if you are on a release older than 6.0.0 (For instance ESP32 v2.0.11 when using Battery-Emulator v5.4.0)
- ⚠️ Make sure to use a 3.x.x version if you are on a release newer than 6.0.0 (For instance ESP32 v3.0.0 when using Battery-Emulator v6.0.0)
- The Arduino board should be set to
ESP32 Dev Module
(underTools
->Board
->ESP32 Arduino
) with the following settings: - Select which battery type you will use, along with other optional settings. This is done in the
USER_SETTINGS.h
file. - Press
Verify
andUpload
to send the sketch to the board. NOTE: In some cases, the LilyGo must be powered through the main power connector instead of USB-C when performing the initial firmware upload. NOTE: On Mac, the following USB driver may need to be installed: https://github.com/WCHSoftGroup/ch34xser_macos
NOTE: If you see garbled messages on the serial console, change the serial console to match the baud rate to the code, currently 115200.
This video explains all the above mentioned steps: https://youtu.be/_mH2AjnAjDk
Linux Development Environment Setup
In addition to the steps above, ESP32 requires a dependency for a Python module, pyserial install using the cli.
python3 -m pip install pyserial
If you're using Ubuntu , use apt to manage the dependencies of arduino:
pyserial install: sudo apt install python3-serial
Arduino AppImage must be set as executable after downloading to run correctly
example: chmod 775 arduino-ide_2.3.3_Linux_64bit.AppImage
Troubleshooting Guide: Flashing Issues on ESP32 (WINDOWS)
Step 1: Confirm Serial Connection
-
Verify Connection Status: Ensure the ESP32 is properly connected to your computer via a USB-C cable that supports both data and power transmission. Using a power-only cable is a common error and will prevent data transfer.
-
Check Serial Output: When connected, the ESP32 should provide output similar to the following when reset:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc
-
To perform this test; Using Arduino IDE:
- Open the Serial Monitor in Arduino IDE.
- Set the baud rate to 115200 (the default baud rate for ESP32).
- Press the reset button on the ESP32. If connected correctly, this should trigger output every time the reset button is pressed.
Step 2: Install Necessary Drivers and Confirm Port Configuration
- Install USB-Serial Drivers (Windows): If using Windows, ensure you have installed the USB-Serial drivers to allow communication with the ESP32:
- Download CH340 USB-Serial Drivers CH340 drivers are common for ESP32 boards
- Verify COM Port in Device Manager:
- Open Device Manager and locate the COM port associated with your ESP32. It should appear similar to the image shown below:
Confirm that the port number matches the one selected in the Arduino IDE.