Introduction: Tweeting Doorbell

About: ​M.Sc. in Electrical Engineering in Rochester Institute of Technology at USA and CMO of Embarcados.

In this instructable, I will explain how to make a very simple project with DragonBoard 410C + Grove Starter Kit for 410C.
To run this tutorial you'll need:

Qualcomm DragonBoard 710C Board.

Grove Starter Kit for 410C

Compatible Power Supply for the board.

PC with Linux Ubuntu 16.04 (I used this distribution in this tutorial).

USB Mouse and Keyboard.Monitor with HDMI Interface

HDMI Cable

To run this tutorial, you need a DragonBoard 410C with Linux Linaro-Alip. To install it, refer to these tutorials, available in Portuguese at Embarcados and in English in Instructables. To set everything for the Grove Starter Kit for 410C, refer to this tutorial available in Instructables.

Visit Grove Starter Kit for DragonBoard homepage for more informations about the expansion kit for 410C. To download the Schematic, access this link.

So, let's start!

Step 1: Create a Twitter App

Go to your twitter account and create an app.

Step 2: Insert All Informations and Create an App

Step 3: Fill the Form

Step 4: Twitter: Keys and Access

Access Keys and Access Tokens tab in your app, that you just created.

Get all the tokens and create a file in 410C, called keys.py with all your information in it.

consumer_key = "aaaaaaaaa"
consumer_secret = "bbbbbbbbbbb"
access_token = "cccccccccc"
access_token_secret = "dddddddddd"

Step 5: Clone 96Boards Repository With Examples

git clone  https://github.com/96boards/Starter_Kit_for_96Boards
sudo apt-get install python-tweepy

Go inside Starter_Kit_for_96Boards folder

Step 6: Code

cd tweeting_doorbell

Copy the file you created, keys.py, here.

Edit tweeting_doorbell.ino

const int buttonPin = 4;<br>const int ledPin = 3;
const int buzzerPin = 5;
int pressed = 0;
void setup() {
        pinMode(buttonPin, INPUT);
        pinMode(ledPin, OUTPUT);
        pinMode(buzzerPin, OUTPUT);
        Serial.begin(115200);
        Serial.println("waiting");
}
void loop() {
        pressed = digitalRead(buttonPin);
        if (pressed == 1) {
                digitalWrite(ledPin, HIGH);
                digitalWrite(buzzerPin, HIGH);
                Serial.println("tweet");
                delay(2000);
                digitalWrite(ledPin, LOW);
                digitalWrite(buzzerPin, LOW);
        }
        delay(100);
}

Edit tweeting_doorbell.py

import tweepy, serial, datetime, time, keys, pyupm_i2clcd<br>auth = tweepy.OAuthHandler(keys.consumer_key,
                           keys.consumer_secret)
auth.set_access_token(keys.access_token,
                      keys.access_token_secret)
api = tweepy.API(auth)
ard = serial.Serial('/dev/tty96B0', 115200)
ef tweet():
        today = datetime.datetime.now()
        msg = '(My Doorbell) Ding dong! Someone was at the door at %s' % \
                today.strftime('%d/%m/%Y %H:%M')
        print(msg)
        api.update_status(msg)
        time.sleep(2)
if __name__ == '__main__':
        print("Welcome to the tweeting doorbell! To quit, press CTRL + C")
        try:
                while True:
                        ardOut = ard.readline()
                        if ardOut.find("tweet") != -1:
                                tweet()
        except KeyboardInterrupt:
                print("CTRL-C!! Exiting...")
~

Step 7: Mounting the Hardware

Connect the Button Grove Board to connector D4.

Connect the Buzzer Grove Board to connector D5.

Connect the Led Grove Board to connector D3 and Connect an LED to D1 connector at this board.

Step 8: Run!

Run

make run
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX
- [COMPUTED]           ARDMK_DIR = /usr/share/arduino (relative to Common.mk)
- [AUTODETECTED]       ARDUINO_DIR = /usr/share/arduino
- [AUTODETECTED]       ARDUINO_VERSION = 105
- [DEFAULT]            ARDUINO_SKETCHBOOK = /home/linaro/sketchbook
- [BUNDLED]            AVR_TOOLS_DIR =
/usr/share/arduino/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = /usr/share/arduino/libraries
(from ARDUINO_DIR)
- [DEFAULT]            ARDUINO_CORE_PATH =
/usr/share/arduino/hardware/arduino/cores/arduino
- [COMPUTED]           ARDUINO_VAR_PATH =
/usr/share/arduino/hardware/arduino/variants (from ARDUINO_DIR)
- [COMPUTED]           BOARDS_TXT =
/usr/share/arduino/hardware/arduino/boards.txt (from ARDUINO_DIR)
- [DEFAULT]            USER_LIB_PATH =
/home/linaro/sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh
- [DEFAULT]            BOARD_TAG = uno
- [COMPUTED]           OBJDIR = build-uno (from BOARD_TAG)
- [DETECTED]           MONITOR_BAUDRATE = 115200  (in sketch)
- [DEFAULT]            OPTIMIZATION_LEVEL = s
- [DEFAULT]            MCU_FLAG_NAME = mmcu
- [DEFAULT]            CFLAGS_STD = -std=gnu99
- [COMPUTED]           DEVICE_PATH = /dev/tty96B0 (from MONITOR_PORT)
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT =
/usr/share/arduino/hardware/arduino/bootloaders (from ARDUINO_DIR)
-------------------------
mkdir -p build-uno
make reset
make[1]: Entering directory
'/home/linaro/Starter_Kit_for_96Boards/tweeting_doorbell'
/usr/bin/ard-reset-arduino  /dev/tty96B0
make[1]: Leaving directory
'/home/linaro/Starter_Kit_for_96Boards/tweeting_doorbell'
make do_upload
make[1]: Entering directory
'/home/linaro/Starter_Kit_for_96Boards/tweeting_doorbell'
/usr/share/arduino/hardware/tools/avr/../avrdude -q -V -D -p
atmega328p -C /usr/share/arduino/hardware/tools/avr/../avrdude.conf -c
arduino -b 115200 -P /dev/tty96B0 \
                -U flash:w:build-uno/tweeting_doorbell.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f
avrdude: reading input file "build-uno/tweeting_doorbell.hex"
avrdude: writing flash (2550 bytes):
avrdude: 2550 bytes of flash written
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done.  Thank you.
make[1]: Leaving directory
'/home/linaro/Starter_Kit_for_96Boards/tweeting_doorbell'
python tweeting_doorbell.py
Welcome to the tweeting doorbell! To quit, press CTRL + C
(My Doorbell) Ding dong! Someone was at the door at 24/12/2016 01:22
(My Doorbell) Ding dong! Someone was at the door at 24/12/2016 01:23

Step 9: Tweet!

Press the button. The buzzer will work ike a doorbell and a tweet will be send in your account.