Trouble writing sensor value. printf MAX7219

In the code below, if I include the basic “it.print(“8765432”);”
8765432 is written to the max7219 segment display and all sensor states are available in home assistant. If I substitute that printf statement with the one that is commented out below, the file compiles and loads but the Log never starts.

I’ve looked at several examples and through the documentation but I can’t find my mistake.

Thanks for any help!

# Name the device and include libraries used
esphome:
  name: co2_monitor

# Specify what type of controller board is being used
esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  services:
    - service: mhz19_calibrate_zero
      then:
        - mhz19.calibrate_zero: garage_co2

# MH-Z19 CO2 monitgor setup
uart:
  - id: co2_uart
    rx_pin: GPIO16
    tx_pin: GPIO17
    baud_rate: 9600
  - id: prop_uart
    rx_pin: GPIO9
    tx_pin: GPIO10
    baud_rate: 9600

sensor:
  - platform: mhz19
    id: "garage_co2"
    co2:
      name: "MH-Z19 CO2 Value"
      id: "co2_value"
    temperature:
      name: "MH-Z19 Temperature"
      id: "temp_value"
    update_interval: 5s
    automatic_baseline_calibration: true
    uart_id: co2_uart

# Example configuration entry
spi:
  clk_pin: GPIO13
  mosi_pin: GPIO14

display:
  - platform: max7219
    cs_pin: GPIO12
    num_chips: 1
    lambda: |-
       it.print("8765432");
#      it.printf(0,1,"%.0f", id(co2_value).state);

# Set a password to update the controller over the wifi
ota:
  password: !secret ota_password

# Setup the wifi networds that will be used
wifi:
  networks:
  - ssid: !secret wifi_ssid_house
    password: !secret wifi_password_house
  - ssid: !secret wifi_ssid_farm
    password: !secret wifi_password_farm
  
# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "co2monitor"
    password: !secret ap_password
      
# Tell controller where to get the current time
time:
  - platform: homeassistant
    id: homeassistant_time
  
# Set up MQTT this will allow us to wake up the controller to send updated code
mqtt:
  broker: '10.0.0.59'
  username: !secret mqtt_user
  password: !secret mqtt_password
  discovery: false
  discovery_retain: false

# Tell the controller our location so it can determine sunrise and sunset
sun:
  latitude: 37.291700°
  longitude: -95.909630

If I look at the documentation, I think your it.printf statement contains the wrong number of arguments. It should contain: 1) the position, 2) the mask, 3) the value to be printed. So what happens if you change it to:

it.printf(0, "%.0f", id(co2_value).state);

Jos

You are 100% right. I stumbled on that yesterday evening and it immediately began working.

I’m a little surprised the it.printf caused the entire device to fail rather than maybe just the 7 seg display portion.

Thanks

Joel