This is my first PoC for the BSides London 2019 badge - a Mood Badge. This page is a placeholder as the writeup will be long, as the road to this was long, winding and full of surprises and some magic smoke. But it’s all about the journey! I will tweet them out as they come…
TL;DR: What is it?
That is: the Bill of Materials, top row from left:
- Adafruit 1.2” 8x8 Matrix;
- A diode, it really doesn’t matter much what kind of, for this purpose :);
- Adafruit MiCS5524 CO, Alcohol and VOC Gas Sensor.
- Adafruit PowerBoost 1000 Charger - Rechargeable 5V Lipo USB Boost @ 1A - 1000C attached to a Lithium Ion Polymer Battery - 3.7v 1200mAh at the back;
- Arduino Micro.
- Adafruit VL53L0X Time of Flight Distance Sensor (it’s not really a Time of Flight Sensor but a laser ranging device, don’t get me started);
- Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor;
- Adafruit Standalone Momentary Capacitive Touch Sensor.
Plus one assembled BSides London 2019 badge. I do not have any deal with Adafruit, they just make cool things with Arduino libraries on which I have a lot to say but that will come later.
The idea and theory of operation (not quite practice, it’s a PoC after all!)
You may be aware of a fantastic (for people like me who are not really good at this whole talk-to-people skill) thing becoming popular with (infosec) cons: you can tag yourself with a coloured tag (I’m sorry but I’m not sure whose idea this was, I will update it when I find out):
- red: don’t talk to me;
- yellow: talk to me if we know each other;
- green: I want to talk to everyone.
I thought, therefore: how about being able to switch the tags during the day? I might feel okay for the first hours and then just want to hide away (and that is me, every time). The badge can, then, display three colours and you can switch between them at will.
Second thing, quite important for, again, people like me: personal space. The badge will start flashing when you get too close to me (~400mm in the current version). To save the battery, it will also dim the matrix as you move away from me in 15 brightness steps until around 1200mm when it switches it off.
You might sometimes want to extend beyond the green colour, destroy all OPSECs and just should HELLO IT’S ME to everyone. In this mode, the badge will scroll “Meadow BSidesLDN2019 Ellis”, in two colours - because why not.
The air can get stuffy on cons, for various reasons and with various things. In this mode the badge will use the gas sensor to measure the air quality (or an approximation of, it’s not calibrated) and display the result in the range of 1-24 on the LED matrix using three colours, one line per one value: green 1-8, yellow 9-16, red 17-24.
The first idea was to use the gesture sensor: it can sense up-down and left-right movements, so it can switch colours and modes… but the library leaves much to desire so had to drop it and use the momentary switch. It’s not the best idea as the badge and the sensor itself is picking a lot of noise - it works fine on my desk but when I’m wearing it it has a life of its own. WiP!
How do we switch between colours and modes though using one switch? Rotating them is not ideal as displaying text takes few seconds, and it’s really bad UX - yes, it’s a PoC but that doesn’t mean it has to be annoying. But we have three ‘modifier keys’ available:
- Shift: when the matrix is flashing;
- Control: when the matrix is solid;
- Alt: when the display is off.
How? The distance measurement is running all the time, so we have one variable that has three states available to modify the touch sensor function. You ‘use modifier keys’ then by adjusting the distance the badge is measuring by pointing it at various things and touching the sensor. So:
- Shift + touch: mode 2, display “Meadow BSidesLDN2019 Ellis” and return to mode 1;
- Control + touch: rotate through the colours: red, yellow, green, red;
- Alt + touch: mode 3 (get back to mode 1 with shift or control).
…has been in my head for the past three weeks, but was written on Sunday evening and through Monday so it’s quite horrible - but I will make it better before showing it :)
I have used Adafruit libraries for the sensors and the matrix; gas sensor is just a voltage output so that is analogRead() with some scaling, touch sensor is digital output so that’s digitalRead() with some debouncing. I have made up my own bargraph function as Adafruit has one… but not for this display so had to patch something together, quick and dirty.
If you feel intimidated by all this - please, stop right now! I will explain everything, this is just a quick overview.