GEMMA ROUND 2

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
bropium
 
Posts: 4
Joined: Mon Nov 03, 2014 7:26 pm

GEMMA ROUND 2

Post by bropium »

My apologies for my previous post. After not getting any responses, I looked up the proper way to post for best answers (http://forums.adafruit.com/viewtopic.php?f=25&t=12170 - for those who don't know).

So here goes my third post.

I am working the DIY FLIR Light Painting - Heat Map Photography (https://learn.adafruit.com/diy-flir-lig ... y?view=all). I am not making the gun, but just using the temperature sensor and lights for a different project.

The problem that I am having is getting the lights to change from blue to red due to temperature. The NeoPixel Ring lights up with which ever color I put as the lowest temperature. For example:
The ring lights up as blue when -
#define COLDTEMP 60
#define HOTTEMP 80

But it lights up as red when -
#define COLDTEMP 80
#define HOTTEMP 60

I know the temperature sensor works because I tested it with the "Using Melexis MLX90614 Non-Contact Sensors" (https://learn.adafruit.com/using-melexi ... g-and-test).

I am positive that my wiring is correct, and that GEMMA is set-up properly. I followed the "Introducing GEMMA" guide (https://learn.adafruit.com/introducing-gemma).

The last thing to check is the code, which I have the least experience with. I did swap out the 24x NeoPixel Ring for the 12x NeoPixel Ring, but other than that, I followed the guide as written.

Code: Select all

/*************************************************** 
This is a library for the MLX90614 temperature sensor SPECIFICALLY
FOR USE WITH TINYWIREM ON TRINKET/GEMMA

Requires the latest TinyWireM with repeated-start support
https://github.com/adafruit/TinyWireM

NOT FOR REGULAR ARDUINOS! Use the regular Adafruit_MLX90614 for that

  Designed specifically to work with the MLX90614 sensors in the
  adafruit shop
  ----> https://www.adafruit.com/products/1748
  ----> https://www.adafruit.com/products/1749

  These sensors use I2C to communicate, 2 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit in any redistribution
 ****************************************************/

#include <TinyWireM.h>
#include <Adafruit_MiniMLX90614.h>
#include <Adafruit_NeoPixel.h>

// change these to adjust the range of temperatures you want to measure 
// (these are in Farenheit)
#define COLDTEMP 60
#define HOTTEMP  80


#define PIN 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN, NEO_GRB + NEO_KHZ800);

Adafruit_MiniMLX90614 mlx = Adafruit_MiniMLX90614();

void setup() {
  mlx.begin();  
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  uint8_t red, blue;
  float temp = mlx.readObjectTempF();

  if (temp < COLDTEMP) temp = COLDTEMP;
  if (temp > HOTTEMP) temp = HOTTEMP;

  // map temperature to red/blue color
  // hotter temp -> more red
  red = map(temp, COLDTEMP, HOTTEMP, 0, 255);  
  // hotter temp -> less blue
  blue = map(temp, COLDTEMP, HOTTEMP, 255, 0);  

  colorWipe(strip.Color(red, 0, blue), 0);
  
  delay(50); // can adjust this for faster/slower updates
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}
Thanks for the help!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: GEMMA ROUND 2

Post by adafruit_support_mike »

What value are you getting from this line?

Code: Select all

  float temp = mlx.readObjectTempF();

User avatar
bropium
 
Posts: 4
Joined: Mon Nov 03, 2014 7:26 pm

Re: GEMMA ROUND 2

Post by bropium »

Do I just upload that code onto GEMMA and it will display a value?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: GEMMA ROUND 2

Post by adafruit_support_mike »

That line is already in your sketch.

The Trinket and Gemma can't do Serial output to the computer, so you'll have to find some other way to display the information.

Try this:

Code: Select all

    int i=0;
    float t = temp;

    while ( t > 0 ) {
        strip.setPixelColor( i, strip.color( 100, 100, 100 ) );
        i++;
        t -= 10;
    }
    strip.show();
    delay( 2000 );
That will light one pixel for every 10 degrees of the temperature reading, giving you at least a general idea of the value.

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

Return to “Other Products from Adafruit”