Jun 10, 2023 - Garage Door Sensor

This is an adaptation of Jeff Geerling’s garage door sensor project. My adaptation adds two temperature sensors and a display.

screenshotOne

Code

---
esphome:
  name: garage-door-temp-display-pico

rp2040:
  board: rpipicow
  framework:
    # Required until https://github.com/platformio/platform-raspberrypi/pull/36 is merged
    platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true

api:
  encryption:
   key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

logger:
  level: DEBUG

output:
  # Built-in LED
  - platform: gpio
    pin:
      number: 32  # 25 for Pico (non-W)
      mode: output
    id: LED

binary_sensor:
  # East Garage Door
  - platform: gpio
    pin:
      number: 14
      mode:
        input: true
        pullup: true
        output: false
        open_drain: false
        pulldown: false
      inverted: false
    name: East Garage Door
    id: east_garage_door
    device_class: garage_door
    filters:
      - delayed_on: 10ms
    disabled_by_default: false
    publish_initial_state: true
    on_state:
      then:
        - if:
            condition:
              or:
                - binary_sensor.is_on: east_garage_door
                - binary_sensor.is_on: west_garage_door
            then:
              - output.turn_on: LED
            else:
              - output.turn_off: LED

  # West Garage Door
  - platform: gpio
    pin:
      number: 15
      mode:
        input: true
        pullup: true
        output: false
        open_drain: false
        pulldown: false
      inverted: false
    name: West Garage Door
    id: west_garage_door
    device_class: garage_door
    filters:
      - delayed_on: 10ms
    disabled_by_default: false
    publish_initial_state: true
    on_state:
      then:
        - if:
            condition:
              or:
                - binary_sensor.is_on: east_garage_door
                - binary_sensor.is_on: west_garage_door
            then:
              - output.turn_on: LED
            else:
              - output.turn_off: LED


# temperature
# Example configuration entry
dallas:
  - id: garage_temp_bus
    pin: GPIO18
  - id: outside_temp_bus
    pin: GPIO26 

# Individual sensors
sensor:
  - platform: dallas
    address: 0x0000000000000000
    name: "Garage Temperature"
    dallas_id: garage_temp_bus
    id: garage_temp
  - platform: dallas
    address: 0x1111111111111111
    name: "Outside Temperature"
    dallas_id: outside_temp_bus
    id: outside_temp

font:
  - file: "fonts/Roboto-Black.ttf"
    id: roboto
    size: 15
i2c:
  sda: GPIO20
  scl: GPIO21

display:
  - platform: ssd1306_i2c
    model: "SH1106 128x64"
    rotation: 180 
      #    reset_pin: 0
    address: 0x3C
    lambda: |-
      if (id(garage_temp).has_state()) {
        it.printf(0, 0, id(roboto),"Garage: %.1f°F", id(garage_temp).state*9/5+32);
      }
      if (id(outside_temp).has_state()) {
        it.printf(0, 16, id(roboto),"Outside: %.1f°F", id(outside_temp).state*9/5+32);
      }
      it.printf(0, 31, id(roboto), "East Door: %s", id(east_garage_door).state);
      it.printf(0, 46, id(roboto), "West Door: %s", id(west_garage_door).state);

Install Esphome

Install the following python packages

pip3 install wheel
pip3 install esphome

Flash Procedure

mkdir pico-pi

# Create the yaml file name and insert the code 
vim garage-door-temperature-display.yml


# Compile the code
esphome run garage-door-temperature-display.yml --device /Volumes/RPI-RP2

cd ~/pico-pi/.esphome/build/garage-door-temperature-display.yml/.pioenvs/rpi-pico/

# Plugin the pico while press the flash button
# Run 'mount | grep RP' command to find the mount point

# flash the code on to the pico 
cp firmware.uf2 /media/<user>/RPI-RP2 

screenshotTwo screenshotThree`

Jun 1, 2023 - Wifi Talley Lights

This is a guide on how to flash the wifi talley for the https://wifi-tally.github.io/ project on Linux.

Flash and Configure the NodeMCU with Linux

# Create Project Directory 
mkdir ~/wifiTalley

# Install the tools
git clone https://github.com/AndiDittrich/NodeMCU-Tool.git
sudo npm install nodemcu-tool -g
sudo npm install cli-progress  
pip install esptool

mkdir ~/wifiTalley/fireware
cd ~/wifiTalley/firmware/

# Download the binary file and config files 
wget https://github.com/wifi-tally/wifi-tally/releases/download/0.5.1/vtally-0.5.1-esp8266.zip
unzip vtally-0.5.1-esp8266.zip

# Flash the the Firmware 
esptool.py --port /dev/ttyUSB0 write_flash -fm dio 0x00000 ~/wifiTally/firmware/nodemcu-3.0-master_20200610-cfe68233-float.bin 

cd ~/wifiTally/NodeMCU-Tool

# Upload the config files
bin/nodemcu-tool.js upload ~/wifiTally/firmware/init.lua
bin/nodemcu-tool.js upload ~/wifiTally/firmware/*.lci

# edit the talley-settings.ini, set the ssid, ssid password, hub ip, and talley name 
vim ~/wifiTally/firmware/tally-settings.ini
 
# Upload the last config files 
bin/nodemcu-tool.js upload ~/wifiTally/firmware/tally-settings.ini

Resources

  • https://wifi-tally.github.io/
  • https://nodemcu.readthedocs.io/en/release/getting-started/#esptoolpy

Nov 7, 2022 - Systemd Start Script for Superset

Create the file superset.service at /lib/systemd/system/superset.service and insert the following. Note the user is sysadmin, the port is 8088 and superset is installed in the /opt/super python virtual environment

[Unit]
Description=Start Superset

[Service]
Type=simple
User=sysadmin
Group=sysadmin
Environment="FLASK_APP=superset"
ExecStart=/opt/super/bin/superset run -p 8088 --with-threads --reload --debugger --host 0.0.0.0

[Install]
WantedBy=multi-user.target

To start the service

systemctl daemon-reload
systemctl start superset