Skip to content

Instantly share code, notes, and snippets.

@benjaminwood
Created May 10, 2020 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjaminwood/6c8de7f66c3974bac850bbefe2bec082 to your computer and use it in GitHub Desktop.
Save benjaminwood/6c8de7f66c3974bac850bbefe2bec082 to your computer and use it in GitHub Desktop.
My On Zoom weekend project
#!/bin/bash
# Replace with your D1 IP (see it in serial monitor when the devboard starts up)
url=http://192.168.179.146/LED
while :
do
if xwininfo -tree -root | grep "Zoom Meeting" &> /dev/null
then
curl -d color=red $url
else
curl -d color=green $url
fi
sleep 1
done
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
ESP8266WiFiMulti wifiMulti; // Create an instance of the ESP8266WiFiMulti class, called 'wifiMulti'
ESP8266WebServer server(80); // Create a webserver object that listens for HTTP request on port 80
int RED = D5;
int GREEN = D6;
void handleRoot();
void handleLED();
void handleNotFound();
void setup(void){
Serial.begin(115200);
delay(10);
Serial.println('\n');
pinMode(RED, OUTPUT); // Make RED pin D5 an output pin
pinMode(GREEN, OUTPUT); // Make GREEN pin D6 an output pin
digitalWrite(GREEN, true);
wifiMulti.addAP("SSID", "PASSWORD"); // add Wi-Fi networks you want to connect to
Serial.println("Connecting ...");
while (wifiMulti.run() != WL_CONNECTED) { // Wait for the Wi-Fi to connect: scan for Wi-Fi networks, and connect to the strongest of the networks above
delay(250);
Serial.print('.');
}
Serial.println('\n');
Serial.print("Connected to ");
Serial.println(WiFi.SSID());
Serial.print("IP address:\t");
Serial.println(WiFi.localIP());
if (MDNS.begin("esp8266")) {
Serial.println("mDNS responder started");
} else {
Serial.println("Error setting up MDNS responder!");
}
server.on("/", HTTP_GET, handleRoot); // Call the 'handleRoot' function when a client requests URI "/"
server.on("/LED", HTTP_POST, handleLED); // Call the 'handleLED' function when a POST request is made to URI "/LED"
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}
void handleRoot() {
server.send(200, "text/html", "<form action=\"/LED\" method=\"POST\"><input type=\"submit\" name='color' value=\"red\"><input type=\"submit\" name='color' value=\"green\"></form>");
}
void handleLED() {
String color = server.arg(0);
String red = "red";
if (color == red) {
digitalWrite(GREEN, false);
digitalWrite(RED, true);
} else {
digitalWrite(RED, false);
digitalWrite(GREEN, true);
}
server.sendHeader("Location","/");
server.send(303);
}
void handleNotFound(){
server.send(404, "text/plain", "404: Not found"); // Send HTTP status 404 (Not Found) when there's no handler for the URI in the request
}

My On Zoom call weekend project

https://twitter.com/benjaminwood/status/1259242096965193728?s=20

I'm running zoom on Linux (Ubuntu 20.04); command.sh and on-zoom-call.service is Linux specific. Happy to chat/think about how this could be done on macOS. As for main.cpp, go easy on me, I don't know C++ well.

Parts

Wemos D1 mini Cheap from China: https://www.aliexpress.com/item/32651747570.html I bought a 5 pack on Amazon: https://www.amazon.com/gp/product/B076F52NQD/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1

Dual color LED module I only used this becuase I had it sitting around as part of kit I got a couple years ago. https://www.sunfounder.com/dual-color-led-module.html

USB charger from an old iPad

# Lives at /etc/systemd/user/on-zoom-call.service
[Unit]
Description=On Zomm Call
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/bin/bash -c "/home/ben/Documents/PlatformIO/Projects/On\ Call/command"
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment