Posts | Comments

Planet Arduino

Archive for the ‘script’ Category


Arduino Garage Door Opener is Security Minded

arduino, arduino hacks, garage door opener, handshake, python, script, Security, sl4a Commenti disabilitati su Arduino Garage Door Opener is Security Minded 

Arduino garage door opener

Do it yourself garage door openers must be all the rage nowadays. We just got word of another take on this popular idea. [Giles] was commissioned by his friend to find a way to control the friend’s garage door using a smart phone. The request was understandable, considering the costly garage door remote and the fact that the buttons on the expensive remote tended to fail after a while. The inspiration for this project came from some YouTube videos of other similar projects. Those projects all paired an Arduino with a Bluetooth headset in order to control the door from a mobile phone. [Giles] understood that while this would get the job done, it wouldn’t be very secure. Bluetooth headsets typically connect to mobile phones using a four digit PIN. Many of them have known default PINs and even if the default is changed, it wouldn’t take very long to guess a four digit PIN. [Giles] knew he had to find a more secure way.

While WiFi was an option, [Giles] decided that having the garage door hooked up to the internet would likely be a security risk, even if it did offer some potential interesting use cases.  He therefore opted to stick with Bluetooth, but decided to use the Seedstudio Bluetooth shield instead of a basic headset. The electronics are relatively simple. [Giles] simply plugged the Bluetooth shield into an Arduino Uno. [Giles] did have one problem with the Bluetooth shield though. The Bluetooth module did not accept many standard AT commands. He needed a way to force a disconnect of a mobile device if it failed authentication. After digging around, he discovered that the module had some extra exposed pads that he could likely use to accomplish that goal. The only problem was that they were expecting a 3.3V signal, and the Arduino works at 5V. The solution was simple. He setup a basic voltage divider using two resistors. This lowered the 5V signal from the Arduino to the required 3.3V. This provides the communication functionality to the mobile phone. He then realized that he could use a simple 12V automotive relay to control the garage door. To control the relay, he used the Freetronics relay control shield. The end result is a relatively simple stack of shields hooked up to a relay.

For the smart phone interface, [Giles] started out by trying to write a native Android application. Having little experience in Android development, he soon realized that it was going to take him longer than anticipated to get anything usable this way. He then decided to use SL4A. SL4A provides a scripting environment for Android and supports several different scripting languages. [Giles] was then able to write a Python script that can be executed on the smart phone. Many people would be tempted to write a really simple script that would just open the door and connect without any real thought about security. After all, this is a one-off obscure garage door opener. Security through obscurity! [Giles] is smarter than that. (altro…)


Script to query Gerber file outer dimensions

code, kicad, manufacturing, pcb, script Commenti disabilitati su Script to query Gerber file outer dimensions 

At Wayne & Layne, we design a lot of circuit boards. During the request-for-quote (RFQ) process for getting a PCB fabricated, the outside dimensions of the PCB are an important driver of the overall per-unit price. As part of the W&L “prepare PCB for RFQ” process, we have a little script that uses the PCB’s board outline Gerber file to determine the dimensions of the PCB’s bounding box.

Pass in the filename of the PCB “board outline” Gerber file, and it will print out the dimensions in both the original units (decimills for Gerbers exported from Kicad) as well as inches (again, assuming decimills). It does this by analyzing all the lines of the gerber file, and determining the minimum and maximum in both x and y directions. The script is based on a little chunk of code written by @laen on Twitter (who makes no claim to the code, and also runs the most excellent OSH Park PCB service). We’re releasing this script into the Public Domain, use it however you like.

#!/usr/bin/env python
# Gerber query script
# Usage: ./ board_edges.gbr
# Written by Matthew Beckler for Wayne and Layne, LLC
# Based on a script from @laen
# Released into the Public Domain. Have fun
def main():
    import sys
    if len(sys.argv) < 2:
        print "Usage: %s gerberfile" % sys.argv[0]
    import re
    filename = sys.argv[1]
    xmin = None
    xmax = None
    ymin = None
    ymax = None
    with open(filename, 'r') as fid:
        for line in fid:
            results ="^X(\d+)Y([\d-]+)", line)
            if results:
                x = int(
                y = int(
                if not xmin or x < xmin:
                    xmin = x
                if not ymin or y < ymin:
                    ymin = y
                if not xmax or x > xmax:
                    xmax = x
                if not ymax or y > ymax:
                    ymax = y
    print "Board dimensions:"
    w = xmax - xmin
    h = ymax - ymin
    print " ", (w, h), "original units"
    print "  (%.4f, %.4f) inches" % (w / 10000.0, h / 10000.0)
    print "  (%.4f, %.4f) mm" % (w / 10000.0*25.4 , h / 10000.0*25.4)
if __name__ == "__main__":

  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook