Episode: 3275 Title: HPR3275: D1 Mini Close Lid to Scan Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3275/hpr3275.mp3 Transcribed: 2025-10-24 20:00:54 --- This is Haka Public Radio episode 3,275 for Friday 19th of February 2021, today's show is entitled, The One Minute Close Lid to Scan and in part on the series, Hardware Upgrades, It is hosted by Ken Fallon, and in about 7 minutes long, and Karina Clean Flag. The summer is, you shall be most monitor if the lid is open, or closed on a network canner. This episode of HBR is brought to you by an honest host.com. At 15% discount on all shared hosting with the offer code HBR15, that's HBR15. Better web hosting that's honest and fair at An HonestHose.com. Hi everybody, my name is Ken Fallon and you're listening to another episode of Hacker Public Radio. Today I'm going to walk you through how I used a We Must Clone to trigger an event on the network. I used this to trigger the lid of a network scanner, but you might use this as a simple burglar alarm or to notify you when somebody's opened a gargling gate or something like that. So give you some history back in episode 2430 scanning books. I worked you through how I used scan image, which is part of the same D package, and my brother printer scanner, all the one thing, allows you to scan over the network into if JPEG file, which is kind of cool. One issue that I had with that was it's a two-part stage, two-part process. So I needed to close the lid of the scanner and then press a key on a keyboard Bluetooth keyboard in order for it to work. So in the intervening time I was looking at several different solutions to fix that. So one of the things I did was get a magnetic sensor read switch that you see on doors or windows for burglar solutions to see if they're open or not, and I used a bit of blue tech to stick those on to the printer lid so that when they come in contact the magnetic part doesn't have any wires. It's on the top and the sensor itself switch is on the bottom. So when you close the lid it's able to detect whether the the lid is open or closed. So that was really all I needed. I tried using the Raspberry Pi, ideally I wanted to use the Raspberry Pi and actually scan it over USB, which would be a more generic solution, but brother doesn't release drivers for that printer on the ARM platform, which is a bit sad. Then I tried using an Intel Compute Stick over there, connected up to a to a Raspberry Pi, but that didn't work. Then I tried just a Raspberry Pi running and connecting over a remote GPIO, which did work, but it's very complicated to set up and maintain. So that wasn't an elegant solution. Then Dan Nixon did a video conference push to talk a button thing where he was monitoring the serial port of an Arduino. So what I did then was I had a Raspberry Pi over there connected to a serial port and when they closed it printed out to the serial port which sent it to a Raspberry Pi, which then I was able to connect to remotely, but not a very elegant solution. And then as I was talking off my component kits, I found some Makerfire D1 Mini, which is a Wemos Mini Clones, which is an ESP 80266 development board that supports Wi-Fi. And I was able to get two of those for six pounds at the time. So essentially what I did then was wire in the switch into the 3.3 volts and the other side into a 10k resistor and then to ground. And that's to make sure that any electricity that store their capacitance of the system is leaked away quite quickly. So you get it clear on or off signal. And then in between the switch, the resistor and the switch itself, I take a pin that goes to D5 and that's where the Wemos determines whether it's high or low. So there are two parts to this program. There's the Arduino light program and you can follow along. I include the ESP 8266 Wi-Fi.h and there are two things that you need to change in your SSID and your Wi-Fi password. If you use pin D5, the scanner lid is included there. Then we have the Wi-Fi server port. We start that. And the first thing it does in the setup is it waits for serial to start, waits for Wi-Fi to connect. It'll go into a loop until Wi-Fi is connected and then it'll print out on the serial port the Wi-Fi address that has the IP address that's been assigned over the Wi-Fi to your device. So if you're putting this device in place, you might do this on your desk and then unplug it and put it out in the garden or wherever you're going to be putting it and it should have the same IP address. And then essentially it goes into a loop and that loop starts the client web server and it prints off a page anytime somebody connects which basically is the simplest web page you can get. HTTP 1-200-OK is sent out and return back is the simplest JSON file that you can get which has got essentially closed which is the key and the value is either going to be true or false and it calls a subroutine that will check to see whether the read switch is closed or not and it'll also change the LED color. So that's one thing that you need. The other part you need is the scan to image. We must scan to image file and you need to put in the image path and your IP address. Obviously this is only going to work if you've got a brother printer but you might be able to use scan image for something else from some other two and if you're triggering an alert this might be some other system that you're using or not. OK and we can basically install those which I've done. I plugged in the remote over here and put it on. There's a blue light. I'll run the program here and it tells me the date and time it says the scanner lid is open then I close it then you hear scanning and it's scanning to the network. It tells me that the file has been saved and it tells me the scanner lid is closed. I now open the scanner lid and the blue light is on and able to change the next page and the next page, close the scanner lid, light off and the scans the next page. So that's what I'm going to be doing for the rest of the day. You in the other hand can tune in tomorrow for another exciting episode of Hacker Public Radio. You've been listening to Hacker Public Radio at Hacker Public Radio. We are a community podcast network that releases shows every weekday Monday through Friday. Today's show, like all our shows, was contributed by an HBR listener like yourself. If you ever thought of recording a podcast and click on our contribute link to find out how easy it really is. Hacker Public Radio was found by the digital dog pound and the infonomicon computer club and it's part of the binary revolution at binrev.com. If you have comments on today's show, please email the host directly, leave a comment on the website or record a follow-up episode yourself. Unless otherwise status, today's show is released on the creative comments, attribution, share a light 3.0 license.