SOLVED ESPHome DS18B20 and MAX7219 7Segment

Hi,
i plan to build a Thermometer for my Pool, wich has 4 DS18B20 Sensors,
one for AIR-Temp,
one for POOL-Water,
one for Solar-Heater,
one for Fire-Heater.

The DS18B20 are already working fine.
I want to use 2xMAX7219 Boards with 8x7Segment each for displaying the Temps.
How can i get the Temp-Values directly in ESPHome to the MAX7219?

Here the code i would use:

esphome:
  name: pool_temp
  platform: ESP8266
  board: d1_mini

# Enable logging
#logger:

# Enable Home Assistant API
api:
  password: "xxxxxxxx"

ota:
  password: "xxxxxxxx"

wifi:
  networks:
  - ssid: "Cxxxxxxx2"
    password: "xxxxxxxx"
  - ssid: "Cxxxxxxx3"
    password: "xxxxxxxx"
  manual_ip:
    static_ip: 192.168.2.254
    gateway: 192.168.2.1
    subnet: 255.255.252.0

web_server:
  port: 80

dallas:
  - pin: GPIO05
    update_interval: 30s
  
sensor:
  - platform: dallas
    address: 0xdc000005948d4d28
    name: "Temp Air"
  - platform: dallas
    address: 0xa800000593ec1d28
    name: "Temp Pool"
  - platform: dallas
    address: 0x6f0000059411c728
    name: "Temp Solar"
  - platform: dallas
    address: 0xf500000594396728
    name: "Temp Fire"
spi:
  clk_pin: D0
  mosi_pin: D1

display:
  - platform: max7219
    cs_pin: 04
    num_chips: 2
    lambda: |-
      it.print("01234567ABCDEFGH");

so how can i display the 4 Temps on both displays?
It should look like this:
“_23.4_20.2”
“_27.9_75.2”
where the undescores are empty digits if temp <100.0 degree
(water wont be hotter than 99.9degree i hope :slight_smile: )
but if -10.0 degree the minus sign should be shown.

Isn’t this all in the page you pointed to?

yeah, i should have read before tho whole text on that site, sorry.

I have got it working as aspected!

Here the Code:

dallas:
  - pin: GPIO05
    update_interval: 3s
  
sensor:
  - platform: dallas
    address: 0xdc000005948d4d28
    name: "Temperature #1"
    id: "DS18B20_1"
  - platform: dallas
    address: 0xa800000593ec1d28
    name: "Temperature #2"
    id: "DS18B20_2"
  - platform: dallas
    address: 0x6f0000059411c728
    name: "Temperature #3"
    id: "DS18B20_3"
  - platform: dallas
    address: 0xf500000594396728
    name: "Temperature #4"
    id: "DS18B20_4"

spi:
  clk_pin: 14
  mosi_pin: 13

display:
  - platform: max7219
    cs_pin: 04
    num_chips: 2
    intensity: 7
    lambda: |-
      it.printf(0, " ");
      it.printf(1, "%.1f", id(DS18B20_1).state);
      it.printf(4, " ");
      it.printf(5, "%.1f", id(DS18B20_2).state);
      it.printf(8, " ");
      it.printf(9, "%.1f", id(DS18B20_3).state);
      it.printf(12, " ");
      it.printf(13, "%.1f", id(DS18B20_4).state);

So far is everything fine, all 4 Temps are shown on the 7Segments.

1 Like