8000 GitHub - academo/grotbutton: Code for the grotbutton IOT
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

academo/grotbutton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grot Bot Button

image

This is an IoT button in the shape of the Grafana mascot Grot that can trigger webhook requests when pressed.

Software Requirements

Really the easiest way is to install it as a vscode extension. Even if you don't use vscode as your editor, it is so much easier with the extension.

Hardware Requirements

  • 3D printed parts (get them from printables
  • ESP32-C3 Super Mini (Get it from Aliexpress. Usually less than 2€)
  • Cherry MX switch or clone. (You can find clones in Aliexpress for as little as 10 units for 2€.)
  • Soldering supplies
  • One jumper wire or any other soft wire (0.35 mm² or 22 AWG)
  • Super glue or instant glue (Cyanoacrylate-based glue e.g. loctite)

Firmware instructions

I recommend you to burn the firmware before you assemble the button so you can test your chip is not defective before you solder anything.

  1. Clone this repository
  2. Open it with PlatformIO
  3. Connect the chip to your computer via USB-C
  4. Upload the firmware. In the command palette: PlatformIO: Upload or press the Upload button (usually top right corner)
  5. Wait for the upload to finish without errors

Assembly instructions

  1. Insert the switch inside the grot bottom part
image image
  1. Cut two small jumper wire pieces of approximately 3cm each, and strip the insulation from the ends (about 5mm from each end)

  2. Solder one wire to each leg of the switch (DO NOT solder to the chip yet)

  3. Glue the housing to the bottom grot part. Pass the wires through the holes in the housing.

    After this step you will have two wires sticking out of the housing image

  4. Solder the wires to the ESP32 chip. (Keep an eye on the chip orientation. The USB port should point to the housing USB hole)

    • One wire to the G pin (ground)
    • The other wire to the 2 pin (button pin)
    • NOTE: It doesn't matter which wire connects to which pin

  5. Adjust the chip so its usb port is in the housing usb hole

image image
  1. Glue the housing lid to the housing (Do not glue the housing to the chip, glue the 3D printed parts)

  2. Fix the Grot Top Part to the switch by applying pressure onto the switch until it is pressed and stays in place.

How to use?

First setup

Once your button is assembled and the firmware is uploaded, you can connect it to any usb c power source (you probably already have it connected to your computer!)

On first boot, the button will start an access point (AP) with the name GrotBot-<random number> and no password. Connect to it with your phone or computer.

Once connected (tell your laptop/smartphone to stay connected even if there's no internet), you should get a captive portal to "Sign in". If not, open the web interface at http://192.168.4.1

Once you are in the web interface, you can configure the button with your WiFi credentials and webhook URL. (Maybe try with this webhook-test website?)

Upon saving the configuration, the button will reboot and try to connect to your WiFi network.

If it fails to connect to your WiFi network, it will retry for the next 30 seconds. If all attempts fail, it will go back to AP mode and wait for you to configure it again.

Normal operation

If it successfully connects, you should be able to press the button and see it calls your webhook URL (GET request)

The button will go to sleep after 60 seconds of inactivity to save power. It'll wake up as soon as you press the button.

Pressing the button several times will trigger the webhook for each press.

Change the webhook URL

To change the webhook URL or wifi credentials:

  • Unplug the button
  • Keep the button pressed while you plug it back
  • Make sure to keep the button pressed for at least 5 seconds while it boots up
  • The button will start in AP mode and you can configure it again by connecting to it with your phone or computer

Authenticated webhooks

You can set headers in the configuration form. If your endpoint requires authentication you can add a header for it. e.g: (for username:password)

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Caution

All form information is stored in plain text. Someone with physical access to your button could read it.

Troubleshooting

Button doesn't connect to the wifi and goes back to AP mode every time

  • Make sure the wifi credentials are correct
  • Did you set USE_LOWER_WIFI_POWER to 0? If so, try setting it to 1
  • Is your wifi signal too weak? Try setting USE_LOWER_WIFI_POWER to 0 (if you have the "good" chip)
  • The esp32 c3 super mini is a very small chip. If your wifi signal is too weak it might just not connect to it at all.

The button is connected to wifi (not in AP mode) but the request doesn't reach the webhook

  • Make sure the webhook URL is correct
  • Try first with a GET request only
  • Maybe try a webhook-test website such as: webhook-test.com

I connect to the AP but it doesn't show the captive portal

  • You might get the "sign in" notification on your phone or computer. Try tapping it.
  • If it doesn't work, try opening the web interface at http://192.168.4.1 (in any browser)
  • Check if your phone is actually connected to the AP. Some phones will automatically disconnect from a wifi network if there's no internet.

But, how do I connect it to Grafana?

  • Register an account in https://webhook-test.com/
  • Get a webhook URL from the "Webhooks" tab and set it in your button's configuration
  • Configure the infinity datasource in your grafana instance to read from your webhook-test.com account
  • Plot away!

Alternative

About

Code for the grotbutton IOT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0