Final assembly is shown in figure below. I have used GPIO extender as shown in figure in order to ease the wiring and flexible sensor placement.
Two sensors are permanently fixed beneath my work table as shown in
figure below. The values generated from these two sensors are logically
"and" operated to activate the trigger pin. Code structure is as
following:
if (distance1 > threshold) and (distance2 > threshold):
#Print the datetime of leaving the table
GPIO.output(Rasptrigger, True)
time.sleep(5)
else:
GPIO.output(Rasptrigger, False)
time.sleep(0.1)
Figure #4
Below figure shows the distance measurement from each sensor. The threshold value is constant value of 24cm (2 feet) as per my sitting arrangement and chair height. As the figure clearly shows, as soon as both sensor value crosses 24cm, the message is generated and mail is sent through Cayenne setup.
It is quite easy to setup triggers along with mail and SMS integration.
Before Cayenne, I used to work with Python API for SMTP which keep
giving me trouble due to advanced security features of gmail. Further
SMS integration was a nightmare for me.
Just after creating a device name, just need to setup trigger condition
as shown below. As soon as RPi pin 21 gets triggered, an email is sent
as shown in below.
In office hour of 8 hours, my goal is to take break from office chair
for at least 20-30 times. Below figure shows all the mail is generated
from last 5 days, it means I am much above goal.
Schematic:
have you tried to use twilio service for sms in your python code?