allow a very young kid to control the laptop's microphone mute/unmute status without adult supervision
visual feedback of the mute status is required
very simple to use
multiple buttons should control the same microphone (read: the parent has control as well)
no batteries
This solution:
use a ESP32 module, flashed with NodeMCU
a button connected to a GPIO input (pull up, GPIO12), and GND
a LED connected to a GPIO output (GPIO13), and GND
a java piece of code running on the machine to be controlled
WIFI connectivity is required and the target machine must be on the same network
The how:
at startup, ESP32, connect to WIFI, joins a multicast group and publishes a initial 'query' message
the java code is running in background on the controlled machine, joins the same multicast group and responds with a 'state' message indicating the volume level
the ESP receives the response and turns on/off the connected LED.
pressing the button triggers the ESP to send a 'toggle' message, expecting a 'state' response that will also turn on/off the connected LED.
Java code:
configuration is set in app.properties that needs to be on the classpath when running the app.
mcastPort/mcastAddress identifies the muticast group. These values must match the ESP32's configuration
pairedNodeID property is not mandatory, the code will only respond to the first device that comunicates with after startup. If set, this should be the the NodeMCU's chip id
useSystemValue property if set to true, the max microphone level is set by the user using the OS controls. If false, then the max microphone level is set to the value configured by 'maxInputValue' integer property
setCommand is (at this time) the OS command to set the microphone volume to a specific value, integer
getStateCommand - os command to retrieve the current microphone value. The output of this command should be a single line, integer value between 0 and 100, inclusive.
ESP32 code:
Configuration is set in wifi.conf file. At startup,if this file is missing, the device will enter the configuration mode, exposing a access point. Additionally, configuration mode can be entered by touching pad 3 during startup.
In configuration mode, a web interface will allow you to configure the primary(secondary) wifi network, multicast group info. During this phase, all avaliable access points are listed.
after the configuration is complete and WIFI network is joined, the ESP32 will join the multicast group and send a 'query' message indicating the chip id in the nodeDd field
the reply will cause the LED status to be updated accordingly
pressing the button will cause the ESP32 to send a 'toggle' message, to be followed by a reply
When no reply to a request is received, the LED will blink 5times/sec indicating a connectivity issue
the GPIOs, timeouts and various parameters are set in init.lua
The case:
The STL and PLA GCODE for Creality Ender 3 is in the Case folder