Recently I got myself a new toy, which is actually a very useful toy, a thermal camera! The one I got was used from eBay, a FLIR ONE Pro “for Android” with USB type-C connector, this is how it looks like:
This is a pretty neat device as it attaches directly to the USB type–C port of a mobile phone (or other device). There is a second type-C connector on it which is only used for charging the internal battery. Why they included this is a bit beyond me, maybe they anticipated that not all Android phones would be able supply enough juice? The most important part though is the thermal image sensor. In the Pro version this has a resolution of 160×120 pixel and a thermal range from -20C to +400C! Additionally there is a regular visible light camera included which can be used to overlay a visible picture onto the thermal (IR) one.
Debugging Electronic With Thermal
The main reason why I bought it was because I needed to debug some embedded electronics with it. Sound weird? Well yes, it may. Sometimes during development you end up in the situation that your circuit still consumes too much energy and you have no idea why, the only thing you do know that it shouldn’t. In a former project I spent weeks chasing down some 10mA and was not able to find it. What makes it so hard is that first you do not know if it is a software or hardware problem. And once you settle on the software side in many designs you quickly drown in possible options – so many pins, so many functions, so many components. And these all have to play nice together! You have to be sure what each and every component does at any given time or you may end up inadvertently driving two signals against each other or feeding power though a logic line to some component.
Since electrical energy in circuits is turned into heat, a thermal camera is an awesome way to at least start to spot which of your components on a PCB gets warm. And if you are lucky, you know that it shouldn’t and can then look closer why this very thing still consumes power. In the before mentioned case we indeed found the sucker, which was a level shifter that got powered down in suspend but the host CPU was still driving a logic signal to – bam!
My current target for analysis is the Purism Librem 5 phone and seeing which of the components draws most energy to then hunt them all down 🙂
Getting It To Work
So the FLIR ONE Pro I got is intended for Android and with the FLIR Android app from the Google app store it works pretty much out of the box which is nice! The app has a bunch of nice features to play with and does it’s job. One nasty bit is though that FLIR always superimposes their company logo into the images takes, which is a bit annoying. But this is a USB device:
Bus 001 Device 009: ID 09cb:1996 FLIR Systems FLIR ONE Camera
Shouldn’t this also be able to work on Linux, on a regular laptop or so? First investigation shows, meh, not so easy, it is not a regular USB Video Class (UVC) device. Looking at the FLIR company website they offer a SDK for it, but only for Android and iOS, no hardware documentation and especially no Linux SDK. Pretty sad. Even more sad that they do not allow a free download of the SDK, you have to apply to get access, which Idid not do – this usually comes with a bunch of NDAs of sort, no thanks. But some more searching the net came up with the following Github project: https://github.com/fnoop/flirone-v4l2
Wow, this is awesome! Though I was sceptical at first since it only mentions the FLIR ONE and I had the ONE PRO. To get this to work one also needs something I have not know before, a Video4Linux loopback device drivers, here: https://github.com/umlaeute/v4l2loopback This kernel driver creates virtual V4L devices that a user space program can then feed video data into and other V4L applications will see this like any other regular V4L device, pretty cool!
The driver compiles cleanly for Linux 5.4.x and 5.5.x (I am running 5.5.3 as of today). After compiling the driver and the program and insmodding the driver:
insmod ./v4l2loopback.ko devices=3
and starting the application:
the camera is active. Now you can start grabbing images from any application that can take V4L video input, for testing I used Guvcview and got this, holding my hand over the sensor:
Isn’t that awesome!? Even with measurements! This is a great starting point for all kinds of application development. The low resolution of the shot here is the real physical resolution of the sensor – keep in mind, this is only 160×120. The higher the resolution of a thermal sensor the exponentially higher its cost. The FLIR One Pro has an official price of $399 – ouch!