Unable to load image

(Request) Pihole With Button

https://rdrama.net/h/slackernews/post/188267/contest-5000mb-reward-whats-in-the

A user asked me the below.

Hey, did you use any guides for setting up your pie hole and/or installing the button?

Was interested in making one of these as well.

Any tips or w/e would be appreciated, thanks!

This was my response. which is probably definitely rslurred but w/e

!codecels roast me


No Guides, but happy to give tips, and follow ups where things are unclear.

Button is pretty cool for sure... but you can do everything you need to do from your computer and phone.

A pihole does not protect you unless you set it up as your DNS on your router.

I would also recommend setting up a vpn to your home network using openvpn that way you can take your protection on the go, itll protect you from getting throttled by your cell phone provider too

Parts

Config Pi

Code

  • Look its probably right... but how you set this thing up makes a difference

  • Put this on your Pi maybe call it buttonscript.js

  • {YOUR USER HERE} needs to be swapped out for the user you created

const fs = require('fs');

const Gpio = require('onoff').Gpio;

const { exec } = require('child_process');

// GPIO pin number

const buttonPin = 17;

const logFilePath = '/home/{YOUR USER HERE}/buttonscript.log';

// Setup the button GPIO as input

const button = new Gpio(buttonPin, 'in', 'falling', { debounceTimeout: 200 });

// Function to disable Pi-hole blocking for 5 minutes

function disablePiHole() {

const timestamp = new Date().toISOString();

const logMessage = [${timestamp}] Button pressed. Disabling Pi-hole for 5 minutes...;

console.log(logMessage);

fs.appendFile(logFilePath, logMessage + '\n', (err) => {

if (err) {

 console.error('Error writing to log file:', err);

}

});

exec('pihole disable 5m');

}

// Add event listener to the button

button.watch(disablePiHole);

// Cleanup GPIO on process exit

process.on('SIGINT', () => {

button.unexport();

process.exit();

});

Service

  • This thing needs to start back up when power fails so you need to set it up to do that

  • go here cd /etc/systemd/system/

  • run this to create it sudo nano buttonscript.service

[Unit]

Description=Button Script

After=network.target

[Service]

ExecStart=/usr/bin/node /home/{YOUR USER HERE}/buttonScript.js > /home/{YOUR USER HERE}/buttonscript.log 2>&1

WorkingDirectory=/home/{YOUR USER HERE}/

Restart=always

User={YOUR USER HERE}

[Install]

WantedBy=multi-user.target

  • save and exit nano

  • run this sudo systemctl enable buttonscript.service

  • run this sudo systemctl start buttonscript.service

Circuit

https://i.rdrama.net/images/169043665549889.webp

https://i.rdrama.net/images/16904366556798973.webp

  • find your pinout, I am showing a 4b there are others

  • 3.3 to a rail on the + side of the breadboard at the top using these wires https://www.amazon.com/dp/B01EV70C78

  • in that top rail, put the resistor in

  • resistor to the left hand side on maybe the top row of the breadboard

  • gpio 17 to left side on that row using these wires https://www.amazon.com/dp/B01EV70C78

  • button to left side on that row use the breadboard wires there

  • other terminal on the button to the right side of the breadboard

  • ground to right side on that row using these wires https://www.amazon.com/dp/B01EV70C78

Package to suit, and your done

26
Jump in the discussion.

No email address required.

Did you really spend $10 on a button for your pihole?


:!marseybooba:

Jump in the discussion.

No email address required.

I spent $10 on something for my parents because they wanted a big red button I didn't say it was a good idea

Jump in the discussion.

No email address required.

I take back my derision. A large red button is appropriate for this application.


:!marseybooba:

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.