6.4 Writing the Code
There are two code components in this project. The first is the sketch that monitors when something has been placed on the force sensitive resistor that is heavy enough to exceed the normal threshold. When that occurs, broadcast the event along with the value of the force resistor resistor via the XBee soft serial port.
The second component is a Python script that waits for a threshold event from the force sensitive resistor monitor. If the threshold has been exceeded, record the value of the resistor along with the date and time of the event to an SQLite database. If the database contains a list of known tracking numbers, iterate through these numbers and interrogate FedEx and UPS web services for a match. Then send an email containing information about the delivery event as well as the courier’s package delivery confirmation, if available.