{"id":30876,"date":"2020-04-03T13:48:35","date_gmt":"2020-04-03T05:48:35","guid":{"rendered":"\/blog\/?p=30876"},"modified":"2020-04-08T15:36:42","modified_gmt":"2020-04-08T07:36:42","slug":"wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera","status":"publish","type":"post","link":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/","title":{"rendered":"Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera"},"content":{"rendered":"\n<p>Now you can make an affordable thermal camera with <a href=\"https:\/\/www.seeedstudio.com\/Wio-Terminal-p-4509.html\">Wio Terminal<\/a> and <a href=\"https:\/\/www.seeedstudio.com\/Grove-Infrared-Temperature-Sensor-Array-AMG8833.html\">Grove &#8211; Infrared Temperature Sensor Array (AMG8833)<\/a>. The total cost for all the components is less than $80 and you can get a low-cost&nbsp;<a href=\"https:\/\/www.flir.com\/\">FLIR\u2122<\/a>&nbsp;like a thermal imagining camera with ease. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"449\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2020\/04\/IRcamera.gif\" alt=\"\" class=\"wp-image-30897\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">What is infrared, and how to &#8220;see&#8221; and use it<\/h3>\n\n\n\n<p>To start with, let&#8217;s take a quick look at infrared. <strong>Infrared<\/strong>&nbsp;(<strong>IR<\/strong>), or&nbsp;<strong>infrared light<\/strong>, is&nbsp;electromagnetic radiation&nbsp;(EMR) with&nbsp;longer<a href=\"https:\/\/en.wikipedia.org\/wiki\/Wavelength\"> wavelengths<\/a>&nbsp;compared with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Light\">visible light<\/a>, which makes it invisible to the human eye in general condition. Most of the&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Thermal_radiation\">thermal radiation<\/a>&nbsp;emitted by objects near room temperature is infrared. (Ref:&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Infrared\">Wikipedia<\/a>) <\/p>\n\n\n\n<p>Human eyes cannot &#8220;see&#8221; Infrared light since it has longer wavelengths than visible light, but a thermal infrared camera can provide a simple solution. It can detect&nbsp;<strong>infrared<\/strong>&nbsp;energy and convert it into a picture with different colors, showing the temperature of detected items.<\/p>\n\n\n\n<p>Below is some typical application of  IR thermal imaging camera:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Non-contact temperature measurements in medical care<\/li><li>Fire prevention systems<\/li><li>Intrusion\/Movement detection<\/li><li>Presence detection \/ Person localization<\/li><li>Sensing elements for smart home<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Build a DIY IR Thermal Imaging Camera <\/h2>\n\n\n\n<p>To set you back a little, the resolution of the Grove &#8211; Infrared Temperature Sensor Array (AMG8833) is only 8 x 8 (64 Pixels), which in some cases is good enough. So Linear Interpolation is used in the code to expand to 70 x 70 (4900 Pixels) for a much better indication.<\/p>\n\n\n\n<p>This demo is inspired by&nbsp;<a href=\"https:\/\/www.youtube.com\/watch?v=A9F1ezGgaC4&amp;t=365s\">Kris Kasprzak&#8217;s video<\/a>. Several modifications were made to make it compatible with Wio Terminal and Grove &#8211; Infrared Temperature Sensor Array (AMG8833). Most Graphics are now first drawn to TFT LCD Sprites first to improve overall performance and faster frame rate. We also added a crosshair in the middle of the screen and showing the temperature at the crosshair. By the way, you can turn on or off the reference line on the screen by clicking the right button upon Wio Terminal.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2020\/04\/IMG_7898-1030x1030.jpg\" alt=\"\" class=\"wp-image-30903\" width=\"300\" height=\"300\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-1030x1030.jpg 1030w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-300x300.jpg 300w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-80x80.jpg 80w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-768x768.jpg 768w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-1536x1536.jpg 1536w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-2048x2048.jpg 2048w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-1024x1024.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><figcaption>With reference line<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-medium is-resized\"><img decoding=\"async\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2020\/04\/IMG_7899-300x300.jpg\" alt=\"\" class=\"wp-image-30904\" width=\"300\" height=\"300\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7899-300x300.jpg 300w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7899-1030x1030.jpg 1030w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7899-80x80.jpg 80w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7899-768x768.jpg 768w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7899-1536x1536.jpg 1536w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7899-2048x2048.jpg 2048w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7899-1024x1024.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><figcaption>Without reference line<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Hardware Requirement<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.seeedstudio.com\/Wio-Terminal-p-4509.html\">Wio Terminal<\/a><\/li><li><a href=\"https:\/\/www.seeedstudio.com\/Grove-Infrared-Temperature-Sensor-Array-AMG8833.html\">Grove &#8211; Infrared Temperature Sensor Array (AMG8833)<\/a><\/li><li><a href=\"https:\/\/www.seeedstudio.com\/Wio-Terminal-Chassis-Battery-p-4516.html\">Wio Terminal Battery Chassis<\/a><\/li><li><a href=\"https:\/\/www.seeedstudio.com\/Grove-Blue-Wrapper-1-1-4-PCS-pac-p-2580.html\">Grove &#8211; Wrapper<\/a> (used to fix your Grove and keep your demo safe)<\/li><\/ul>\n\n\n\n<p class=\"has-background has-pale-cyan-blue-background-color\">Note: The Wio Terminal and battery chassis used in this post are demos for testing, so their outlook is slightly different from the pictures at the right. For example, the button of Wio Terminal should be blue, and the enclosure of the battery chassis should be white.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1030\" height=\"484\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2020\/04\/\u622a\u5c4f2020-04-01\u4e0b\u53485.11.08-1030x484.png\" alt=\"\" class=\"wp-image-30908\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/\u622a\u5c4f2020-04-01\u4e0b\u53485.11.08-1030x484.png 1030w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/\u622a\u5c4f2020-04-01\u4e0b\u53485.11.08-300x141.png 300w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/\u622a\u5c4f2020-04-01\u4e0b\u53485.11.08-768x361.png 768w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/\u622a\u5c4f2020-04-01\u4e0b\u53485.11.08-1536x723.png 1536w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/\u622a\u5c4f2020-04-01\u4e0b\u53485.11.08-1024x482.png 1024w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/\u622a\u5c4f2020-04-01\u4e0b\u53485.11.08.png 1722w\" sizes=\"(max-width: 1030px) 100vw, 1030px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Software Requirement<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Install the LCD screen Library&nbsp;<code>Seeed_Arduino_LCD<\/code>, please visit&nbsp;<a href=\"http:\/\/wiki.seeedstudio.com\/Wio-Terminal-LCD-Overview\/\">Wio Terminal LCD<\/a>&nbsp;for more information.<\/li><li>Visit the&nbsp;<a href=\"https:\/\/github.com\/Seeed-Studio\/Seeed_AMG8833\">Seeed_AMG8833<\/a>&nbsp;repositories and download the entire repo to your local drive.<ul><li>Now, the Seeed_AMG8833 library can be installed to the Arduino IDE. Open the Arduino IDE, and click&nbsp;<code>sketch<\/code>&nbsp;-&gt;&nbsp;<code>Include Library<\/code>&nbsp;-&gt;&nbsp;<code>Add .ZIP Library<\/code>, and choose the&nbsp;<code>Seeed_AMG8833<\/code>&nbsp;file that you&#8217;ve have just downloaded.<\/li><\/ul><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arduino-instructions\">Setup Instructions<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Plugin the Grove &#8211; Infrared Temperature Sensor Array (AMG8833) to the Grove I2C Interface of Wio Terminal.<\/li><li>Download the Complete code&nbsp;<a href=\"https:\/\/files.seeedstudio.com\/wiki\/Wio-Terminal\/res\/ThermalCamera.ino\">here<\/a>&nbsp;or copy the code at the end of this page.<\/li><li>Upload the code.<\/li><\/ul>\n\n\n\n<p>Now you can turn on Wio Terminal and have a try of your new IR thermal imaging camera!<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"419\" height=\"259\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2020\/04\/QQ20200401-174927.gif\" alt=\"\" class=\"wp-image-30910\"\/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"420\" height=\"216\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2020\/04\/QQ20200402-162503.gif\" alt=\"\" class=\"wp-image-30929\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Explore More at Our Github &amp; Forum<\/h2>\n\n\n\n<p>Want to know more about Wio Terminal? Our brand-new Forum has been released and is waiting for you to join our discussion!  Feel free to post your questions or any technical issue about&nbsp;Wio Terminal&nbsp;at our <a href=\"https:\/\/forum.seeedstudio.com\/c\/products\/wio-terminal\/85\">forum<\/a>.  We can\u2019t wait to hear your voices and welcome all suggestions! <\/p>\n\n\n\n<p>In case of anyone having no idea of what Wio Terminal is, let\u2019s take a look at it together!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">A Brief Introduction of Wio Terminal<\/h3>\n\n\n\n<p><a href=\"https:\/\/www.seeedstudio.com\/Wio-Terminal-p-4509.html\">Wio Terminal<\/a>&nbsp;is a simple and tiny device to build I\/O with the physical world. It is an ATSAMD51-based Dev. board with wireless connectivity supported by Realtek RTL8720DN.<\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Wio Terminal | ATSAMD51 Core with Realtek RTL8720DN BLE 5.0 &amp; Wi-Fi 2.4G\/5G Dev Board\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/HSkqHrpk7FM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"complete-code\">Complete Code<\/h3>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong>Note:<\/strong>&nbsp;To boost up performance and frame rate of this IR Thermal Imaging Camera, you can boost the Wio Terminal CPU Speed to 200MHz. Select&nbsp;<code>Tools<\/code>&nbsp;-&gt;&nbsp;<code>CPU Speed<\/code>&nbsp;-&gt;&nbsp;<code>200MHz(Overclock)<\/code><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2020\/04\/CPUboost-1030x983.png\" alt=\"\" class=\"wp-image-30895\" width=\"515\" height=\"492\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/CPUboost-1030x983.png 1030w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/CPUboost-300x286.png 300w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/CPUboost-768x733.png 768w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/CPUboost-1024x977.png 1024w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/CPUboost.png 1050w\" sizes=\"(max-width: 515px) 100vw, 515px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\n\n  This program is for upsizing an 8 x 8 array of thermal camera readings\n  it will size up by 10x and display to a 240 x 320\n  interpolation is linear and \"good enough\" given the display is a 5-6-5 color palet\n  Total final array is an array of 70 x 70 of internal points only\n\n  Revisions\n  1.0     Kasprzak      Initial code\n  1.1     Anson(Seeed Studio)  Adapted to Wio Terminal with Grove - Infrared Sensor(AMG8833)\n\n*\/\n\n#include &lt;Seeed_AMG8833_driver.h>\n#include &lt;TFT_eSPI.h>                \/\/ Include the graphics library (this includes the sprite functions)  \n\nTFT_eSPI    tft = TFT_eSPI(); \nTFT_eSprite Display = TFT_eSprite(&amp;tft);  \/\/ Create Sprite object \"img\" with pointer to \"tft\" object\n\/\/ the pointer is used by pushSprite() to push it onto the TFT\n\nunsigned long CurTime;\n\nuint16_t TheColor;\n\/\/ start with some initial colors\nuint16_t MinTemp = 25;\nuint16_t MaxTemp = 35;\n\n\/\/ variables for interpolated colors\nbyte red, green, blue;\n\n\/\/ variables for row\/column interpolation\nbyte i, j, k, row, col, incr;\nfloat intPoint, val, a, b, c, d, ii;\nbyte aLow, aHigh;\n\n\/\/ size of a display \"pixel\"\nbyte BoxWidth = 3;\nbyte BoxHeight = 3;\n\nint x, y;\nchar buf[20];\n\n\/\/ variable to toggle the display grid\nint ShowGrid = -1;\n\n\/\/ array for the 8 x 8 measured pixels\nfloat pixels[64];\n\n\/\/ array for the interpolated array\nfloat HDTemp[80][80];\n\n\/\/ create the camara object\nAMG8833 ThermalSensor;\n\n\/\/Toggle the grid on and off\nvoid toggleGrid() {\n  ShowGrid = ShowGrid *-1;\n  Display.fillRect(15, 15, 210, 210, TFT_BLACK);\n  yield();\n}\n\nvoid setup() {\n  Serial.begin(115200);\n\n  \/\/ start the display and set the background to black\n  tft.begin();\n  tft.fillScreen(TFT_BLACK);\n\n  \/\/Interrupt to toggle Gird on and off\n  pinMode(WIO_KEY_A, INPUT);\n  attachInterrupt(digitalPinToInterrupt(WIO_KEY_A), toggleGrid, FALLING);\n\n  \/\/ set display rotation (you may need to change to 0 depending on your display\n  tft.setRotation(3);\n\n  \/\/ show a splash screen\n\n  tft.setCursor(20, 20);\n  tft.setTextColor(TFT_BLUE, TFT_BLACK);\n  tft.print(\"Thermal \");\n\n  tft.setTextColor(TFT_RED, TFT_BLACK);\n  tft.print(\"Camera\");\n\n  \/\/ let sensor boot up\n  bool status = ThermalSensor.init();\n  delay(100);\n\n  if (!status) {\n      Serial.print(\"Failed to initalized AMG8833\");\n  }\n\n  \/\/ read the camera for initial testing\n  ThermalSensor.read_pixel_temperature(pixels);\n\n  \/\/ check status and display results\n  if (pixels[0] &lt; 0) {\n    while (1) {\n      tft.setCursor(20, 40);\n      tft.setTextColor(TFT_RED, TFT_BLACK);\n      tft.print(\"Readings: FAIL\");\n      delay(500);\n    }\n  }\n  else {\n    tft.setCursor(20, 40);\n    tft.setTextColor(TFT_GREEN, TFT_BLACK);\n    tft.print(\"Readings: OK\");\n    delay(2000);\n  }\n\n  tft.fillScreen(TFT_BLACK);\n\n  Display.createSprite(TFT_HEIGHT, TFT_WIDTH);\n  Display.fillSprite(TFT_BLACK); \n\n  \/\/ get the cutoff points for the color interpolation routines\n  \/\/ note this function called when the temp scale is changed\n  Getabcd();\n\n  \/\/ draw a legend with the scale that matches the sensors max and min\n  DrawLegend();\n\n}\n\nvoid loop() {  \n  CurTime = millis();\n\n  \/\/ draw a large white border for the temperature area\n  Display.fillRect(10, 10, 220, 220, TFT_WHITE);\n\n  \/\/ read the sensor\n  ThermalSensor.read_pixel_temperature(pixels);\n\n  \/\/ now that we have an 8 x 8 sensor array\n  \/\/ interpolate to get a bigger screen\n  \/\/ interpolate the 8 rows (interpolate the 70 column points between the 8 sensor pixels first)\n  for (row = 0; row &lt; 8; row ++) {\n    for (col = 0; col &lt; 70; col ++) {\n      \/\/ get the first array point, then the next\n      \/\/ also need to bump by 8 for the subsequent rows\n      aLow =  col \/ 10 + (row * 8);\n      aHigh = (col \/ 10) + 1 + (row * 8);\n      \/\/ get the amount to interpolate for each of the 10 columns\n      \/\/ here were doing simple linear interpolation mainly to keep performace high and\n      \/\/ display is 5-6-5 color palet so fancy interpolation will get lost in low color depth\n      intPoint =   (( pixels[aHigh] - pixels[aLow] ) \/ 10.0 );\n      \/\/ determine how much to bump each column (basically 0-9)\n      incr = col % 10;\n      \/\/ find the interpolated value\n      val = (intPoint * incr ) +  pixels[aLow];\n      \/\/ store in the 70 x 70 array\n      \/\/ since display is pointing away, reverse row to transpose row data\n      HDTemp[ (7 - row) * 10]<div class = \"one \">\r\n    \r\n    <\/div><div class = \"clear\"><\/div> = val;\n\n    }\n  }\n\n  \/\/ now that we have raw data with 70 columns\n  \/\/ interpolate each of the 70 columns\n  \/\/ forget Arduino..no where near fast enough..Teensy at > 72 mhz is the starting point\n\n  for (col = 0; col &lt; 70; col ++) {\n    for (row = 0; row &lt; 70; row ++) {\n      \/\/ get the first array point, then the next\n      \/\/ also need to bump by 8 for the subsequent cols\n      aLow =  (row \/ 10 ) * 10;\n      aHigh = aLow + 10;\n      \/\/ get the amount to interpolate for each of the 10 columns\n      \/\/ here were doing simple linear interpolation mainly to keep performace high and\n      \/\/ display is 5-6-5 color palet so fancy interpolation will get lost in low color depth\n      intPoint =   (( HDTemp[aHigh]<div class = \"one \">\r\n    \r\n    <\/div><div class = \"clear\"><\/div> - HDTemp[aLow]<div class = \"one \">\r\n    \r\n    <\/div><div class = \"clear\"><\/div> ) \/ 10.0 );\n      \/\/ determine how much to bump each column (basically 0-9)\n      incr = row % 10;\n      \/\/ find the interpolated value\n      val = (intPoint * incr ) +  HDTemp[aLow]<div class = \"one \">\r\n    \r\n    <\/div><div class = \"clear\"><\/div>;\n      \/\/ store in the 70 x 70 array\n      HDTemp[ row ]<div class = \"one \">\r\n    \r\n    <\/div><div class = \"clear\"><\/div> = val;\n    }\n  }\n\n\n  \/\/display the 70 x 70 array\n  DisplayGradient();\n\n  \/\/Crosshair in the middle of the screen\n  Display.drawCircle(115, 115, 5, TFT_WHITE);\n  Display.drawFastVLine(115, 105, 20, TFT_WHITE);\n  Display.drawFastHLine(105, 115, 20, TFT_WHITE);\n\n  \/\/Push the Sprite to the screen\n  Display.pushSprite(0, 0);\n\n  \/\/Displaying the temp at the middle of the Screen\n  tft.setRotation(3);\n  tft.setTextColor(TFT_WHITE);\n  tft.drawFloat(HDTemp[35][35], 2, 90, 20);\n\n  \/\/Uncomment this to print out frame rate\n  Serial.print(\"Frame rate: \"); Serial.println(1\/(0.001*(millis() - CurTime)));\n\n}\n\n\/\/ function to display the results\nvoid DisplayGradient() {\n\n  tft.setRotation(4);\n\n  \/\/ rip through 70 rows\n  for (row = 0; row &lt; 70; row ++) {\n\n    \/\/ fast way to draw a non-flicker grid--just make every 10 pixels 2x2 as opposed to 3x3\n    \/\/ drawing lines after the grid will just flicker too much\n    if (ShowGrid &lt; 0) {\n      BoxWidth = 3;\n    }\n    else {\n      if ((row % 10 == 9) ) {\n        BoxWidth = 2;\n      }\n      else {\n        BoxWidth = 3;\n      }\n    }\n    \/\/ then rip through each 70 cols\n    for (col = 0; col &lt; 70; col++) {\n\n      \/\/ fast way to draw a non-flicker grid--just make every 10 pixels 2x2 as opposed to 3x3\n      if (ShowGrid &lt; 0) {\n        BoxHeight = 3;\n      }\n      else {\n        if ( (col % 10 == 9)) {\n          BoxHeight = 2;\n        }\n        else {\n          BoxHeight = 3;\n        }\n      }\n      \/\/ finally we can draw each the 70 x 70 points, note the call to get interpolated color\n      Display.fillRect((row * 3) + 15, (col * 3) + 15, BoxWidth, BoxHeight, GetColor(HDTemp[row]<div class = \"one \">\r\n    \r\n    <\/div><div class = \"clear\"><\/div>));\n    }\n  }\n\n}\n\n\/\/ my fast yet effective color interpolation routine\nuint16_t GetColor(float val) {\n\n  \/*\n    pass in value and figure out R G B\n    several published ways to do this I basically graphed R G B and developed simple linear equations\n    again a 5-6-5 color display will not need accurate temp to R G B color calculation\n\n    equations based on\n    http:\/\/web-tech.ga-usa.com\/2012\/05\/creating-a-custom-hot-to-cold-temperature-color-gradient-for-use-with-rrdtool\/index.html\n\n  *\/\n\n  red = constrain(255.0 \/ (c - b) * val - ((b * 255.0) \/ (c - b)), 0, 255);\n\n  if ((val > MinTemp) &amp; (val &lt; a)) {\n    green = constrain(255.0 \/ (a - MinTemp) * val - (255.0 * MinTemp) \/ (a - MinTemp), 0, 255);\n  }\n  else if ((val >= a) &amp; (val &lt;= c)) {\n    green = 255;\n  }\n  else if (val > c) {\n    green = constrain(255.0 \/ (c - d) * val - (d * 255.0) \/ (c - d), 0, 255);\n  }\n  else if ((val > d) | (val &lt; a)) {\n    green = 0;\n  }\n\n  if (val &lt;= b) {\n    blue = constrain(255.0 \/ (a - b) * val - (255.0 * b) \/ (a - b), 0, 255);\n  }\n  else if ((val > b) &amp; (val &lt;= d)) {\n    blue = 0;\n  }\n  else if (val > d) {\n    blue = constrain(240.0 \/ (MaxTemp - d) * val - (d * 240.0) \/ (MaxTemp - d), 0, 240);\n  }\n\n  \/\/ use the displays color mapping function to get 5-6-5 color palet (R=5 bits, G=6 bits, B-5 bits)\n  return Display.color565(red, green, blue);\n\n}\n\n\/\/ function to get the cutoff points in the temp vs RGB graph\nvoid Getabcd() {\n\n  a = MinTemp + (MaxTemp - MinTemp) * 0.2121;\n  b = MinTemp + (MaxTemp - MinTemp) * 0.3182;\n  c = MinTemp + (MaxTemp - MinTemp) * 0.4242;\n  d = MinTemp + (MaxTemp - MinTemp) * 0.8182;\n\n}\n\n\/\/ function to draw a legend\nvoid DrawLegend() {\n\n  \/\/color legend with max and min text\n  j = 0;\n\n  float inc = (MaxTemp - MinTemp ) \/ 160.0;\n\n  for (ii = MinTemp; ii &lt; MaxTemp; ii += inc) {\n    tft.drawFastHLine(260, 200 - j++, 30, GetColor(ii));\n  }\n\n  tft.setTextSize(2);\n  tft.setCursor(245, 20);\n  tft.setTextColor(TFT_WHITE, TFT_BLACK);\n  sprintf(buf, \"%2d\/%2d\", MaxTemp, (int) (MaxTemp * 1.8) + 32);\n  tft.print(buf);\n\n  tft.setTextSize(2);\n  tft.setCursor(245, 210);\n  tft.setTextColor(TFT_WHITE, TFT_BLACK);\n  sprintf(buf, \"%2d\/%2d\", MinTemp, (int) (MinTemp * 1.8) + 32);\n  tft.print(buf);\n\n}\n\n\/\/ END OF CODE<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Now you can make an affordable thermal camera with Wio Terminal and Grove &#8211; Infrared<\/p>\n","protected":false},"author":3487,"featured_media":30903,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[3062,3003],"class_list":["post-30876","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-amg8833","tag-wio-terminal"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera - Latest News from Seeed Studio<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera - Latest News from Seeed Studio\" \/>\n<meta property=\"og:description\" content=\"Now you can make an affordable thermal camera with Wio Terminal and Grove &#8211; Infrared\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/\" \/>\n<meta property=\"og:site_name\" content=\"Latest News from Seeed Studio\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-03T05:48:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-08T07:36:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"2560\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Serene\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Serene\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/\",\"name\":\"Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera - Latest News from Seeed Studio\",\"isPartOf\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg\",\"datePublished\":\"2020-04-03T05:48:35+00:00\",\"dateModified\":\"2020-04-08T07:36:42+00:00\",\"author\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/0102457b277e33e4cdb544dd3ec2eab5\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#primaryimage\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg\",\"contentUrl\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg\",\"width\":2560,\"height\":2560},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.seeedstudio.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#website\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/\",\"name\":\"Latest News from Seeed Studio\",\"description\":\"Emerging IoT, AI and Autonomous Applications on the Edge\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.seeedstudio.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/0102457b277e33e4cdb544dd3ec2eab5\",\"name\":\"Serene\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/67d0ba8df1892d2ff8fd9057bbe8caf4?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/67d0ba8df1892d2ff8fd9057bbe8caf4?s=96&r=g\",\"caption\":\"Serene\"},\"url\":\"https:\/\/www.seeedstudio.com\/blog\/author\/serene\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera - Latest News from Seeed Studio","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/","og_locale":"en_US","og_type":"article","og_title":"Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera - Latest News from Seeed Studio","og_description":"Now you can make an affordable thermal camera with Wio Terminal and Grove &#8211; Infrared","og_url":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/","og_site_name":"Latest News from Seeed Studio","article_published_time":"2020-04-03T05:48:35+00:00","article_modified_time":"2020-04-08T07:36:42+00:00","og_image":[{"width":2560,"height":2560,"url":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg","type":"image\/jpeg"}],"author":"Serene","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Serene","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/","url":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/","name":"Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera - Latest News from Seeed Studio","isPartOf":{"@id":"https:\/\/www.seeedstudio.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#primaryimage"},"image":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#primaryimage"},"thumbnailUrl":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg","datePublished":"2020-04-03T05:48:35+00:00","dateModified":"2020-04-08T07:36:42+00:00","author":{"@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/0102457b277e33e4cdb544dd3ec2eab5"},"breadcrumb":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#primaryimage","url":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg","contentUrl":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg","width":2560,"height":2560},{"@type":"BreadcrumbList","@id":"https:\/\/www.seeedstudio.com\/blog\/2020\/04\/03\/wio-terminal-update-build-an-affordable-ir-thermal-imaging-camera\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.seeedstudio.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Wio Terminal Update: Build An Affordable IR Thermal Imaging Camera"}]},{"@type":"WebSite","@id":"https:\/\/www.seeedstudio.com\/blog\/#website","url":"https:\/\/www.seeedstudio.com\/blog\/","name":"Latest News from Seeed Studio","description":"Emerging IoT, AI and Autonomous Applications on the Edge","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.seeedstudio.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/0102457b277e33e4cdb544dd3ec2eab5","name":"Serene","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/67d0ba8df1892d2ff8fd9057bbe8caf4?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/67d0ba8df1892d2ff8fd9057bbe8caf4?s=96&r=g","caption":"Serene"},"url":"https:\/\/www.seeedstudio.com\/blog\/author\/serene\/"}]}},"modified_by":"Serene","views":6507,"featured_image_urls":{"full":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg",2560,2560,false],"thumbnail":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-80x80.jpg",80,80,true],"medium":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-300x300.jpg",300,300,true],"medium_large":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-768x768.jpg",640,640,true],"large":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-1030x1030.jpg",640,640,true],"1536x1536":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-1536x1536.jpg",1536,1536,true],"2048x2048":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-2048x2048.jpg",2048,2048,true],"visody_icon":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-scaled.jpg",32,32,false],"magazine-7-slider-full":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-1536x1020.jpg",1536,1020,true],"magazine-7-slider-center":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-936x897.jpg",936,897,true],"magazine-7-featured":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-1024x1024.jpg",1024,1024,true],"magazine-7-medium":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-720x380.jpg",720,380,true],"magazine-7-medium-square":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2020\/04\/IMG_7898-675x450.jpg",675,450,true]},"author_info":{"display_name":"Serene","author_link":"https:\/\/www.seeedstudio.com\/blog\/author\/serene\/"},"category_info":"<a href=\"https:\/\/www.seeedstudio.com\/blog\/category\/news\/\" rel=\"category tag\">News<\/a>","tag_info":"News","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/30876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/users\/3487"}],"replies":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/comments?post=30876"}],"version-history":[{"count":18,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/30876\/revisions"}],"predecessor-version":[{"id":31118,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/30876\/revisions\/31118"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/media\/30903"}],"wp:attachment":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/media?parent=30876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/categories?post=30876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/tags?post=30876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}