surfing_spider

pizza_oven_sensor.yaml

May 8th, 2021 (edited)
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 7.06 KB | None | 0 0
  1. ### Pizza Oven Temperature sensor ###
  2.  
  3.  
  4. ##OLED Fonts ### you will need to download the ttf font for the OLED display and place them in your esphome config dir e.g //homeassistants/config/esphome
  5. # slkscr.ttf - https://www.dafont.com/silkscreen.font
  6. # BebasNeue-Regular.ttf - https://www.dafont.com/bebas-neue.font
  7. # arial.ttf - https://www.dafont.com/bebas-neue.font?text=arial.ttf
  8.  
  9. ## Parts used ###
  10. #£14.50 MakerHawk ESP32 Module OLED Display WiFi Development Board WIFI Kit 32 Low Power Consumption 240 MHZ Dual Core with CP2012 Chip 0.96inch Display ( https://www.amazon.co.uk/gp/product/B076P8GRWV/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1 )
  11. #£7.88   SNOWINSPRING 1 Set Max6675 Module + K Type Thermocouple Sensor Module for & 1Pcs K Type 50X5Mm 800C Probe Thermocouple ( https://www.amazon.co.uk/dp/B08HQ81MVH/ref=cm_sw_em_r_mt_dp_ZCKQDF06XT6TAQXFFYPH )
  12.  
  13. ## Resources ##
  14. # https://resource.heltec.cn/download/WiFi_Kit_32/WIFI_Kit_32_pinoutDiagram_V2.pdf
  15. # https://esphome.io/components/sensor/max6675.html?highlight=max6675
  16.  
  17. ## Wiring of the esp32 to the sensor ###
  18. # esp32 pin GND to max6675 gnd
  19. # esp32 pin 3.3v to max6675 vcc  (104nf cap between vcc & gnd)
  20. # esp32 pin 2 (cs) to max6675 (CS)
  21. # esp32 pin 18 (SCK) to max6675 (SCK)
  22. # esp32 pin 19 (miso) to max6675 (SO)
  23.  
  24. ## Thingiverse Files for Case
  25. # https://www.thingiverse.com/thing:4855762
  26.  
  27.  
  28. esphome:
  29.   name: pizza_oven_sensor
  30.   platform: ESP32
  31.   board: heltec_wifi_kit_32
  32.  
  33. wifi:
  34.   networks:
  35.   - ssid: !secret wifi_ssid   # Home Wifi details
  36.     password: !secret wifi_password
  37.   - ssid: !secret wifi_ssid2  # Mobile Phone hotspot for when out of range of home wifi        
  38.     password: !secret wifi_password2
  39.   - ssid: !secret wifi_ssid3  # TP-Link Wifi Extender
  40.     password: !secret wifi_password3
  41.  
  42.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  43.   ap:
  44.     ssid: "Pizza Oven Sensor"
  45.     password: "YsP2eRCdRPPK"
  46.  
  47. captive_portal:
  48. # Enable logging
  49. logger:
  50. # Enable Home Assistant API
  51. # api:
  52.  
  53. # MQTT settings instead of using the normal api because the area I use the pizza oven has poor WiFi coverage so I can use my phone to connect to my MQTT from outside my LAN. If you don't have this problems (comment out this sections and uncomment out "api:"" if you have both you get repeated device restarts)
  54. mqtt:
  55.   broker: !secret mqtt_broker
  56.   username: !secret mqtt_username
  57.   password: !secret mqtt_password
  58.   discovery_retain: false
  59.  
  60. ota:
  61. sensor:
  62. ### Wifi Signal Strength  ####
  63.   - platform: wifi_signal
  64.     name: "Pizza Oven Sensor WiFi Signal"
  65.     update_interval: 30s
  66.     id: wifisignal
  67.  
  68. ### current Thermocouple sensor ###
  69.   - platform: max6675
  70.     name: "Pizza Oven Temperature"
  71.     accuracy_decimals: 0
  72.     cs_pin: 2
  73.     update_interval: 2s
  74.     filters: # filter used to smooth out sensor data noise
  75.       - sliding_window_moving_average:
  76.           window_size: 10
  77.           send_every: 10
  78.       - calibrate_linear: # Map 0.0 (from sensor) to 0.0 (true value)
  79.           # - 7.2 -> 0.0 # Iced water
  80.           - 24 -> 20 # Room Temp
  81.           - 103.0 -> 100 # Water @ Rolling Boil
  82. ### current Thermocouple sensor ###
  83.   - platform: max6675
  84.     name: "Pizza Oven Temperature Display"
  85.     accuracy_decimals: 0
  86.     cs_pin: 2
  87.     update_interval: 1s
  88.     id: thermocouple
  89.     internal: true
  90.     filters: # filter used to smooth out sensor data noise
  91.       #- sliding_window_moving_average:
  92.       #    window_size: 10
  93.       #    send_every: 10
  94.       - calibrate_linear: # Map 0.0 (from sensor) to 0.0 (true value)
  95.           # - 7.2 -> 0.0 # Iced water
  96.           - 24 -> 20 # Room Temp
  97.           - 103.0 -> 100 # Water @ Rolling Boil
  98.  
  99. ## Minimum Temp over 10mins
  100.   - platform: max6675
  101.     name: "Pizza Oven Temperature - Minimum"
  102.     accuracy_decimals: 0
  103.     cs_pin: 2
  104.     update_interval: 20s
  105.     id: thermocouple_min
  106.     filters:
  107.       - min:
  108.           window_size: 60  ## min in 10 minutes (10mins*60seconds / Update interval 10s)
  109.           send_every: 1
  110.       - calibrate_linear: # Map 0.0 (from sensor) to 0.0 (true value)
  111.           # - 7.2 -> 0.0 # Iced water
  112.           - 24 -> 20 # Room Temp
  113.           - 103.0 -> 100 # Water @ Rolling Boil
  114. ## Maximum Temp over 10mins
  115.   - platform: max6675
  116.     name: "Pizza Oven Temperature - Maximum"
  117.     accuracy_decimals: 0
  118.     cs_pin: 2
  119.     update_interval: 20s
  120.     id: thermocouple_max
  121.     filters:
  122.       - max:
  123.           window_size: 60  ## max in 10 minutes (10mins*60seconds / Update interval 10s)
  124.           send_every: 1
  125.       - calibrate_linear: # Map 0.0 (from sensor) to 0.0 (true value)
  126.           # - 7.2 -> 0.0 # Iced water
  127.           - 24 -> 20 # Room Temp
  128.           - 103.0 -> 100 # Water @ Rolling Boil
  129.          
  130. spi:
  131.   miso_pin: 19
  132.   clk_pin: 18
  133.  
  134. # add fonts for OLED Display
  135. font:
  136.   - file: 'slkscr.ttf'
  137.     id: font1
  138.     size: 8
  139.  
  140.   - file: 'BebasNeue-Regular.ttf'
  141.     id: font2
  142.     size: 40
  143.  
  144.   - file: 'arial.ttf'
  145.     id: font3
  146.     size: 12  
  147.    
  148.   - file: 'materialdesignicons-webfont.ttf'
  149.     id: icon_font
  150.     size: 20
  151.     glyphs: [
  152.       # Wifi signal strength icons
  153.       '󰤯', # mdi-wifi-strength-outline
  154.       '󰤟', # mdi-wifi-strength-1
  155.       '󰤢', # mdi-wifi-strength-2
  156.       '󰤥', # mdi-wifi-strength-3
  157.       '󰤨', # mdi-wifi-strength-4
  158.     ]
  159.  
  160. ### OLED Setup ###
  161. i2c:
  162.   sda: 4
  163.   scl: 15
  164.  
  165. display:
  166.   - platform: ssd1306_i2c
  167.     model: "SSD1306 128x64"
  168.     reset_pin: 16
  169.     address: 0x3C
  170.     lambda: |-
  171.  
  172.       // Print Pizza Oven Temp (from thermocouple sensor)
  173.       if (id(thermocouple).has_state()) {
  174.         it.printf(128, 60, id(font2), TextAlign::BASELINE_RIGHT , "%.1f°C", id(thermocouple).state);
  175.       }
  176.  
  177.       // Print Maximum temperature
  178.       if (id(thermocouple_max).has_state()) {
  179.         it.printf(127, 10, id(font3), TextAlign::TOP_RIGHT , "Max:%.0f°C", id(thermocouple_max).state);
  180.       }
  181.       // Print Minimum temperature
  182.       if (id(thermocouple_min).has_state()) {
  183.         it.printf(0, 10, id(font3), TextAlign::TOP_LEFT , "Min:%.0f°C", id(thermocouple_min).state);
  184.       }
  185.  
  186.       // Draw the outline of a rectangle with the top left at [50,60], a width of 30 and a height of 42
  187.       it.rectangle(0, 0, 128, 10);
  188.  
  189.       // Print "Pizza Oven Temp" in top center.
  190.       it.printf(64, 1, id(font1), TextAlign::TOP_CENTER, "Pizza Oven Temperature");
  191.  
  192.       // WiFi signal strength icon
  193.       int x, y;
  194.       if(id(wifisignal).has_state()) {
  195.         // Set location of Wifi Signal Icon
  196.         x = 0, y = 44;
  197.         if (id(wifisignal).state >= -50) {
  198.             //Excellent
  199.             it.print(x, y, id(icon_font), "󰤨");
  200.         } else if (id(wifisignal).state  >= -60) {
  201.             //Good          
  202.             it.print(x, y, id(icon_font), "󰤥");
  203.         } else if (id(wifisignal).state  >= -67) {
  204.             //Fair
  205.             it.print(x, y, id(icon_font), "󰤢");
  206.         } else if (id(wifisignal).state  >= -70) {
  207.             // Weak
  208.             it.print(x, y, id(icon_font), "󰤟");
  209.         } else {
  210.             // Unlikely
  211.             it.print(x, y, id(icon_font), "󰤯");
  212.         }
  213.       }
Add Comment
Please, Sign In to add comment