Things used in this project

Hardware components:
12994 02
Raspberry Pi 1 Model B+
HC-SR04 Ranging Detector Mod Distance Sensor
Adafruit 16mm Panel Mount Momentary Pushbutton - Black
Adafruit RGB Matrix HAT + RTC for Raspberry Pi - Mini Kit
Adafruit 64x32 RGB LED Matrix - 5mm pitch
Switching Power Supplies 110W 5V 22A 85-264VAC
Software apps and online services:
Ha 2up iot
Amazon Web Services AWS IoT
Simpleicon sns
Amazon Web Services AWS SNS
Simpleicon cognito
Amazon Web Services AWS Cognito
Hand tools and fabrication machines:
09507 01
Soldering iron (generic)


Button connected to Raspberry Pi
The button is connected to GPIO 18
Gpio listener example
Family Board completed
P 20160131 112130 1 p
Ultrasonic Sensor
GPIO used are 24 and 25
Hc sr04 tut 2


Family Board on Raspberry PiPython
Connect to raspberry pi using SSH
Command :
sudo python
import json
import ssl
import time
import subprocess
import os
import paho.mqtt.client as mqtt
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
import RPi.GPIO as GPIO

# GPIO 18 is used for arcade button
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)

devicecert = "/home/pi/aws/cert.pem"
devicekey = "/home/pi/aws/privateKey.pem"
servercert = "/home/pi/aws/root-CA.pem"
server = "<your aws server url>"

def on_message(client, userdata, msg):
    # Message received for led matrix, analyse it and send it to led matrix
    # When a message is publish by the mobile phone on topic familyboard/display
    # the message is sent to the led matrix
    print("Message: " + msg.topic + " Payload:" + str(msg.payload))

    # Message contains message to display and color indication 
    strPayload = msg.payload 
    colorPos = strPayload.find("color=")
    colorStr = strPayload[colorPos+6:]
    c = (255, 0, 0)

    if "red" in colorStr : 
        c = (252, 76, 2)
    if "blue" in colorStr : 
        c = (0, 122, 255)
    if "green" in colorStr :
        c = (109, 196, 79)
    #text = (str(msg.payload), (0, 0, 255))
    font = ImageFont.truetype("/usr/share/fonts/truetype/droid/DroidSans.ttf", 32)
    all_text = strPayload[0:colorPos]

    width, ignore = font.getsize(all_text)
    im ="RGB", (width + 30, 32), "black")
    draw = ImageDraw.Draw(im)

    x = 0
    t = all_text
    draw.text((x, 0), t, c, font=font)

    # The text with font and color is saved on a image in ppm format and sent
    # to the led matrix"test.ppm")
    os.system("./led-matrix -D 1 -c 2 -t 20 test.ppm")
def on_log(client, userdata, level, msg):
    print("Log: " + msg)

def on_connect(client, userdata, flags, rc):
    print("on_connect: ")

def button_pressed(channel):
    print("button pressed")
    message = "button pressed"
    client.publish("familyboard/button", message, qos, retain)
client = mqtt.Client("testThing01")
client.on_connect = on_connect
client.on_message = on_message
client.on_log = on_log
client.tls_set(servercert, devicecert, devicekey, ssl.CERT_REQUIRED, ssl.PROTOCOL_SSLv23)
client.connect(server, 8883, 60)


awsmsg = {'state':{ 'reported': {'powerup': 1 }}} #update on power up
payload = json.dumps(awsmsg)
client.publish(topic, payload ,qos, retain)

GPIO.add_event_detect(18, GPIO.FALLING, callback=button_pressed, bouncetime=75)

# set sonar
TRIG = 24 
ECHO = 25

print "Distance Measurement In Progress"


GPIO.output(TRIG, False)
print "Waiting For Sensor To Settle"

while True:
    GPIO.output(TRIG, True)
    GPIO.output(TRIG, False)

    while GPIO.input(ECHO)==0:
        pulse_start = time.time()

    while GPIO.input(ECHO)==1:
        pulse_end = time.time()

    pulse_duration = pulse_end - pulse_start
    distance = pulse_duration * 17150
    distance = round(distance, 2)

    if distance < 50 :
        print "Distance:",distance,"cm"
        message = "Sonar detection"
        client.publish("familyboard/sonar", message, qos, retain)
Family Board iPhone application
Sources of the iPhone application used for Family Board You have to change values in Constants.swift


Richard hd
Richard Seltrecht
3 projects • 8 followers
Thanks to Adafruit and Amazon.


Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback


Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog