Trinket-Powered Conference Room Occupancy Display

Similar documents
Interior Purse Light. Created by Becky Stern. Last updated on :41:08 PM UTC

Adafruit Capacitive Touch Sensor Breakouts

Toy Car Speed Timer. Created by Kirby Griese. Last updated on :13:49 PM UTC

Adafruit 8x16 LED Matrix FeatherWing

Adafruit 1.27" and 1.5" Color OLED Breakout Board

NeoMatrix 8x8 Word Clock

i2c/spi LCD Backpack Created by lady ada Last updated on :11:04 PM UTC

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Coffee Detonator: The TNT Plunger Grinder

Monochrome OLED Breakouts

Adafruit Mini TFT " 160x80

Adafruit APDS9960 breakout

Trellis 3D Printed Enclosure

Adafruit Color Sensors

Jewel Hair Stick. Created by Leslie Birch. Last updated on :47:17 PM UTC

Adafruit I2C FRAM Breakout

Feather Weather Lamp. Created by Ruiz Brothers. Last updated on :54:26 PM UTC

Circuit Playground Digital Input

0.96" mini Color OLED

Adafruit 8x16 LED Matrix FeatherWing

Celebration Spectacles

FLORA and GEMMA ICSP. Created by Becky Stern. Last updated on :42:16 PM UTC

Joy Featherwing. Created by Dean Miller. Last updated on :03:07 PM UTC

Pushrod Garage. Created by John Park. Last updated on :07:30 PM UTC

Bike Wheel POV Display

Magical Mistletoe. Created by Leslie Birch. Last updated on :45:29 PM UTC

Mad Science Test Tube Rack

DIY Circuit Playground Shields

Adafruit LED Sequins. Created by Becky Stern. Last updated on :02:00 AM UTC

Adafruit 7-Segment LED FeatherWings

1.8" TFT Display Breakout and Shield

Guardian Shield+ Zelda Breath of the Wild

Trinket NeoPixel LED Longboard

Mystery Box: NeoMatrix Mk I

Light-Up Angler Fish Embroidery

Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout

Solar Boost Bag. Created by Becky Stern. Last updated on :44:55 PM UTC

Alohamora Bottle. Created by Erin St Blaine. Last updated on :58:53 PM UTC

Adafruit TPL5110 Power Timer Breakout

Naughty or Nice Machine

Interactive Gift Box. Created by codingpro. Last updated on :47:40 AM UTC

NeoPixel Ring Bangle Bracelet

RGB LCD Shield. Created by lady ada. Last updated on :48:40 PM UTC

Remote Controlled LED Tea Light Sconce

Adafruit IO Basics: Analog Input

Adafruit LED Backpacks

Adafruit LED Backpacks

Neon LED Signs. Created by John Park. Last updated on :11:09 PM UTC

Chirping Plush Owl Toy

Adafruit CCS811 Air Quality Sensor

Adafruit AMG8833 8x8 Thermal Camera Sensor

MCP Bit DAC Tutorial

FLORA and GEMMA ICSP. Created by Becky Stern. Last updated on :30:55 PM EST

3D Printed Camera LED Ring

Crickit Dancing Marionette Kit Created by Dano Wall. Last updated on :03:11 PM UTC

Flora Brake Light Backpack

Adafruit LED Sequins. Created by Becky Stern. Last updated on :00:06 PM EST

LED Eyes. Created by Ruiz Brothers. Last updated on :50:55 AM UTC

Cup o' Sound. Created by Becky Stern. Last updated on :30:06 PM EST

Tent Lantern. Created by Timothy Reese. Last updated on :17:25 AM UTC

Using IFTTT with Adafruit IO to Make an IoT Door Detector

Adafruit IO Basics: Digital Output

Sewable NeoPixels. Created by Becky Stern. Last updated on :50:14 PM EDT

MCP Bit DAC Tutorial

Arduino Lesson 6. Digital Inputs

LED Breath Stats Mask

Introducing Adafruit Trellis

Clockwork Goggles. Created by John Park. Last updated on :03:10 PM UTC

Adafruit IO Basics: Digital Input

NeoPixel Basketball Hoop

Adafruit Si5351 Clock Generator Breakout

Portable Apple Watch Charger

Adafruit TPL5111 Reset Enable Timer Breakout

3D Printed LED Knuckle Jewelry

FPV Mini Display. Created by Ruiz Brothers. Last updated on :00:18 PM UTC

GPS Logging Dog Harness

Mystical LED Halloween Hood

Ultrasonic Ruler. Created by Ruiz Brothers. Last updated on :08:28 PM UTC

IS31FL x9 Charlieplexed PWM LED Driver

Snake Charmer Box. Created by Dano Wall. Last updated on :07:25 PM UTC

TSL2561 Luminosity Sensor

Adafruit ATWINC1500 WiFi Breakout

Adabot Operation Game

FLORA TV-B-Gone. Created by Becky Stern. Last updated on :32:57 PM UTC

'Sup Brows. Created by Kate Hartman. Last updated on :52:04 PM UTC

Getting Started with FLORA

Adafruit DRV2605 Haptic Controller Breakout

3D Printed Google AIY Voice Kit

Audio Prank Gift Box. Created by Becky Stern. Last updated on :46:15 PM UTC

Prophet 600 GliGli mod

Camera LED Ring Light

Getting Started with FLORA

ISS Pin. Created by Leslie Birch. Last updated on :27:30 PM UTC

MLX90393 Wide-Range 3-Axis Magnetometer

FeatherWing Proto, Doubler and Tripler

Adafruit PCF8523 Real Time Clock

Adafruit AS channel Visible Light Sensor

Adafruit AM2320 Sensor

Circuit Playground Kaleidoscope

CircuitPython Media Dial

Transcription:

Trinket-Powered Conference Room Occupancy Display Created by Mike Barela Last updated on 2018-08-22 03:38:56 PM UTC

Guide Contents Guide Contents Overview Build Wiring Diagrams Populating the Board Code Considerations Wrap-up Adjustment Mount 2 3 5 5 6 9 11 12 12 14 Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 2 of 14

Overview Every facility has a conference room or other meeting space. And when the door is closed, it is always a guessing game whether the room is occupied or not. This inevitably leads to someone opening the door and disturbing what is happening inside. It could interrupt a meeting or spoil an important experiment. Commercial sensor/indicator combinations can cost over $400 dollars. If you have many rooms, the cost could be prohibitive. This project started as an inquiry by the Indiana University IT Department who wrote to Adafruit asking if there was a less expensive alternative to commercial units by using Adafruit's Trinket mini-microcontroller. This project is inspired by that inquiry. Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 3 of 14

Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 4 of 14

Build The small weatherproof enclosure (http://adafru.it/903) is a good sized enclosure for the project. The 1/2 sized Perma Proto Board (http://adafru.it/571) fits inside the box and clears the rounded divots with a bit of modding.. The 2.1mm panel mount barrel jack (http://adafru.it/610) is used for power - solder power wires on prior to installation (large lug is positive). Drill a 1/2 inch hole just past the cover hole. The plastic dimple was chisled to fit it in that location. Thread the jack in securing with the included plastic screw ring. A cable gland is used to run the PIR sensor wires through the enclosure keeping things weathertight. Drill a 5/8 inch hole (for the large gland, a smaller if you use the small gland) between the power jack and the other case cover hole. There is a small lip on the case - I dremeled it down a bit to have the gland fit snug. You can run penetrations through the back as an alternative if you want the look to be "cable free". Best to make mounting holes in the back of the case if needed to screw the case into the wall. This would probably be harder later in the build given the amount of items we are putting in. The 1/2 Perma Proto is nearly perfect. The corners should be cut just a bit on one side and the hole on that side slightly enlarged to allow it to fit snug screwed on the brass mounting hole. A short M4 screw is fitted in the enlarged hole. The board should be mounted so the screw is in the standoff furthest from the penetrations. Wiring Diagrams A passive-infrared sensor (PIR) is the gold standard for tracking movement in a general area. It does not provide distance like ultrasonic or other sensors but can have a wide field of view and good sensitivity to warm bodies. A Trinket receives the signal from the PIR. When the room is occupied, the sensor tripped, Trinket will display a red X on an Adafruit 8x8 bi-color LED matrix. If there is no movement, a green square is displayed. The function of a PIR can be found in this older tutorial by LadyAda (https://adafru.it/d2h). Also Learning Arduino Lesson 17 (https://adafru.it/c2f) features this sensor. Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 5 of 14

Populating the Board You can refer to the Fritzing diagrams on the Overview Page for the parts placement. I used two pieces of female header, 5 pins each, to mount the Trinket to the board. This allows the Trinket to easily be removed for programming. A 4 position header mounts the display. Another couple pieces of header from the scrap box are used to steady the top end for an even mount. Socket headers are not required but make it very easy to change out components and wire underneath. Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 6 of 14

The wiring is straightforward: Pin 0 on Trinket to the display I2C data line Pin 2 on Trinket to the display I2C clock line BAT on Trinket to the + line on the protoboard which is connected to 5 volts GND on Trinket to the - line on the protoboard which is connected to power ground Pin 1 on Trinket is connected to a 1500 ohm resistor to +5 volts (available at Radio Shack, Maker Shed, and other electronics outlets) Pin 1 on Trinket is also connected to the PIR data line (center) The red power line on the PIR and display goes to 5 volt + line on the protoboard The black ground line on the PIR and display goes to the ground - line on the protoboard Be sure you interconnect the top and bottom power busses with interconnect wires (towards the left). I mounted pins to the power lines to plug in the power jack (upper left). I also put pins on power and Trinket Pin 1 to easily connect the PIR wire. Double check your wiring to the diagrams and pictures. Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 7 of 14

Mount the board inside the enclosure with the screw. If it does not fit, you must take some material off the right ends and enlarge the hole for the screw. Plug in the power from the power panel mount jack to the + and - on the board. Run a cable from the PIR to the +, -, and Pin 1 on Trinket per the Fritzing diagram. You can now plug the display in. Leave the Trinket out as we are going to program that next. Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 8 of 14

Code For Trinket, you need to have a modified Arduino Integrated Development Environment (IDE) to compile and load code. Please see the tutorial Introducing Trinket (https://adafru.it/ceu) for the steps necessary to set up your programming environment. New for 2016: The Arduino IDE Version 1.6.7 and later has support for Adafruit Trinket. We suggest downloading the latest IDE from arduino.cc and the latest Adafruit libraries noted below. Three Arduino libraries are used to facilitate programming: The Arduino IDE Wire library provides I2C communications between the Trinket and the display. The Adafruit_LEDBackpack code loads in the Wire library so we do not need to do it in the main sketch unless we want to use I2C communications for other devices. The Adafruit LED Backpack library (https://adafru.it/ali) has routines to talk to the display. This library was updated in 2016 to use the Trinket compatible Wire library. The Adafruit GFX library (https://adafru.it/aja) is required to accompany the backpack library. The statement to include this library is done in the LEDBackpack library. Using the Adafruit libraries take up a fair amount of space but simplifies programming. Please see the Adafruit tutorial All About Arduino Libraries (https://adafru.it/aym) for information on adding these libraries to your Arduino environment. Install the libraries into your arduinosketch/libraries directory. Restart the IDE to ensure the libraries load. Cut and paste the following code into your IDE window: /*************************************************** Adafruit Trinket-based Room Occupancy sensor and display Featuring a Trinket 5V and the 8x8 Bi-color LED Matrix and I2C Backpack For Trinket, this program is within 120 bytes of the maximum code size of 5,310 bytes. Adding significantly more functionality may not be possible. Version 2.0 New Wire Library support for newer IDE Mike Barela for Adafruit Industries ****************************************************/ // The Adafruit_LEDBackpack library will pull in the standard Arduino // Wire library and needs the Adafruit_GFX library to be installed also! #include "Adafruit_LEDBackpack.h" const int PIRpin = 1; // PIR signal pin on Trinket Pin #1 uint8_t pirstate = LOW; // Stores state of the PIR sensor Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix(); void setup() { pinmode(pirpin, INPUT); // Initial state is low matrix.begin(0x70); // pass in the address } Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 9 of 14

} static const uint8_t PROGMEM x_bmp[] = { B10000001, B01000010, B00100100, B00011000, B00011000, B00100100, B01000010, B10000001 }, box_bmp[] = { B11111111, B10000001, B10000001, B10000001, B10000001, B10000001, B10000001, B11111111 }; // X and square bitmaps void loop() { int sense = digitalread(pirpin); // Read PIR Sensor if(sense == HIGH) { // If high and it was low, sensor tripped if(pirstate == LOW) { // and we display a red X matrix.clear(); matrix.drawbitmap(0, 0, x_bmp, 8, 8, LED_RED); matrix.writedisplay(); pirstate = HIGH; } } else { if(pirstate == HIGH) { // If low and state was high, sensor set matrix.clear(); // and we sisplay a green box matrix.drawbitmap(0, 0, box_bmp, 8, 8, LED_GREEN); matrix.writedisplay(); pirstate = LOW; } } } Ensure you set the Arduino IDE as follows: Tools -> Board to: Adafruit Trinket 8MHz Tools -> Programmer to: USBtinyISP Press the verify checkmark icon to verify your code compiles. If it does not, check the code and the libraries. Note there are only a few bytes left in the code space so adding functionality might take up too much space. This includes adding the delay function. Take your Trinket out of the circuit and plug it into the USB cable. Then press the Trinket reset button on the board then quickly click the upload icon (right arrow) in the Arduino IDE. This will upload the code to the Trinket. Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 10 of 14

If you get an error on upload (and not on verify), try the sequence again. If you consistently have errors, see the Adafruit Trinket forum on steps to debug the process. Considerations The code space is very tight using all the libraries. More code space could be obtained by using low level I2C calls. This was done in the Space Invaders pendant tutorial (https://adafru.it/d2j). This would require additional work to get the correct calls coded and since this project works great as is, we didn't spend the extra hacking-time! Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 11 of 14

Wrap-up Adjustment The PIR has two adjustment potentiometers on the back. 1. The first adjusts the sensitivity of the sensor. You should start with a reading towards the "min" side, and adjust clockwise as necessary. 2. The second adjusts the time the sensor stays "latched" or in the on state. When testing, leave this at the left which is a short time. Adjust clockwise for longer intervals. Test the unit by making all the connections and the PIR is pointed away from movement or covered by a cardboard box. The green square should be displayed. Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 12 of 14

Move in front of the sensor and the red X should be displayed. If the display does not change, check your wiring to the sensor and the potentiometers. Once it is working, you can adjust the potentiometers to increase sensitivity and/or the delay used. Adafruit Industries https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display Page 13 of 14

One programming note: the Arduino delay software routine cannot be used with the libraries as it adds a bit too much code. Try to adjust using the PIR potentiometers. Mount Mount the display box near the entrance to the room monitored. Mount the PIR sensor so it has a "field of view" of a wide area of the inside of the room. For a conference room, the table area would be best (do not aim above peoples heads). Run power from an outlet to the display box. Ensure you have a 5 volt DC supply. If you only want the display to show through the clear cover, you can make a mask from white paper. You can have the LED display show through the paper or cut out a square just for the display. Adafruit Industries Last Updated: 2018-08-22 03:38:51 PM UTC Page 14 of 14