ESPHOME MAX7219 with dot-matrix

Hi,

after i setup a ESP with MAX7219 and 7Segment-Displays i wanted to try MAX7219 with 4 DotMatrix Displays but even in the first democode i get compiling errors.

Her my code:

time:
  - platform: homeassistant
    id: hass_time

spi:
  clk_pin: 14
  mosi_pin: 13

display:
  - platform: max7219
    id: display_max
    cs_pin: 15
    num_chips: 4
    intensity: 1
    lambda: |-
      it.print(0, 0, id(digit_font), "HELLO!");

font:
  - file: D:\Home-Assistant\common\lcd.ttf
    id: digit_font
    size: 6

and

time:
  - platform: homeassistant
    id: hass_time

spi:
  clk_pin: 14
  mosi_pin: 13

display:
  - platform: max7219
    id: display_max
    cs_pin: 15
    num_chips: 4
    intensity: 1
    lambda: |-
      it.strftime(0, 0, id(digit_font), "%H:%M", id(hass_time).now());

font:
  - file: D:\Home-Assistant\common\lcd.ttf
    id: digit_font
    size: 6

i get this error-logs from esphome:

Building in release mode
Compiling .pioenvs\matrix-anzeige\src\main.cpp.o
Compiling .pioenvs\matrix-anzeige\FrameworkArduino\spiffs\spiffs_hydrogen.cpp.o
Compiling .pioenvs\matrix-anzeige\FrameworkArduino\spiffs\spiffs_nucleus.cpp.o
Compiling .pioenvs\matrix-anzeige\FrameworkArduino\spiffs_api.cpp.o
Compiling .pioenvs\matrix-anzeige\FrameworkArduino\sqrt32.cpp.o
Q:\ESP_max7219matrix.yaml: In lambda function:
Q:\ESP_max7219matrix.yaml:41:42: error: no matching function for call to 'esphome::max7219::MAX7219Component::print(int, int, esphome::display::Font*&, const char [7])'
   41 |       it.print(0, 0, id(digit_font), "HELLO!");
      |                                          ^
In file included from src\esphome.h:22,
                 from src\main.cpp:3:
src\esphome\components\max7219\max7219.h:45:11: note: candidate: 'uint8_t esphome::max7219::MAX7219Component::print(uint8_t, const char*)'
   45 |   uint8_t print(uint8_t pos, const char *str);
      |           ^~~~~
src\esphome\components\max7219\max7219.h:45:11: note:   candidate expects 2 arguments, 4 provided
src\esphome\components\max7219\max7219.h:47:11: note: candidate: 'uint8_t esphome::max7219::MAX7219Component::print(const char*)'
   47 |   uint8_t print(const char *str);
      |           ^~~~~
src\esphome\components\max7219\max7219.h:47:11: note:   candidate expects 1 argument, 4 provided
Compiling .pioenvs\matrix-anzeige\FrameworkArduino\stdlib_noniso.cpp.o
Compiling .pioenvs\matrix-anzeige\FrameworkArduino\time.cpp.o
*** [.pioenvs\matrix-anzeige\src\main.cpp.o] Error 1
============================================== [FAILED] Took 5.48 seconds =============================================

how can i fix this?

Ohhh, after about one day of trying if found the error!
It is sitting in front of the monitor! :frowning:

My mistake was:

display:
  - platform: max7219   <--------------------

and it must be

display:
  - platform: max7219digit   <--------------

for the dotmatrix!

Now i can compile!
I use ARIAL as font, but this doesn’t look good, does anyone know wich font would be suitable for the Dot-Matrix?

And i wonder why the displayed time always starts at 01:00 ?
Do i have to assign something in HA?

I use this and think it looks okay.

font:
  - file: "pixelmix.ttf"
    id: digit_font8
    size: 8
  - file: "pixelmix.ttf"
    id: digit_font6
    size: 6
    glyphs:
    - ' '
    - '@'
    - '*'
    - '!'
    - '"'
    - '%'
    - '&'
    - (
    - )
    - +
    - ','
    - '-'
    - .
    - '0'
    - '1'
    - '2'
    - '3'
    - '4'
    - '5'
    - '6'
    - '7'
    - '8'
    - '9'
    - ':'
    - A
    - B
    - C
    - D
    - E
    - F
    - G
    - H
    - I
    - J
    - K
    - L
    - M
    - N
    - O
    - P
    - Q
    - R
    - S
    - T
    - U
    - V
    - W
    - X
    - Y
    - Z
    - _
    - a
    - b
    - c
    - d
    - e
    - f
    - g
    - h
    - i
    - j
    - k
    - l
    - m
    - n
    - o
    - p
    - q
    - r
    - s
    - t
    - u
    - v
    - w
    - x
    - y
    - z
    - °

You will have to download the font package. Some place like https://www.wfonts.com/font/pixelmix and include it in your ESPHOME directory.

oh thank you for that link!
Yes, this definitly looks really good!

Only one thing i don’t get, why starts the “clock” always at 01:00:00 ?
It should get the time form HA!
in configuration.yaml i have:

sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_utc'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'

I pull HA time with this.

time:
  - platform: homeassistant
    id: hass_time
    timezone: EST+5EDT,M3.2.0/2,M11.1.0/2 

Display it with

            it.strftime(0, 0, id(digit_font8), "%I:%M", id(hass_time).now()); 

ok, thank you, that works, but i found another variant to get time:

time:
  - platform: sntp
    id: sntp_time
    servers: 192.168.2.1

Where 192.168.2.1 is my fritz!box.

Now i try to display my pool_water_temp, but i get strange full dot-display:

sensor:
  - platform: homeassistant
    name: "Pool Wasser Temp"
    id: "wasser_temp"
    entity_id: "sensor.temperature_2_2"

spi:
  clk_pin: 14
  mosi_pin: 13

display:
  - platform: max7219digit
    id: display_max
    cs_pin: 15
    num_chips: 8
    rotate_chip: 0
    intensity: 0
    lambda: |-
      it.strftime(0, 0, id(digit_font8), "%H:%M:%S", id(sntp_time).now());
      it.printf(33, 0, id(digit_font8), "%s", id(wasser_temp));

do you know how to display the temp?

i have tried this:

sensor:
  - platform: homeassistant
    name: "POOL Wasser Temp"
    id: "pool_wasser_temp"
    entity_id: "sensor.temperature_2_2"

display:
  - platform: max7219digit
    id: display_max
    cs_pin: 15
    num_chips: 8
    rotate_chip: 0
    intensity: 0
    lambda: |-
      it.strftime(0, 0, id(digit_font8), TextAlign::TOP_LEFT, "%H:%M:%S", id(sntp_time).now());
      if (id(pool_wasser_temp).has_state()) 
      {
        it.printf(65, 0, id(digit_font6), TextAlign::TOP_RIGHT, "%.1f°C", id(pool_wasser_temp).state);
      }

but i don’t get the temperature.
If i let it run without the IF, i get “nan°C” on display.
On the log i just see this, but no more:

[20:53:08][C][mdns:085]:   Hostname: matrix-anzeige
[20:53:08][C][ota:085]: Over-The-Air Updates:
[20:53:08][C][ota:086]:   Address: 192.168.2.255:8266
[20:53:08][C][ota:089]:   Using Password.
[20:53:08][C][api:138]: API Server:
[20:53:08][C][api:139]:   Address: 192.168.2.255:6053
[20:53:08][C][api:143]:   Using noise encryption: NO
[20:53:08][C][sntp:050]: SNTP Time:
[20:53:08][C][sntp:051]:   Server 1: '192.168.2.1'
[20:53:08][C][sntp:052]:   Server 2: ''
[20:53:08][C][sntp:053]:   Server 3: ''
[20:53:08][C][sntp:054]:   Timezone: 'CET-1CEST,M3.5.0,M10.5.0/3'
[20:53:08][C][homeassistant.sensor:030]: Homeassistant Sensor 'POOL Wasser Temp'
[20:53:08][C][homeassistant.sensor:030]:   State Class: ''
[20:53:08][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[20:53:09][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[20:53:09][C][homeassistant.sensor:031]:   Entity ID: 'sensor.temperature_2_2'

but the sensor is working!

Not an expert but I noticed you have quotes while my definition does not.

sensor:
  - platform: homeassistant
    name: "Outside Temperature"
    id: outside_temp
    entity_id: sensor.rear_porch_motion_air_temperature
    internal: True
    on_value:
      then:
        - component.update: max7219digitdisplay

i just tried that, but it stays the same.
What does your code:

    on_value:
      then:
        - component.update: max7219digitdisplay

?
Could you show your whole code?

this is mine:

time:
  - platform: homeassistant
    id: hass_time
    timezone: CET-1CEST,M3.5.0,M10.5.0/3    

spi:
  clk_pin: 14
  mosi_pin: 13


sensor:
  - platform: homeassistant
    name: "POOL Wasser Temp"
    id: pool_wasser_temp
    entity_id: sensor.temperature_2_2
    internal: true
  - platform: homeassistant
    name: "POOL Luft Temp"
    id: pool_luft_temp
    entity_id: sensor.temperature_1_2
    internal: true

display:
  - platform: max7219digit
    id: display_max
    cs_pin: 15
    num_chips: 12
    rotate_chip: 0
    update_interval: 100ms
    intensity: 0
    lambda: |-
      it.strftime(0, 0, id(digit_font8), "%H:%M:%S", id(hass_time).now());
      if (id(pool_wasser_temp).has_state())
      { 
        it.printf(68, 0, id(digit_font6), TextAlign::TOP_RIGHT, "%.1f°C", id(pool_wasser_temp).state);
      }
      if (id(pool_luft_temp).has_state()) 
      {
        it.printf(97, 0, id(digit_font6), TextAlign::TOP_RIGHT , "%.1f°C", id(pool_luft_temp).state);
      }

# Font muss in D:\Home-Assistant\common sein!
font:
  - file: D:\Home-Assistant\common\pixelmix.ttf
    id: digit_font8
    size: 8
  - file: D:\Home-Assistant\common\pixelmix.ttf
    id: digit_font6
    size: 7
    glyphs:
    - ' '
    - '@'
    - '*'
    - '!'
    - '"'
    - '%'
    - '&'
    - (
    - )
    - +
    - ','
    - '-'
    - .
    - '0'
    - '1'
    - '2'
    - '3'
    - '4'
    - '5'
    - '6'
    - '7'
    - '8'
    - '9'
    - ':'
    - A
    - B
    - C
    - D
    - E
    - F
    - G
    - H
    - I
    - J
    - K
    - L
    - M
    - N
    - O
    - P
    - Q
    - R
    - S
    - T
    - U
    - V
    - W
    - X
    - Y
    - Z
    - _
    - a
    - b
    - c
    - d
    - e
    - f
    - g
    - h
    - i
    - j
    - k
    - l
    - m
    - n
    - o
    - p
    - q
    - r
    - s
    - t
    - u
    - v
    - w
    - x
    - y
    - z
    - °
    

1 Like

So, everything is working now!
My mistake (again) i made:

Because this esp is new, i simply forgot to register it in HomeAssistant!
:frowning: :skull: :woozy_face:
Sorry for stealing your time, but sometime the simplest things can turn out in worst cases…
Better i get more sleep…

Thank you!