Tricorder project, coding advice needed!

llo Everyone,

I'm working on an arduino based project, although I'm a beginner I managed to get some codes working until I got really stuck, which is now.

So basically the project is to have an arduino board with a couple of environmental sensors on it, please see the following link for more details:

I have chosen 4 sensors to work on, which are:

  • Ambient Temperature and Humidity: Measurement Specialties HTU21D
  • 3-Axis Magnetometer: Honeywell HMC5883L
  • Low-resolution thermal camera: Melexis MLX90620 16×4
  • Spectrometer: Hamamatsu C12666MA micro-spectrometer

I purchased an Arduino board MEGA 2560 along with an Adafruit 2.8" TFT Resistive Shield, to mount all the sensors and monitor results from them.

(I have attached my codes) I managed to make a basic interface for the screen and the magnetometer and everything was working perfectly fine, until I moved to the next step which was connecting the IR MLX sensor. After adding the connections for the sensor, the codes I had no longer worked, I've been even trying to run a graphics test on the screen it wouldn't even work. I still haven't got the codes for the IR sensor since I have no idea how to program it right now, but only have the connection made.

So I'm wondering why my codes are no longer working, and if I could get some advice on that, It would be highly appreciated!

Thank You.

screen_Mag.ino (3.23 KB)

#include <Adafruit_FT6206.h>

#include <Adafruit_GFX.h>
#include <gfxfont.h>

#include <Adafruit_ILI9341.h>

#include <Wire.h>

#include <SPI.h>

#include "LCD.h"
#include "TCH.h"

// The FT6206 uses hardware I2C (SCL/SDA)
Adafruit_FT6206 ctp = Adafruit_FT6206();

// The display also uses hardware SPI, plus #9 & #10
#define TFT_CS 10
#define TFT_DC 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// Size of the color selection boxes and the paintbrush size
#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
  while (!Serial);     // used for leonardo debugging
 
  Serial.begin(115200);
  Serial.println(F("Cap Touch Paint!"));
  
  tft.begin();
  if (! ctp.begin(40)) {  // pass in 'sensitivity' coefficient
    Serial.println("Couldn't start FT6206 touchscreen controller");
    while (1);
  }

  Serial.println("Capacitive touchscreen started");
  
  DRAW_SCREEN();

}

void loop() {
  
  // Waiting for a screen touch
  if (! ctp.touched()) {
    return;
  }
  
  // Retrieve a point  
  TS_Point p = ctp.getPoint();
  p.x = 240 - p.x;
  p.y = 320 - p.y;
  Tuch(p);
  // Print out raw data from screen touch controller
  //Serial.print("X = "); Serial.print(240 - p.x);
  //Serial.print("\tY = "); Serial.print(320 - p.y);
  //Serial.println(" -> ");
 /*

  // flip it around to match the screen.
  p.x = map(p.x, 0, 240, 240, 0);
  p.y = map(p.y, 0, 320, 320, 0);

  // Print out the remapped (rotated) coordinates
  Serial.print("("); Serial.print(p.x);
  Serial.print(", "); Serial.print(p.y);
  Serial.println(")");
  

  if (p.y < BOXSIZE) {
     oldcolor = currentcolor;

     if (p.x < BOXSIZE) { 
       currentcolor = ILI9341_RED; 
       tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*2) {
       currentcolor = ILI9341_YELLOW;
       tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*3) {
       currentcolor = ILI9341_GREEN;
       tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*4) {
       currentcolor = ILI9341_CYAN;
       tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*5) {
       currentcolor = ILI9341_BLUE;
       tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x <= BOXSIZE*6) {
       currentcolor = ILI9341_MAGENTA;
       tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     }

     if (oldcolor != currentcolor) {
        if (oldcolor == ILI9341_RED) 
          tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
        if (oldcolor == ILI9341_YELLOW) 
          tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
        if (oldcolor == ILI9341_GREEN) 
          tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
        if (oldcolor == ILI9341_CYAN) 
          tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
        if (oldcolor == ILI9341_BLUE) 
          tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
        if (oldcolor == ILI9341_MAGENTA) 
          tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
     }
  }
  if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
    tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
  }
  */
}
  while (!Serial);     // used for leonardo debugging

But you don't have a Leonardo, so why do you have code for something you don't have?

Where is the unused Due code?

Why would you think it reasonable to wait for the Serial instance to start BEFORE you tell it to start?

void loop() {
 
  // Waiting for a screen touch
  if (! ctp.touched()) {
    return;
  }

Absolute rubbish. Doing nothing unless the screen is touched is NOT ever going to work.

You don’t seem to have the mlx library or begin code in here. Also you know that’s a I2C (SDA, SCL) enables device right?

I’m working on a tricorder too (my own not this preset project). If you want more help email me I know how frustrating problems can be and people who aren’t willing to help you with them.