This is probably my last devlog, but here’s a quick demonstration of the menu and module detection. Module is detected like this:
- The main MCU in the power bank senses that something has been connected.
- Power bank sends 0x00 over UART which tells the module to send its ID. If it doesn’t get a response after retrying for 10 times, it assumes the connected device isn’t a module.
- Module sends its ID to the power bank.
Then depending on the ID the power bank can show something on its screen or send battery information to the module.
It took me hours to get the communication working because the arduino failed to get the ID (It was constantly returning 0 which means no module). At first, I thought the problem was that I used voltage dividers to convert the logic voltage (Needed to convert it because the ESP32-C3 runs at 3.3V, but the Arduino nano clone at 5V). So I soldered together a logic level shifter, it still didn’t work. Then I thought maybe I had damaged the UART interface on the ESP because I accidentally connected 5V to the TX pin once. So I tried a different ESP32 and it still didn’t work. I then found that the problem was that I had set dummy_receiver to true in the ESPHome YAML. I set it to false and it worked.
Next I will change the menu a bit.