# Badger 2040W and ESPHome/Home Assistant

**URL:** <https://forums.pimoroni.com/t/badger-2040w-and-esphome-home-assistant/26635>\
**Category:** Support\
**Created:** [November 26, 2024, 5:59pm UTC](https://forums.pimoroni.com/t/badger-2040w-and-esphome-home-assistant/26635 "2024-11-26T17:59:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisThomas42](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@ChrisThomas42](https://forums.pimoroni.com/u/ChrisThomas42)\
**Post date:** [November 26, 2024, 5:59pm UTC](https://forums.pimoroni.com/t/badger-2040w-and-esphome-home-assistant/26635/1 "2024-11-26T17:59:11Z")

</div>

Hello Everyone!  
Some time ago I was gifted a Badger 2040W and tinkered with it for a while and it’s been in the drawer ever since. Recently I thought I could maybe use it with my home automation, specifically Home Assistant and ESPHome.

It was relatively easy to get the Pico configured and all the buttons and LEDs are controllable in ESPHome. However for the life of me I cannot get the display to work. I’ve poured over the schematic for the Badger and assigned pins, checked if they’re active low. Tried different versions of the Inky display but only a black screen, nothing other than a black screen.

I’ve defined these pins:  
clk\_pin: GPIO18,  
mosi\_pin: GPIO19  
miso\_pin: GPIO16  
cs\_pin: GPIO17  
dc\_pin: GPIO20  
busy\_pin: GPIO26  
reset\_pin: GPIO21  
button\_a: GPIO12  
button\_b: GPIO13  
button\_c: GPIO14  
button\_down: GPIO11  
button\_up: GPIO15  
badger\_led: GPIO22  
pico\_led: GPIO32

If I put the Badger firmware back on then it all works fine so it appears that I’ve not damaged anything, at least so far.

Can anyone shed any light of any mistake I’ve made in the pin definitions and their active state, plus what the model of the display is?

Chris

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [November 26, 2024, 6:38pm UTC](https://forums.pimoroni.com/t/badger-2040w-and-esphome-home-assistant/26635/2 "2024-11-26T18:38:12Z")

</div>

I have not checked the GPIOs you listed here, I think you can do that with the schematic provided on the product page.

It is not clear what program/firmware you are running on the Badger2040W. This is important because the display needs special commands during initialization.

---

<div class="post-metadata">

**Author:** ![ChrisThomas42](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@ChrisThomas42](https://forums.pimoroni.com/u/ChrisThomas42)\
**Post date:** [November 26, 2024, 7:22pm UTC](https://forums.pimoroni.com/t/badger-2040w-and-esphome-home-assistant/26635/3 "2024-11-26T19:22:42Z")

</div>

Hi @bablokb,  
I’m using ESPHome and it has “components” for the processor and the peripherals. I have successfully configured and used the board with the GPIO on the Badger. The pin assignments for the buttons and LEDs I got from the schematic and all of those work.

The component for the waveshare display is configured with the SPI bus and the display as follows;

spi:  
clk\_pin: GPIO18  
mosi\_pin: GPIO19  
miso\_pin: GPIO16 # might not be needed?

display:

- platform: waveshare\_epaper  
id: badger\_w  
cs\_pin:  
number: GPIO17  
inverted: true  
dc\_pin: GPIO20  
busy\_pin:  
number: GPIO26  
inverted: true  
reset\_pin:  
number: GPIO21  
inverted: true  
rotation: 270  
model: 2.90inv2

I can’t find anywhere the specific model of the display used, in ESPHome there are 6 different 2.9 inch display types listed. I’ve tried almost every combination with no luck.

It could just be as you say, the ESPHome component just does not initialise the part correctly.

More reading…

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [November 26, 2024, 7:54pm UTC](https://forums.pimoroni.com/t/badger-2040w-and-esphome-home-assistant/26635/4 "2024-11-26T19:54:28Z")

</div>

> [@ChrisThomas42](#):
>
> It could just be as you say, the ESPHome component just does not initialise the part correctly.

That is exactly my experience: I tried to use the display with standard CircuitPython drivers, but it turned out the display needed some very special handling.

---

<div class="post-metadata">

**Author:** ![ChrisThomas42](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@ChrisThomas42](https://forums.pimoroni.com/u/ChrisThomas42)\
**Post date:** [November 26, 2024, 8:12pm UTC](https://forums.pimoroni.com/t/badger-2040w-and-esphome-home-assistant/26635/5 "2024-11-26T20:12:59Z")

</div>

It’s been a LONG time since I did any really programming, but I might see if I can find the source for the display initialisation in the Badger code. ESPHome is all open source and I know how to find that. The issue is will I be able to make ANY sense of either and come up with a fix that will work?

Still need to find the exact model of the display used on the Badger though.

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [November 26, 2024, 8:23pm UTC](https://forums.pimoroni.com/t/badger-2040w-and-esphome-home-assistant/26635/6 "2024-11-26T20:23:46Z")

</div>

Have a look here: [pimoroni-pico/drivers/uc8151/uc8151.cpp at main · pimoroni/pimoroni-pico · GitHub](https://github.com/pimoroni/pimoroni-pico/blob/main/drivers/uc8151/uc8151.cpp)

But even if you know that it is a UC8151 driver-chip, this will not imply that it works with other UC8151 drivers.

One other cause of problems: during boot, you have to pull GPIO10 high and keep it high.
