Mail Chime Hack

For several years, I have had a Hanna Products Mail Chime installed on my outdoor mailbox with an indoor receiver. The transmitter is attached to the door of the mailbox. When the door is opened a gravity switch is closed and a signal is sent to the receiver. The receiver sounds an alert and illuminates an LED lamp. The lamp is reset by a momentary contact push-to-close button switch.

I took a receiver apart to see if I could make a simple hack to have a Raspberry Pi sense when the LED lamp was on and then send an email to one of my accounts to indicated the mailbox door had been opened. Another function is to send a signal to a relay module to reset the LED lamp to off.

The project requires some programming skills with Linux and Python, a basic understanding of some electronic components, and some soldering is required. I had my project operating in three short evenings.

Parts List

Hanna Products, Inc. Mail Chime – Amazon $55
Raspberry Pi Model B – Amazon $56
2 1K ohm resisters – Amazon, pack of 100, $6
1 DaFuRui 8Pcs DC 5V 1 Channel Relay Module – Amazon, pack of 8, $13
1 MCP3008 Microchip – Amazon, Pack of 4, $12.50
1 breadboard – Amazon, ELEGOO 3pcs MB-102, $9
Jumper wires – Amazon, Elegoo EL-CP-004, $7

Raspberry Pi breakout board and ribbon cable
A case for the Raspberry Pi.

Soldering iron and solder
Phillips head screwdriver
Small flathead screwdriver wire stripper

The following is the schematic for the project.

Note the half-moon indentation at one end of the MCP3008 microchip. This will orient the chip to access the correct pins. Also, I used a labeled breakout board for the Raspberry Pi instead of a direct connection.

Begin by opening the bottom of the mail chime. One phillips screw holds the bottom panel to the housing. The printed circuit board is not fastened to the housing. Then solder 4 jumper wires to the printed circuit board inside of the disassembled mail chime as shown.

Mail Chime Printed Circuit Board

Then plugin the MCP3008 Microchip, and the 2 1K ohm resistors to the breadboard. Then connect the various jumper wires on the breadboard, and from the breadboard to the Raspberry Pi, the relay module and the mail chime. Use the schematic and photograph as guidance. I used a Raspberry Pi breakout board to easily identify the Raspberry Pi connections.

The resistors act as a voltage splitter to decrease the voltage going to the MCP3008 CH0 pin.

Mail chime printed circuit board connected to the breadboard. Note that a breakout board is being used for the Raspberry Pi, which s connected to a ribbon cable. The breakout board is labeled to identify the pin connections.
All components connected.

Use the small flathead screwdriver to connect the jumper wires to the relay module.

Python Scripts

UPDATE: Google no longer permits logins from 3rd party software. I have made a few changes to the script to set it up for alternate domains. Those changes are in red. Note that the proper name for the SMTP Server Name is required.

Python scripts are placed in the following directory on the Raspberry Pi:


Note that the indented lines in the following Python scripts are indented with tabs, not spaces.

import spidev, time
import time
import datetime
import os
#Open SPI bus
spi = spidev.SpiDev(), 0)

#Function to read SPI data from MCP3008 chip
#Channel must be an integer 0-7
def ReadChannel(channel):
     adc = spi.xfer2([1, (8 + channel) << 4, 0])
     data = ((adc[1]&3) << 8) + adc[2]
     return data
#Function to convert data to voltage level
#rounded to specified number of decimal places
def ConvertVolts(data,places):
     volts = (data * 3.3) / float(1023)
     volts = round(volts,places)
     return volts

mySendMail = '/home/pi/projects/mailbox/'
myResetChime = '/home/pi/projects/mailbox/'
print ("Check mail was run.")

reading = ReadChannel(0)
voltage = ConvertVolts(reading,2)
print("Reading=%d\tVoltage=%.2f" % (reading, voltage))

#If voltage is greater than or equal to 0.75 V then send an e-#mail
if (voltage >= 0.75):
     now =
     print("Mailbox was opened at: ")
     print(now.strftime('%H:%M %Y-%m-%d'))
     print("Mailbox Chime has been reset.")

import smtplib
import datetime
MAIL_PASS = "password"
now =
text = 'Your mail box has been opened!!!\n\n'
text = text + 'Time: '+now.strftime("%H:%M:%S %Y-%m-%d")+'\n\n'
sent_from = MAIL_USER 
to = ['']
subject = 'Mailbox Alert'
body = text
email_text = """\
From: %s
To: %s
Subject: %s

""" % (sent_from, ", ".join(to), subject, body)

     server = smtplib.SMTP('<SMTP Server Name>', 587)
     server.login(MAIL_USER, MAIL_PASS)
     server.sendmail(sent_from, to, email_text)

 except Exception as e:


import RPi.GPIO as GPIO
import time
in1 = 16

GPIO.setup(in1, GPIO.OUT)
GPIO.output(in1, GPIO.LOW)   
GPIO.output(in1, GPIO.HIGH)
GPIO.output(in1, GPIO.LOW)   

Crontab Settings

Enter the following one line using the crontab -e command.

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/pi/projects/mailbox/ >> /home/pi/projects/mailbox/mailbox.log 2>&1

Crontab will run the Python script every 5 minutes. Any output to standard output and standard error will be written to the mailbox.log file for troubleshooting purposes. When the mail chime is triggered by the mailbox door sensor, there will be current to the mail chime LED, which is then detected by the MCP3008 microchip at CH0. This in turn triggers the code to send an email, then after 60 seconds, the relay is actuated to reset the mail chime.

6 thoughts on “Mail Chime Hack

  1. Richard Creasey May 15, 2022 / 5:34 PM

    Hi Bill,
    Thank you for documenting this. I have a mail chime and for years wanted to trigger a text message when the LED is on. You did a great job at documenting it and I hope to duplicate your work this week.

    73 AI4Y


    • Richard Creasey May 20, 2022 / 10:57 AM

      I found one wiring issue with your schematic

      MCP3008 Pin 11 should go to RPi pin 19 and not pin 21.
      MCP3008 Pin 12 should go to RPi pin 21 and not pin 19

      Once I corrected the wiring the RPi would read the ADC voltage correctly.

      On my RPi I had to modify as follows:


      mySendMail = ‘/home/pi/projects/mailbox/’
      myResetChime = ‘/home/pi/projects/mailbox/’


      mySendMail = ‘python /home/pi/projects/mailbox/’
      myResetChime = ‘python /home/pi/projects/mailbox/’

      I also created a bash file to call from cron as follows:

      vi /home/pi/projects/mailbox/

      export PATH=/home/pi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/pi/projects/mailbox/
      cd /home/pi/
      python3 /home/pi/projects/mailbox/

      My crontab entry is :

      0-59 * * * * /home/pi/projects/mailbox/ >> /home/pi/projects/mailbox/mailbox.log 2>&1

      Again, thank you for sharing all the photos, wiring, schematic, etc. Much appreciated!


      • Bill October 15, 2022 / 5:07 PM

        Thanks for your comment. I was using a breakout board instead of a direct connection to the Raspberry Pi. That may account for the pin number discrepancy. The labels (MOS1, MOS0 and CLK) are correct. I will make a note in my post.


    • Grady Holt February 11, 2023 / 6:32 PM

      Richard, I, too, would prefer text notifications from my chime mail so I would be very appreciative of any guidance you might provide based on your experience with your project. Thanks


      • Richard February 12, 2023 / 7:22 AM

        Hi Grady, I followed Bills instruction and it worked. I already noted the one wiring exception and script modifications that allowed it to work for me. Beyond that, just take your time.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s