{"id":20969367,"url":"https://github.com/imranr98/serfswitch","last_synced_at":"2026-01-29T03:40:28.962Z","repository":{"id":192459223,"uuid":"686762958","full_name":"ImranR98/serfSwitch","owner":"ImranR98","description":"An Arduino-based smart \"switch\" that fits over a regular switch and physically flips it on demand (because we're all just renters these days).","archived":false,"fork":false,"pushed_at":"2024-09-21T22:33:44.000Z","size":1258,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T00:16:51.189Z","etag":null,"topics":["arduino","arduino-nano","diy","diy-electronics","esp32","iot","mqtt","smart-home","smart-switch"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ImranR98.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-03T21:22:48.000Z","updated_at":"2025-02-21T15:57:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcd7bbe5-ff83-4d5d-84ac-a1ee66063b0e","html_url":"https://github.com/ImranR98/serfSwitch","commit_stats":null,"previous_names":["imranr98/serfswitch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImranR98%2FserfSwitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImranR98%2FserfSwitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImranR98%2FserfSwitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImranR98%2FserfSwitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ImranR98","download_url":"https://codeload.github.com/ImranR98/serfSwitch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497817,"owners_count":21113984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-nano","diy","diy-electronics","esp32","iot","mqtt","smart-home","smart-switch"],"created_at":"2024-11-19T03:20:40.656Z","updated_at":"2026-01-29T03:40:28.929Z","avatar_url":"https://github.com/ImranR98.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serfSwitch\n\nAn Arduino-based smart \"switch\" that fits over a regular switch and physically flips it on demand (because we're all just renters these days).\n\nUses [MQTT](https://mqtt.org/) to integrate with [Home Assistant](https://www.home-assistant.io/).\n\n\u003e My first electronics project!\n\n## Requirements\n\n- [Arduino Nano ESP32](https://docs.arduino.cc/hardware/nano-esp32)\n- [Small servo motor](https://www.amazon.ca/dp/B0BMFY8SX8?psc=1\u0026ref=ppx_yo2ov_dt_b_product_details)\n- Tools and other materials:\n  - [Soldering kit](https://www.amazon.ca/dp/B085Y328GK?psc=1\u0026ref=ppx_yo2ov_dt_b_product_details)\n  - [Wire stripper/cutter](https://www.amazon.ca/dp/B073YG65N2?ref=ppx_yo2ov_dt_b_product_details\u0026th=1)\n  - [Jumper wires (male/female)](https://www.amazon.ca/IZOKEE-240pcs-Solderless-Breadboard-Arduino/dp/B08151TQHG/ref=sr_1_5?crid=36ZMSYJOC62IM\u0026keywords=female+jumper\u0026qid=1693773281\u0026sprefix=female+jumer%2Caps%2C309\u0026sr=8-5)\n  - [Aluminium strips](https://www.amazon.ca/dp/B07PDDCMC5?psc=1\u0026ref=ppx_yo2ov_dt_b_product_details)\n  - [Strong double-sided tape](https://www.amazon.ca/dp/B07PYG86FC?psc=1\u0026ref=ppx_yo2ov_dt_b_product_details)\n  - Optional [breadboard](https://www.amazon.ca/BB400-Solderless-BreadBoard-tie-Points-Backing/dp/B00Q9G8MQS)\n- Infrastructure\n  - [Mosquitto](https://mosquitto.org/) or other MQTT server install\n  - [Home Assistant](https://www.home-assistant.io/) install with the [MQTT integration](https://www.home-assistant.io/integrations/mqtt/) connected\n\n## Usage\n\n0. Setup the Arduino IDE with the [ESP32](https://github.com/espressif/arduino-esp32) and [MQTT](https://www.arduino.cc/reference/en/libraries/mqtt/) libraries (on Linux, you may need to add `SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"2341\", ATTRS{idProduct}==\"0070\", MODE:=\"0666\"` to `/etc/udev/rules.d/60-arduino-esp32.rules`).\n1. Copy `template.creds.h` to `creds.h` and fill it in if you want to (if not, you'll need to configure connection settings via Bluetooth).\n2. Strip a centimeter or so of insulation off each of the three wires of the servo (power, ground, control).\n3. Do the same for 3 wires that end in female jumper pins. Coordinating colour with the 3 servo wires is recommended.\n4. Manually twist the exposed end of the power wire from the servo motor with a corresponding female jumper wire for a loose attachment.\n5. Do the same for the servo ground wire.\n6. Solder the 2 power wires (that were twisted together to form \"one wire\") to the `VIN` pin on the Arduino.\n   - You could use the breadboard to prototype everything first.\n7. Solder the \"merged\" ground wire to one of the `GND` pins on the Arduino.\n8. Solder the servo control wire to either the `D3`, `D6`, or `D7` ports on the Arduino.\n   - Only one pin is technically used but the code outputs to all 3 - this is a lazy way to \"correct\" a soldering error in my builds.\n9. Solder the remaining hanging wire (the third female jumper wire) to the `VBUS` pin on the Arduino.\n10. Connect a USB-C power supply to the device. It should show up in Home Assistant with a permanent randomly-generated ID, and should be usable immediately.\n    - Depending on the motor used and how you set it up, you may need to modify some variables under `// Hardware config` - experiment with what values work for you.\n    - Note that the code does support a push button connected to pin `D5`, but I ended up not using one for my build.\n11. Use the aluminium strips and double sided tape to securely mount everything over your existing dumb switch.\n    - Obviously, skip this in the prototyping stage.\n12. The female jumpers are used to power a second switch without needing a second USB-C power supply.\n    - Using a male-male wire, connect the `VBUS`-attached pin of the USB-powered switch to the `VIN`-attached (power) pin on the second switch.\n    - Do the same to connect the `GND`-attached pins of both switches.\n    - Due to power constraints, only 1 switch can be attached in this way.\n13. After the board is plugged in, it should automatically connect to the configured MQTT server. If you did not put configuration variables in `creds.h`, you can use a Bluetooth LE scanner app to configure the switch via Bluetooth (as instructed in the Bluetooth characteristic). The blinking lights you see on boot represent a 6 digit code you will need to include when configuring the switch.\n\n## Result\n\nHey, I never said it was pretty.\n\n![result.jpg](result.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimranr98%2Fserfswitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimranr98%2Fserfswitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimranr98%2Fserfswitch/lists"}