This is an archived copy of all my blog posts which is irregularly updated.
  • Porting I2C code from Arduino to Atmel ASF

    I’m in the middle of writing the software for our very first LoRa device, and the module we used as a basis is based around an Atmel SAM D20 MCU. Which means writing code against Atmel Software Framework (ASF). I figured that porting the code to read a sensor over I2C to ASF would be very straight forward, but it took me 2 days. So for my future self: here’s how to read data from the MPU-6050 over I2C in ASF.

    Continue reading »

  • Live analyzing movement through machine learning

    Twice a year Telenor Digital organises an internal hackathon, a two-day offsite where we have the chance to mingle with other teams and work on things we’d normally never touch. Given Jan’s fascination with phone sensors he was wondering whether we could feed the data from the gyroscope and the accelerometer into a machine learning algorithm and that way classify what a person is doing. Could we create a model that would check the stream of data coming off these sensors and then tell whether the person is sitting, walking or dancing?

    Continue reading »

  • Using AWS IoT as your LoRa backend

    Last week during re:Invent, Amazon announced AWS IoT. If you ignore all the fluff on the product page, the service is essentially a message broker. You throw messages over MQTT to Amazon, and you can set up rules to act upon those messages, for example to store the messages in a database. In Telenor Digital we’re working quite a lot with LoRa, Semtech’s wide area network solution, and we figured it would be worth an experiment to see how we can integrate our network with AWS IoT.

    Continue reading »

  • Awesome JavaScript snippets

    I have been writing mostly C and C++ in the last months, hacking away on LoRa and drones, but I had the pleasure of doing a week of JavaScript again, and I was reminded how much I love this weird, quirk and beautiful language. So today a write-up of some very useful patterns that show the power of JS.

    Continue reading »

  • Flying a drone in your browser with WebBluetooth

    There are tons of devices around us, and the number is only growing. And more and more of these devices come with connectivity. From suitcases to plants to eggs. This brings new challenges: how can we discover devices around us, and how can we interact with them?

    Currently device interactions are handled by separate apps running on mobile phones. But this does not solve the discoverability issue. I need to know which devices are around me before I know which app to install. When I’m standing in front of a meeting room I don’t care about which app to install, or even what the name or ID of the meeting room is. I just want to make a booking or see availability, and as fast as possible.

    Continue reading »

  • Building a smart meeting room w/ LoRa and Physical Web

    Ah! An empty meeting room. The moment you sit down however you’re being kicked out by someone who apparently ‘reserved’ the damn thing, and you’ll have to start your quest for some quiet working space all over again. Annoying. So when you’re finally used to first checking the calendar for the room, you’ll start to notice that there are people reserving rooms that they are not using at all!

    As we see smart suitcases, connected plants, and egg management devices appear I was wondering why our meeting rooms are still so dumb. When companies are building ‘smart’ meeting rooms, they usually don’t get further than just hanging an iPad next to the entrance. It’s time to create a proper smart meeting room.

    Continue reading »

  • JSConf.us

    In the past years I have been speaking at a variety of events, meetups and conferences, but for a JavaScript focused developer there’s only one mother of all conferences: JSConf.us. Originally started in 2009, a time before node.js was released, and where jQuery was the hottest library; it has grown to be the de-facto conference for everyone in the JS world, with sister conferences all over the world. In 2014 I already had the wonderful opportunity to speak at JSConf EU (video) and JSConf.Asia (video), and this year I was invited to complete the trio and speak at the 2015 edition of JSConf.us in Amelia Island, Florida!

    Continue reading »

  • Hack your phone: turn your volume buttons into GPIO ports

    As described in Firefox OS as an IoT platform, we are re-using existing phone hardware to build Gonzo, our wireless camera. While this has some major benefits, like more mature software and a cheaper pricepoint, it also has a major downside: because a phone motherboard is not meant to be an IoT board it doesn’t offer any extensibility points.

    A standard IoT dev board like the Raspberry Pi or Arduino comes with a number of General Purpose Input/Output (GPIO) pins. As a hardware developer you can use these pins to add new functionality to your board. For example, you can add new sensors to the board. For Gonzo we ran into the issue that we would like to add a LED light to the device, but the phone mainboard we use does not have GPIO ports.

    But we’re creative thinkers, so time for a hardware hack! Let’s re-map the volume buttons of your phone into generic GPIO ports.

    Continue reading »

  • Compiling cwebp for Android with PNG/JPEG support

    TL;DR: Pre-configured git repo. Clone it and run ndk-build.

    In an earlier post I described that power consumption is our main issue with Gonzo. We need the camera to run for a month or so on a single charge, and everything you do with the camera eats power away. A major cost in terms of battery life is uploading the photos that the camera takes. The photos that we take are 640x480, encoded as JPEG at 70% quality. That gives an average file size of a bit over 50 KB, and that takes 13 seconds to upload over a 2G connection. If we can get that down, that means less transmission time, and thus less power consumption.

    There has been quite some fuss over new image formats that should compress better, of which BPG looked very promising. Unfortunately it’s built on top of x265, and licensing issues are withholding me from using it in any production system. Next thing: WebP, Googles image format based on VP8.

    Continue reading »

  • Firefox OS as an embedded platform: Adding a new API to read arbitrary files

    As described in an earlier blog post we’re using Firefox OS as the OS for Gonzo, our wireless camera. The big advantage is the great set of built-in APIs that we can use to leverage functionality around dialing/SMS/camera/power management. However there are a couple of things we missed from the platform.

    Because the way Firefox OS is architectured all user code, like the actual code that powers Gonzo, runs in a web context. That means that the code is isolated in a sandbox and we cannot execute code outside of the sandbox or outside our privilege level. For IoT or embedded purposes that is actually quite a shame, as all the functionality that you want to use needs to be built into Gecko (the JS engine that powers Firefox & Firefox OS). For normal developers this is actually great. If I want to monitor the value of the proximity sensor it is a lot easier to write:

    Continue reading »