I came across this idea because there is a problem in the company that I work for. There is a remote office that has only a few people working a few hours a day. For these people computers are still a “complicated” object. We have internet and a VPN there. We also have e-mail and a server for remote backups. However something was missing. We need an easy way to transfer paper documents to our headquarters instantly.

.

.

To Buy a network scanner was too expensive; to buy a simple scanner and attach it to a computer was not a solution either, because there are 3 computers to 3 people. Despite that, it will not be would be an easy task to use this software due to people lack of knowledge.

The solution: an old scanner and a Raspberry Pi.

I assume that you may have some network background for setting up an email server and Bind so you can configure your operating system to send email to any email account.

In this solution I used Raspbian for the OS, Sendmail, Bind, Python, Bash, Sane, Imagemagick and Mutt. I’ll skip the Sendmail and Bind details.

The idea is: atach an old USB scanner (must be compatible with Sane) to the Raspberry Pi, push a button to initiate the scanning process and a script is launched so the scanned image would be automatically sent to a predefined email address.

We have 2 leds for system status; I’ll be on headquarters and if the system fails, someone has to describe me, by phone what they see in the Raspberry Pi box.



So, let’s start by hardware: we will need 3 pins; one pin for the push button and two others for system status with leds.

System busy:

Pin 18 (RED) will be used to show that the system is performing is main task since the moment we’ll push the button to the moment that the image is processed, converted and sent.

Push button:

The button to trigger all the action. It will be conected to Pin 18 and a 10.000 omh resistor.

System status:

Pin 14 (GREEN) will be used to show the healthy system status by blinking twice every 5 seconds.

For that, I’ve used a simple Bash script that is called from /etc/rc.local on system boot.

rc.local

#initiate PINS 14 and 18 on GPIO

echo 14 > /sys/class/gpio/export

echo out > /sys/class/gpio/gpio14/direction

echo 18 > /sys/class/gpio/export

echo out > /sys/class/gpio/gpio18/direction

#turns leds 14 and 18 off

echo 0 > /sys/class/gpio/gpio14/value

echo 0 > /sys/class/gpio/gpio18/value

#bash script to initiate blinking status

/root/scripts/blinking.sh &

# python script to listen for the push button

/root/scripts/script_listen_for_scan.py &

/root/scripts/blinking.sh

#!/bin/bash

while true; do

echo 1 > /sys/class/gpio/gpio14/value

sleep 0.05

echo 0 > /sys/class/gpio/gpio14/value

sleep 0.09

echo 1 > /sys/class/gpio/gpio14/value

sleep 0.05

echo 0 > /sys/class/gpio/gpio14/value

sleep 5

done

/root/scripts/script_listen_for_scan.py

#!/usr/bin/env python

from time import sleep

import os

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

GPIO.setup(23, GPIO.IN)

GPIO.setup(24, GPIO.IN)

while True:

if ( GPIO.input(23) == True ):

os.system(‘/root/scripts/scan.sh &’)

sleep(1);

/root/scripts/scan.sh (this script will make all the job, and is called trough the loop of script_listen_for_scan.py)

#!/bin/bash

cd /root

rm -rf /root/sent.lock # to ensure that if something goes wrong, next time system will not hang up because of this

echo 1 > /sys/class/gpio/gpio18/value # process initiated – let’s turn led RED on

scanimage –resolution 100 > /root/scan_job.pnm # scan and save the file

convert /root/scan_job.pnm /root/scan_job.jpg # convert to JPG

cd /root # ensure to run as root to avoid the mutt to not send the file

sudo mutt -s “Scan from Remote Office” -a /root/scan_job.jpg -c email@mydomain.com < /root/MSG # MSG contains a simple message.

echo 0 > /sys/class/gpio/gpio18/value # job completed – Turn RED led off.

Video: