New domain and blog

New domain and blog
Please head over to my new domain to view my blog and current projects

Wednesday, 24 April 2013

Raspberry Pi temperature profile using LabVIEW

Connected to my Raspberry Pi is a DS18B20 temperature sensor which I have mounted inside the case roughly above the processor. I wanted to map the temperature profile inside the case and have a visual representation of it. To do this I joined up a Python script, an SQLite3 database and LabVIEW.


I only have one temperature sensor connected and the RasPi doesn't run very warm so this image is rather exaggerated. I'll explain a bit more later.

So I started off by writing a Python script that runs on my RasPi. It measures the temperature and then logs it to a SQLite3 database that I store in a shared folder on a mounted USB flash drive. I have accelerometer data in the database too, but that will be added a bit later.



That is all that happens on the RasPi. Next I wrote a LabVIEW program that queries the database over the network to get all the data. I need to do a bit of work on my query to just return the last line of data but that I'll add in future versions.

To query the SQLite3 database, I used the this toolkit which works really well and is super simple to get set up. Once I have the temperature, I need to display it on in user interface. This is where Sensor Mapping Express VI comes in really handy.


All you need to do is point to your .stl file and select where you want to the temperature sensors to sit on the RasPi. I used this model which I converted using Google SketchUp. This is where I had to use four dummy senors to be able to show the temperature difference. I have set the outside 4 sensors to 0 degrees Celsius and only sensor 0 is getting the temperature from the database. With more sensors this can be made a lot more accurate. As I said earlier, this is just to prove a concept for now.

Every 100ms I query the database, build an array with the temperature data and then apply it to the Sensor Mapping Express VI. The temperature profile then changes according to the surface temperature of the RasPi.

Here are the colours that I used for my mapping:

Temperature vs Colour mapping:
0 Celsius R-0 G-0 B-255
21.25 Celsius R-0 G-255 B-255
42.5 Celsius R-0 G-255 B-0
63.75 Celsius R-255 G-255 B-0
85 Celsius R-255 G-0 B-0

I have already connected up an ADXL345 accelerometer which is acquiring tilt and pitch values, so my next step is to be able to move the  model in LabVIEW as I move my physical RasPi. Should be some fun for a few more hours.

If you want a copy of my code, you can grab it over here.

Please feel free to leave any tips, comments or questions below.

Greg

No comments:

Post a Comment