pc-switch - first testing boards arrived

pc-switch prototype arrived and I need to fix some things. But it is working perfectly!

pc-switch - first testing boards arrived
pc-switch in my hand

As you can see in the picture, I got the pc-switch boards! Two of those boards are on the way of my contractor who built the board.

🚨
The PokyPow prelaunch page is live! Sign up there for stock updates at Crowdsupply.

Wrong socket

After inspecting the device I immediately found a "mistake". We used the wrong socket! The USB 2.0 header on the motherboard has 9 pins and usually one port on the hole in the corner is blocked.

That way you can not possibly plug it in the wrong way. As I remember from my Master in Quality Engineering this is called Poka Yoke: make it impossible for an error to occur or make it obvious once it has occurred 🤓

Wrong orientation

Another physical thing that caught my attention: The plug needs to be rotated 180 degrees. It is currently facing down. That way we do not see the RGB LED.

Used a strapping pin

So we used a so-called strapping pin which crashed the program in a way that I had to utilize the reset button on the board. We need to switch to a regular GPIO pin which does not have specific boot behaviour.

LED power is detected but power led in case does not light up

I am not sure what is wrong here. But I tested this on 3 cases I have at home. I can perfectly detect the power on state with the power led. However, the power led on the case does not work anymore. Maybe its resistance from the cables or the wrong optocoupler. My hardware guy is looking into this.

Antenna

Of course, I bought the wrong antennas in the beginning. Antennas are so badly labeled and even if you search for the antenna with a specific connector you might get results for a wrong connector.

The connector which can be used is one of these: w.FL / MHF3 / IPEX3

I found this antenna from Adafruit with a 220mm long cable: https://www.adafruit.com/product/5445

Angled shot of red rectangular antenna with wFL connector.
WiFi Antenna with w.FL / MHF3 / IPEX3 Connector

Software

This works!

Had to tweak a bit here and there but it works. This is my current code which will be uploaded to GitHub soon:

esphome:
  name: server-switch
  friendly_name: server-switch

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino
  flash_size: 4MB
  

# Enable logging
logger:
  # level: DEBUG

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
  password: ""

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Server Fallback Hotspot"
    password: ""

captive_portal:
  
web_server:
  port: 80

light:
  - platform: neopixelbus
    type: GRBW
    variant: SK6812
    pin: GPIO8
    num_leds: 30
    name: "LED Strip"
    effects:
      - addressable_rainbow:

sensor:
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 2s


switch:
  - platform: gpio
    pin: 
      number: GPIO7
      inverted: true
      mode:
        output: true
        pulldown: true
    id: power_pin
    internal: true

  - platform: gpio
    pin: 
      number: GPIO6
      inverted: true
      mode:
        output: true
        pulldown: true
    id: reset_pin
    internal: true

  - platform: template
    name: "Power Switch"
    id: power_switch
    internal: true
    turn_on_action:
      - switch.turn_on: power_pin
      - delay: 2000ms
      - switch.turn_off: power_pin

  - platform: template
    name: "Power Switch Force"
    id: power_switch_force
    internal: true
    turn_on_action:
      - switch.turn_on: power_pin
      - delay: 10000ms
      - switch.turn_off: power_pin

  - platform: template
    name: "Reset Switch"
    id: reset_switch
    internal: true
    turn_on_action:
      - switch.turn_on: reset_pin
      - delay: 1000ms
      - switch.turn_off: reset_pin


binary_sensor:
  - platform: gpio
    pin:
      number: GPIO10
      inverted: true
    id: pc_power_sensor
    name: "Power State"
    device_class: running
    icon: "mdi:desktop-classic"

button:
  - platform: template
    name: "Power Button"
    id: power_button
    icon: "mdi:power-standby"
    on_press:
      then:
        - switch.toggle: power_switch

  - platform: template
    name: "Force Power Off"
    id: force_power_off
    icon: "mdi:power-plug-off"
    on_press:
      then:
        - switch.toggle: power_switch_force
        - delay: 1000ms
        - switch.turn_off: power_switch_force

  - platform: template
    name: "Reset Button"
    id: reset_button
    icon: "mdi:restart"
    on_press:
      then:
        - switch.toggle: reset_pin

Last Words

How am I doing and what do you think about this project?

I love hearing from readers, and I am always looking for feedback. Is there anything you would like to read more or less of? You can just click on the 👍 or 👎 down below. What do you enjoy most about the newsletter, just let me know in the comments.

Have a great day! 👋