I'm looking to create a website that changes its text based on a physical button I can push at home. I've seen a variety of approaches discussed, like using Cloudflare tunnels, GitHub pages with auto-push features, or even sending an email to trigger changes. However, I'm more interested in hearing how you all would tackle this project. So, how would you set it up?
5 Answers
I would probably go with a Raspberry Pi, connect the button directly to it, and write an app that triggers when the button is pressed. You could create a bash script that constantly checks the button's state and makes a web request to notify a website when it's pressed. This approach gives you a lot of flexibility and control.
It really depends on your goals and setup! If you need a simple toggle, having the button itself host the website is one way to go. But for a larger or more robust implementation, connecting the button to an API that updates a separate web server might be better, especially if you're thinking about handling more traffic in the future.
Using an ESP32 is a really simple option. It can handle the API calls easily. If you're looking to make things a bit more IoT-like, MQTT is worth considering. It's flexible and has worked well for me in the past. Even my non-coding friend uses Node-RED for similar applications.
Before diving in, it's essential to know where your button will be located and its capabilities. If it's wireless, that's a plus! For a self-hosted site, create an endpoint that receives updates from the button. Keep in mind that something needs to be running to handle those requests, so consider setting up your own service.
True, you really need that service running to manage everything smoothly. Depending on your hardware, it can simplify things significantly.
First off, you'll want to control the backend of the site. Set up an API endpoint that updates the text whenever the button is pressed. You'll need a microcontroller like an Arduino or Raspberry Pi to connect the button and send requests to that endpoint. Don't forget to add an authentication token to keep your endpoint secure. It's quite straightforward!
Nice, that's a solid idea! The script loop can handle multiple presses effectively.