0

Newbie here !! Im trying to display the output of my MLX90614 sensor on mcufriend tft display (with arduino UNO). But unable to do so. I can only see the TFT being lit to white color, text -> "Target" flashes on screen for millisecond and then again white lit screen.

  1. But I tried tft-lcd sample codes, which are working fine &
  2. I also tried mlx90614 (mlxtext code), which is also working fine.

But I combined the two codes so as to output it on TFT, which doesnt work. Hence I think this code might have some issue. Im a beginner pls help!!

#include <Adafruit_TFTLCD.h> 
#include <Adafruit_GFX.h>    
#include <TouchScreen.h>
#include <Wire.h>
#include <Adafruit_MLX90614.h>

#define LCD_CS A3 
#define LCD_CD A2 
#define LCD_WR A1 
#define LCD_RD A0 
#define LCD_RESET A4 

#define BLACK   0x0000
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

boolean buttonEnabled = true;

void setup() {
  Serial.begin(9600);

  mlx.begin();
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(1);
  tft.fillScreen(WHITE);
  tft.drawRect(0,0,319,240,YELLOW);

}

void loop() {

  tft.setCursor(0,1);
  tft.setTextSize(2);
  tft.print("Target  ");
  tft.setTextColor(BLACK);
  tft.print(mlx.readObjectTempC());
  tft.print(" C");
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.println();
  delay(500);

}
  • look at #define LCD_CS A3 ... do you see it conflicting with another define? ... look for other conflicts – jsotola May 31 at 23:05
  • @jsotola, deleted all the unnecessary defines, still not working – vinita May 31 at 23:20
  • start with working tft code ... add a couple lines of mlx code an test ... repeat until failure – jsotola May 31 at 23:57
  • The Adafruit library Adafruit_MLX90614 already includes the wire library in the .h file and the constructor calls wire.begin in the .cpp file. Please try removing the wire library you've included in your sketch. If that doesn't solve the problem, follow jsotola's suggestion and add 1 line of code at a time to the working example until it "breaks". – VE7JRO Jun 1 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.