Last week was Linux Conf AU 2017, which is a community run Free and Open Source Software conference that is in a different A/NZ city every year. This year I'd managed to attend the Open Hardware MiniConf and was inspired to build something during the conference. I'm not sure how it occurred to me to build a 'Hug Detector' into my Conference badge, but it did and after talking about it with some fellow delegates, the feedback was overwhelmingly positive.

So after heading to my room early to get some sleep, I got sidetracked. Armed with an ESP8266 based D1 Mini, some sensors, a breadboard, and some wires I stayed up until 1am. Then a wild GitHub repository occurred.

I popped by the rego desk the next morning, to acquire an extra badge holder. Which was met with some initial quizzical expressions, followed by intrigue whilst handing it over. Sitting up the back of the sessions and stabbing myself several times, I managed to get something of a working concept.

That evening I set about tidying up the wires and got it working well enough with the sensors I had on hand. However I really wanted to get the Freepixels I'd attached to display feedback about 'Hug Quality' and was hitting a strange problem with the micro controllers memory disappearing when ever I utilised them. As it turns out there was a dev from Expressif Systems who was intrigued by my badge and when I mentioned my problem it was met with "Want me to take a look at the code".

As it turns out the bug was in how I was iterating over the LED modules:

for(i = 0; i <= NUM_LEDS; i++) {
    leds[i] = CRGB::Red;
    leds[i].maximizeBrightness();
    FastLED.show();
}

'NUM_LEDS' is configured as '2', but arrays start at '0' in a lot of languages (including c++) so I was iterating past the end of 'leds' array and corrupting the micro controllers memory. I'd missed that entirely and as I generally work in higher level scripting languages, this kind of thing normally blows up the runtime in quite an obvious way. Below is the single character change that fixed the problem.

for(i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Red;
    leds[i].maximizeBrightness();
    FastLED.show();
}

Overall I really enjoyed working on the project. It was a fun way to make new friends and make a positive contribution to what was an exceptional LCA. Here are some extra tweets that shared the joy <3


This content is available for you to use for free, even commercially, under a Creative Commons Attribution 4.0 International License

If you wish to support my work, please tip me on gittip.


Comments

comments powered by Disqus