Badger 2040W and ESPHome/Home Assistant

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

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.

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…

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.

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.

Have a look here: pimoroni-pico/drivers/uc8151/uc8151.cpp at main · pimoroni/pimoroni-pico · GitHub

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.