Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at

hpr3275 :: D1 Mini Close Lid to Scan

Use a Wemos to monitor if the lid is open or closed on a network scanner.

<< First, < Previous, , Latest >>

Thumbnail of Ken Fallon
Hosted by Ken Fallon on 2021-02-19 is flagged as Clean and is released under a CC-BY-SA license.
Wemos, D1 Mini, network scan. 1.
The show is available on the Internet Archive at:

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:07:10

Hardware upgrades.

Hosts share their experiences when upgrading their equipment.


Use a Wemos to monitor if the lid is open or closed on a network scanner.


In episode hpr2430 :: Scanning books, I had a bash file trigger a network scan. This required two steps, one to close the lid and the next to press a key for scantoimage.bash to trigger the next page of the scan.

In the intervening time I looked at several solutions to improve this situation.

The most obvious step was to put a magnetic switch on the scanner lid so that a device could detect the lid been closed.

I tried a Raspberry PI but my scanner drivers are only available for Intel and not Arm. Then then accessing the pi using Remote GPIO, but it got very complex to setup and run.

Inspired by hpr3077 :: Video conference Push to Talk Hosted by DanNixon on 2020-05-19, I tried using an arduino talking over serial to a Intel Compute Stick. But that was very flakey.


Finally I settled on using a Clone of LOLIN D1 mini, and some Reed Contacts.


Wire one end of the reed contact to 3.3v, and the other end to ground via a 10K resistor.

Have a sensor wire go from the 10K resistor to pin D5 on the D1 Mini.





D1 Mini

See wemos-close-to-scan.ino


See wemos-scantoimage.bash


  1. Plug in D1 Mini and monitor the serial port to get its IP Address.
  2. Change the server="YOUR-WEMOS-IP-ADDRESS" in wemos-scantoimage.bash to the ip address.
  3. Change the image_path="/PATH/TO/YOUR/SCANS/" in wemos-scantoimage.bash to where your want the files saved.
  4. Close scanner and scan.


Subscribe to the comments RSS feed.

Comment #1 posted on 2023-05-11 08:56:20 by Ken Fallon

I need to put this on some Perfboard

Thanks Dave for having the schematic on for me to find based on the bash file name.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
What is the HOST_ID for the host of this show?
What does HPR mean to you?