I’m a complete novice at this but I’m struggling to build an ESP-32D. I do have some other boards working so this one is a bit mysterious, especially as I had it working once but I can’t remember how!
Ideally I would like to build it using ESP Builder in Home Assistant but that fails. Attaching the board to my PC, and choosing ESP32 as the board, near the start of the install it fails, and I couldn’t find a log. Restarting it, and skipping ends up with with “InvalidJSONFile: Could not load broken JSON: /data/cache/platformio/packages/[email protected]+2021r2-patch5/.piopm” . I have no idea where to start with this - I’ve read threads which talk about deleting the platformio cache etc etc but I don’t think I have one! This is the generated yaml.
esphome:
name: test
friendly_name: test
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "x="
ota:
- platform: esphome
password: "x"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Test Fallback Hotspot"
password: "x"
captive_portal:
I also tried with esphome.io using the ready made project called empty ESPhome device which goes through erasing then installing then adding WiFiand that fails too.
Is it just that this board is not supported in those tools? If so, how can I build it?
It looks to me that a JSON file that has been cached in ESPHone is corrupt. Try cleaning the build files. Click the 3 dots and select Clean Build Files in the popup menu.
Thanks, that sounded really promising to me but that didn’t work. However you may be on the right track because along the way I have attached a new board , using another board I’ve bought (unused I believe) - a C6. Just for testing I skipped the step where you tell it where the board is connected and went to the menu and selected ESP32-C6, which is what it is. I get the message that the config is created with the encryption key. I choose manual install to “install it myself using ESPHome Web”, the log shows it starting then
INFO Reading configuration /config/esphome/lounge-new.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing lounge-new (board: esp32-c6-devkitc-1; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
UnknownBoard: Unknown board ID 'esp32-c6-devkitc-1'``
which is not the same error but makes me think something somewhere is broken, probably local to me. I’m not sure what I should delete though.
Or, I suppose, for some reason it’s not reaching the bit of the internet it needs. I have nothing in the way though, and a fast connection etc.
UPDATED TO ADD YAML
This defaults to framework type arduino which gives the error above. If I change that to esp-idf I get the same error as before
InvalidJSONFile: Could not load broken JSON: /data/cache/platformio/packages/[email protected]+2021r2-patch5/.piopm
And after deleting and reinstalling ESP Home Builder…
INFO ESPHome 2025.5.1
INFO Reading configuration /config/esphome/lounge2.yaml...
INFO Generating C++ source...
INFO Core config, version or integrations changed, cleaning build files...
INFO Compiling app...
Processing lounge2 (board: esp32-c6-devkitc-1; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Platform Manager: Installing platformio/espressif32 @ 5.4.0
INFO Installing platformio/espressif32 @ 5.4.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Platform Manager: [email protected] has been installed!
INFO [email protected] has been installed!
UnknownBoard: Unknown board ID 'esp32-c6-devkitc-1'
I was about the write that Arduino is the default platform in ESPHome and it’s a bit old and don’t support newer chips. Changing to esp-idf usually fixes that.
However, I think we’re dealing with two different issues. Are you still gettting the
InvalidJSONFile: Could not load broken JSON: /data/cache/platformio/packages/[email protected]+2021r2-patch5/.piopm
EDIT: Which I have now managed to get built but the log stops at “Starting scheduler on CPU0”… that was with a minimal yaml.
2nd Edit - yes Zenzay , quite likely two different problems but I mention all the facts in case they may be relevant (which rather clogs up the discussion). Btw the link you posted was where I found the arduino/esp framework idea - but thanks
I’ve done a lot of poking and prodding but the only significant thing I think was changing the cable and I now have a (nearly) successful build on the ESP 32D
I have changed the cable back and it doesn’t fail, even if I rerase the card, which might mean something else fixed it. I did reboot my PC at some point but I’ve had this problem for days so that can’t be it. Other than that I’m not sure what changed.
I’m just left with some non fatal messages in the log
[17:52:15][I][wifi:313]: WiFi Connecting to 'Geoffs WiFi'...
[17:52:15][W][wifi:674]: WiFi Unknown connection status 0
[17:52:15][I][wifi:313]: WiFi Connecting to 'Geoffs WiFi'...
[17:52:15][W][wifi_esp32:569][arduino_events]: Event: Disconnected ssid='Geoffs WiFi' bssid=[redacted] reason='Association Leave'
[17:52:17][I][wifi:617]: WiFi Connected!
and later
[17:52:18][W][component:167]: Component api set Warning flag: unspecified
then every minute
[17:52:26][W][api.connection:135]: : Socket operation failed: BAD_INDICATOR errno=11
[17:52:26][W][component:182]: Component api cleared Warning flag
[17:52:26][W][component:167]: Component api set Warning flag: unspecified1
But it seems to be reporting what I need it to, so I will look at these “in the fullness of time!!”
I hate not knowing or being able to say what fixed it but thanks for your help and tips
Why can’t that be it? The first question Help Desk asks you to do is reboot your computer.
You neglected to include the part of the log that shows all the networks the device can see and how strong they are. Many weird connectivity problems are caused by bad Wi-Fi. There are many reasons this could be.
As I implied, the computer has been rebooted many times during this investigation.
I chose to not include the whole log, it wasn’t neglect. I understand WiFi quality and had concluded that wasn’t the problem, so I chose to include the things I didn’t really understand that I thought might be helpful to troubleshooting. The logs are, as you probably know, massive and I felt the thread was already overblown in size.
So assume the WiFi is OK. Can you help please with the more likely of the many reasons which may cause this? Just the top five please, for the time being.
Thanks. I usually do try reboots and having read that I will bear it in mind for future issues. However in this case it’s not solved the problem but, as I said above, the board seems to be doing what I want it to so I’m moving on for a bit.
Rebooting the host Pi did however resolve another issue with rebuilding a C6, although that now also has a different error which doesn’t seem to impact but I will investigate.
Just fyi, it kind of helps that I have two Home Assistants on my network, in that I can go to each and see if they are logging the same errors. This is a temporary move really, brought about because to build OTA with ESP Home Builder I need an SSL connection, which my regular HA doesn’t have - I use Cloudflare.
Anyway, thanks for the link & suggestion, I’ll bear it in mind in future.