Overview
Our system consists of a Raspberry Pi running our framework python file, including a Gmail API and a serial communication function in it.
The Raspberry Pi is connected to an Arduino UNO, which runs our motor control code, sending signals to two steppers motors with the help of an Adafruit motorshield.
The Raspberry Pi is connected to an Arduino UNO, which runs our motor control code, sending signals to two steppers motors with the help of an Adafruit motorshield.
The Gmail API
The first thing we did, was set up a new Gmail account poe.kinnect@gmail.com. We then subscribed to all major Olin mailing lists like Carpe and Helpme. All incoming mails of these mailing lists get tagged en get put in their respective labels. This way all emails are neatly organized.
This allows the Gmail API to connect to this Gmail account and read the amount of emails in each of these labels. This happens every five minutes so we can see how the amount of emails of a certain mailing list changes and how the sculpture moves accordingly.
This allows the Gmail API to connect to this Gmail account and read the amount of emails in each of these labels. This happens every five minutes so we can see how the amount of emails of a certain mailing list changes and how the sculpture moves accordingly.
Python Framework
The Python code runs in a constant loop, first connecting to the Gmail account and getting the amount of mails in a label. Then comparing this to the previous amount stored in the memory and calculating the difference between the two. The next step is sending these differences to the Arduino so it can drive the motors accordingly.
Via the power of PySerial, a python package which allows serial port communication with other devices, we send these differences to the Arduino Uno micro controller over the serial port. Every day at midnight, instead of sending these differences, we send a reset command so the sculpture goes back to its default position.
Via the power of PySerial, a python package which allows serial port communication with other devices, we send these differences to the Arduino Uno micro controller over the serial port. Every day at midnight, instead of sending these differences, we send a reset command so the sculpture goes back to its default position.
Firmware
The Arduino firmware receives these differences, it then turns on the stepper motors and makes them move a certain amount of steps. The amount of steps scales linearly to the difference sent until the maximum amount of steps is reached. After that, both stepper motors go to half their current position and the loop can start over. The Arduino keeps track of the weight's position at all time so it can go back to the default position whenever a reset command is sent.
For a complete detailed step by step explanation and all the source code, click the button on the right.
|