MLX90640_arcadaCam example code

Microsoft's MakeCode platform for easy blocks-style programming

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Minshan
 
Posts: 9
Joined: Sun Dec 06, 2020 11:30 pm

MLX90640_arcadaCam example code

Post by Minshan »

I want to use Arduino to drive my thermal camera(MLX90640). Then,I open the example “Adafruit MLX90640-MLX90640_arcadaCam.” However, it can’t work. It said “Adafruit_Arcada does not name a type.“ But I have installed the libraries ”Adafruit Arcada”. (The attachment is the picture showing which I installed.) What’s wrong with it? Could you help me solve this problem? Thanks!


wrong mwssage:
MLX90640_arcadaCam:3:1: error: 'Adafruit_Arcada_Library' does not name a type

Adafruit_Arcada_Library arcada;

Code: Select all

#include <Adafruit_MLX90640.h>
#include <Adafruit_Arcada.h>
Adafruit_Arcada arcada;


Adafruit_MLX90640 mlx;
float frame[32*24]; // buffer for full frame of temperatures

//low range of the sensor (this will be blue on the screen)
#define MINTEMP 20

//high range of the sensor (this will be red on the screen)
#define MAXTEMP 35

//the colors we will be using
const uint16_t camColors[] = {0x480F,
0x400F,0x400F,0x400F,0x4010,0x3810,0x3810,0x3810,0x3810,0x3010,0x3010,
0x3010,0x2810,0x2810,0x2810,0x2810,0x2010,0x2010,0x2010,0x1810,0x1810,
0x1811,0x1811,0x1011,0x1011,0x1011,0x0811,0x0811,0x0811,0x0011,0x0011,
0x0011,0x0011,0x0011,0x0031,0x0031,0x0051,0x0072,0x0072,0x0092,0x00B2,
0x00B2,0x00D2,0x00F2,0x00F2,0x0112,0x0132,0x0152,0x0152,0x0172,0x0192,
0x0192,0x01B2,0x01D2,0x01F3,0x01F3,0x0213,0x0233,0x0253,0x0253,0x0273,
0x0293,0x02B3,0x02D3,0x02D3,0x02F3,0x0313,0x0333,0x0333,0x0353,0x0373,
0x0394,0x03B4,0x03D4,0x03D4,0x03F4,0x0414,0x0434,0x0454,0x0474,0x0474,
0x0494,0x04B4,0x04D4,0x04F4,0x0514,0x0534,0x0534,0x0554,0x0554,0x0574,
0x0574,0x0573,0x0573,0x0573,0x0572,0x0572,0x0572,0x0571,0x0591,0x0591,
0x0590,0x0590,0x058F,0x058F,0x058F,0x058E,0x05AE,0x05AE,0x05AD,0x05AD,
0x05AD,0x05AC,0x05AC,0x05AB,0x05CB,0x05CB,0x05CA,0x05CA,0x05CA,0x05C9,
0x05C9,0x05C8,0x05E8,0x05E8,0x05E7,0x05E7,0x05E6,0x05E6,0x05E6,0x05E5,
0x05E5,0x0604,0x0604,0x0604,0x0603,0x0603,0x0602,0x0602,0x0601,0x0621,
0x0621,0x0620,0x0620,0x0620,0x0620,0x0E20,0x0E20,0x0E40,0x1640,0x1640,
0x1E40,0x1E40,0x2640,0x2640,0x2E40,0x2E60,0x3660,0x3660,0x3E60,0x3E60,
0x3E60,0x4660,0x4660,0x4E60,0x4E80,0x5680,0x5680,0x5E80,0x5E80,0x6680,
0x6680,0x6E80,0x6EA0,0x76A0,0x76A0,0x7EA0,0x7EA0,0x86A0,0x86A0,0x8EA0,
0x8EC0,0x96C0,0x96C0,0x9EC0,0x9EC0,0xA6C0,0xAEC0,0xAEC0,0xB6E0,0xB6E0,
0xBEE0,0xBEE0,0xC6E0,0xC6E0,0xCEE0,0xCEE0,0xD6E0,0xD700,0xDF00,0xDEE0,
0xDEC0,0xDEA0,0xDE80,0xDE80,0xE660,0xE640,0xE620,0xE600,0xE5E0,0xE5C0,
0xE5A0,0xE580,0xE560,0xE540,0xE520,0xE500,0xE4E0,0xE4C0,0xE4A0,0xE480,
0xE460,0xEC40,0xEC20,0xEC00,0xEBE0,0xEBC0,0xEBA0,0xEB80,0xEB60,0xEB40,
0xEB20,0xEB00,0xEAE0,0xEAC0,0xEAA0,0xEA80,0xEA60,0xEA40,0xF220,0xF200,
0xF1E0,0xF1C0,0xF1A0,0xF180,0xF160,0xF140,0xF100,0xF0E0,0xF0C0,0xF0A0,
0xF080,0xF060,0xF040,0xF020,0xF800,};

uint16_t displayPixelWidth, displayPixelHeight;

void setup() {
  if (!arcada.arcadaBegin()) {
    Serial.print("Failed to begin");
    while (1);
  }
  arcada.displayBegin();
  // Turn on backlight
  arcada.setBacklight(255);
  
  Serial.begin(115200);
  //while (!Serial);
  
  arcada.display->fillScreen(ARCADA_BLACK);
  displayPixelWidth = arcada.display->width() / 32;
  displayPixelHeight = arcada.display->width() / 32; //Keep pixels square 

  delay(100);

  Serial.println("Adafruit MLX90640 Camera");
  if (! mlx.begin(MLX90640_I2CADDR_DEFAULT, &Wire)) {
    arcada.haltBox("MLX90640 not found!");
  }
  Serial.println("Found Adafruit MLX90640");

  Serial.print("Serial number: ");
  Serial.print(mlx.serialNumber[0], HEX);
  Serial.print(mlx.serialNumber[1], HEX);
  Serial.println(mlx.serialNumber[2], HEX);
  
  mlx.setMode(MLX90640_CHESS);
  mlx.setResolution(MLX90640_ADC_18BIT);
  mlx.setRefreshRate(MLX90640_8_HZ);
  Wire.setClock(1000000); // max 1 MHz
}


void loop() {
  uint32_t timestamp = millis();
  if (mlx.getFrame(frame) != 0) {
    Serial.println("Failed");
    return;
  }

  int colorTemp;
  for (uint8_t h=0; h<24; h++) {
    for (uint8_t w=0; w<32; w++) {
      float t = frame[h*32 + w];
      // Serial.print(t, 1); Serial.print(", ");

      t = min(t, MAXTEMP);
      t = max(t, MINTEMP); 
           
      uint8_t colorIndex = map(t, MINTEMP, MAXTEMP, 0, 255);
      
      colorIndex = constrain(colorIndex, 0, 255);
      //draw the pixels!
      arcada.display->fillRect(displayPixelWidth * w, displayPixelHeight * h,
                               displayPixelHeight, displayPixelWidth, 
                               camColors[colorIndex]);
    }
  }
  Serial.print((millis()-timestamp) / 2); Serial.println(" ms per frame (2 frames per display)");
  Serial.print(2000.0 / (millis()-timestamp)); Serial.println(" FPS (2 frames per display)");
}
Attachments
arcada library.png
arcada library.png (22.08 KiB) Viewed 847 times
Last edited by adafruit_support_carter on Wed Dec 09, 2020 3:46 pm, edited 1 time in total.
Reason: fix [code] tag

User avatar
Disciple
 
Posts: 852
Joined: Tue Jan 06, 2015 8:13 pm

Re: MLX90640_arcadaCam example code

Post by Disciple »

Which microcontroller are you using? Is it included on Adafruit's list of compatible boards?
I'm just another customer, but I did get a MLX90640 project to work.

Hallelujah!
Disciple

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: MLX90640_arcadaCam example code

Post by adafruit_support_carter »

Yep, good question. What Arduino board do you have?

User avatar
Minshan
 
Posts: 9
Joined: Sun Dec 06, 2020 11:30 pm

Re: MLX90640_arcadaCam example code

Post by Minshan »

I use MLX90640

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: MLX90640_arcadaCam example code

Post by adafruit_support_carter »

That's the sensor breakout. What are you attaching the MLX90640 to?

User avatar
Minshan
 
Posts: 9
Joined: Sun Dec 06, 2020 11:30 pm

Re: MLX90640_arcadaCam example code

Post by Minshan »

ESP32(NodeMCU-32S)
Attachments
131301549_695877744430357_8928988872891058226_n.jpg
131301549_695877744430357_8928988872891058226_n.jpg (245.68 KiB) Viewed 817 times

User avatar
adafruit2
 
Posts: 22111
Joined: Fri Mar 11, 2005 7:36 pm

Re: MLX90640_arcadaCam example code

Post by adafruit2 »

yeah arcada is for our boards that have screens built in - you will have to adapt the code to your display and display driver. maybe folks online have done something for you to use

User avatar
Minshan
 
Posts: 9
Joined: Sun Dec 06, 2020 11:30 pm

Re: MLX90640_arcadaCam example code

Post by Minshan »

Disciple wrote:Which microcontroller are you using? Is it included on Adafruit's list of compatible boards?
I'm just another customer, but I did get a MLX90640 project to work.

Hallelujah!
Disciple

Thanks for your reply. Can I ask you some questions?
Did you encounter the same problem? And how did you adjust your code?

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: MLX90640_arcadaCam example code

Post by adafruit_support_carter »

I did a test compile of the example against that target board and I did get the same error that you did.

The solution is not simple. You would need to adapt code written for a specific set of hardware to your setup.

The Arcada library is really only for use with the boards defined here:
https://github.com/adafruit/Adafruit_Ar ... ter/Boards

User avatar
Minshan
 
Posts: 9
Joined: Sun Dec 06, 2020 11:30 pm

Re: MLX90640_arcadaCam example code

Post by Minshan »

adafruit2 wrote:yeah arcada is for our boards that have screens built in - you will have to adapt the code to your display and display driver. maybe folks online have done something for you to use
Can you give me the thorough information of this board? Also the website where I can buy it. Thanks.

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: MLX90640_arcadaCam example code

Post by adafruit_support_carter »

The previously linked list of header files is the best source:
https://github.com/adafruit/Adafruit_Ar ... ter/Boards

The board names come after the Adafruit_Arcada_ prefix. You should be able to use that name to search and quickly get to a specific product page. More than one board exists. They are available in the Adafruit shop:
https://www.adafruit.com/

User avatar
Disciple
 
Posts: 852
Joined: Tue Jan 06, 2015 8:13 pm

Re: MLX90640_arcadaCam example code

Post by Disciple »

Minshan wrote:Thanks for your reply. Can I ask you some questions?
Did you encounter the same problem? And how did you adjust your code?
My MLX90640 project was developed using the Arcada library on an Adafruit PyBadge.
(The same setup ran the MLX90640_arcadaCam example.)
It was initially created on a Teensy 3.2 using code from SparkFun. It required libraries for managing I2C, SPI, ST7735R displays, MicroSD readers, and Adafruit_GFX. That sort of structure might be needed to recreate an arcadaCam clone using another processor, a fair task. Switching to a PyBadge would be much simpler. As you see fit. Hope this helps.

Hallelujah!
Disciple

Locked
Please be positive and constructive with your questions and comments.

Return to “MakeCode”