Colorímetro Portátil

Reações Colorimétricas são muito comuns nos laboratórios de Biologia e Química; essas reações formam produtos coloridos, e a partir da medição da absorção/transmissão de diferentes comprimentos de onda incididos sobre esses produtos podemos determinar, por exemplo, a concentração de uma determinada substância presente na solução investigada. Para realizar essas medições utiliza-se colorímetros e espectrofotômetros, equipamentos que possuem um custo significativamente elevado, podendo, assim, limitar seu acesso.

Neste tutorial mostraremos como montar um colorímetro portátil de baixo custo utilizando Arduino. Este equipamento apresenta uma ótima solução para o ensino, levando em consideração que muitas escolas não possuem tal ferramenta, mas também pode ser empregado em laboratórios.

                                                                    

Materiais

  • 1 Protoboard

  • 1 Display OLED

  • 1 Módulo LED RGB

  • 1 Sensor TSL 2561

  • 1 Módulo SD

  • 1 Placa Arduino UNO

  • 3 Botões

  • Jumper

Conexões

Protoboard:

A Protoboard deve ser alimentada com as portas 5V e GND da placa Arduino UNO

Módulo LED RGB:

  • R na porta 6
  • G na porta 5
  • B na porta 3
  • Negativo na porta GND

Sensor TSL 2561:

  • VCC na porta 3V
  • GND
  • SDA na porta 4
  • SCL na porta 5

Display OLED:

  • VCC na porta 5V
  • GND
  • CS na porta 10
  • MOSI na porta 11
  • SCK na porta 13
  • MISO na porta 12

Módulo SD:

  • VCC na porta 5V
  • GND
  • SDA na porta 4
  • SCK na porta 5

Botões:

Uma das pernas dos botões deve ser alimentada pela porta 5V; a outra perna ligada à uma das pernas do resistor e à porta 7, 4 e 2 (cada um dos 3 botões em uma dessas portas); a outra perna do resistor deve ser ligada ao GND

Código

Abaixo está disponibilizada a programação do Colorímetro Portátil e as bibliotecas necessárias para seu funcionamento correto. 

#include <SPI.h>
#include <RTClib.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
#include <SD.h>
#include <MicroLCD.h>

#define SD_CS_DIO 10

RTC_Millis RTC;

// SD Card Config
Sd2Card card;
SdVolume volume;
SdFile root;

// the logging file
File DataFile;


//CONFIGURACAO DO DISPLAY MICRO LCD
LCD_SH1106 lcd; /* para módulo controlado pelo CI SH1106 OLED */
//LCD_SSD1306 lcd; /* para módulo contralado pelo CI SSD1306 OLED */

Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);

void displaySensorDetails(void) {
  sensor_t sensor;
  tsl.getSensor(&sensor);
}

void configureSensor(void) {
  tsl.enableAutoRange(true);
  tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);
}

// Define as conexões para cada cor do RGB
const int R = 6;
const int G = 5;
const int B = 3;

// Armazena os valores para cada cor entre (0-255)
int ValorR = 0;
int ValorG = 0;
int ValorB = 0;
int pinLed = 0;

// Define as conexões do botão seletor (push button)
int seletor;
int nm;
float Absorbancia;
float I0;

void setup() {
  Serial.begin(9600);
  Serial.println("Light Sensor Test");
  Serial.println("");
  RTC.begin(DateTime(__DATE__, __TIME__));
  lcd.begin ();
  lcd.clear();
  lcd.setCursor(10, 0);
  lcd.setFontSize(FONT_SIZE_MEDIUM);
  lcd.print("COLORIMETER");
  // There was a problem detecting the TSL2561 ... check your connections
  if (!tsl.begin()) {
    Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
    lcd.setCursor(1, 3);
    lcd.setFontSize(FONT_SIZE_SMALL);
    lcd.print("No TSL2561 detected");
    while (1);
  } else {
    lcd.setCursor(1, 3);
    lcd.setFontSize(FONT_SIZE_SMALL);
    lcd.print("TSL2561 OK");

  }
  // Display some basic information on this sensor
  displaySensorDetails();

  // Setup the sensor gain and integration time
  configureSensor();

  /* We're ready to go! */
  Serial.println("");

  // Indica que os pinos dos botões são de SAÍDA do Arduino
  pinMode(R, OUTPUT);
  pinMode(G, OUTPUT);
  pinMode(B, OUTPUT);

  // Indica que os pinos dos botões são de ENTRADA no Arduino
  pinMode(7, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);

  analogWrite(R, 255);  //coloca valor inicial para vermeho (padrão inicial)
  nm = 630;

  // initialize the SD card
  // Set the SD card CS pin to an output
  pinMode(SD_CS_DIO, OUTPUT);

  // Initialise the SD card
  SD.begin(SD_CS_DIO);
  if (!SD.begin(SD_CS_DIO)) {
    /* If there was an error output this to the serial port and go no further */
    Serial.println("ERROR: SD card failed to initialise");
    lcd.setCursor(1, 5);
    lcd.setFontSize(FONT_SIZE_SMALL);
    lcd.print("SD CARD ERROR");
    while (1);
  }
  else {
    lcd.setCursor(1, 5);
    lcd.setFontSize(FONT_SIZE_SMALL);
    lcd.print("SD CARD OK");
    Serial.println("SD Card OK");
    delay (2000);
    // Get a new sensor event
    sensors_event_t event;
    tsl.getEvent(&event);
    I0 = event.light;
  }
  lcd.clear();
}

void loop()
{
  // Get a new sensor event
  sensors_event_t event;
  tsl.getEvent(&event);

  /* Display the results (light is measured in lux) */

  if (event.light) {
    lcd.setCursor(5, 2);
    lcd.setFontSize(FONT_SIZE_MEDIUM);
    lcd.print("             ");
    Serial.print(event.light);
    Serial.println(" lux");
    Serial.println (I0);
    Absorbancia = log(I0 / event.light);
    Serial.print(Absorbancia);
    Serial.println(" Absorbância");
    if (digitalRead(7) == LOW) {
      nm = 420;
      analogWrite(R, 0);  //coloca valor inicial para vermeho (padrão inicial)
      analogWrite(G, 0);  //coloca valor inicial para vermeho (padrão inicial)
      analogWrite(B, 255);  //coloca valor inicial para vermeho (padrão inicial)
      I0 = event.light;
    }
    if (digitalRead(4) == LOW) {
      nm = 520;
      analogWrite(R, 0);  //coloca valor inicial para vermeho (padrão inicial)
      analogWrite(G, 255);  //coloca valor inicial para vermeho (padrão inicial)
      analogWrite(B, 0);  //coloca valor inicial para vermeho (padrão inicial)
      I0 = event.light;
    }
    if (digitalRead(2) == LOW) {
      nm = 630;
      analogWrite(R, 255);  //coloca valor inicial para vermeho (padrão inicial)
      analogWrite(G, 0);  //coloca valor inicial para vermeho (padrão inicial)
      analogWrite(B, 0);  //coloca valor inicial para vermeho (padrão inicial)
      I0 = event.light;
    }

  }
  else {
    Serial.println("Sensor overload");
    lcd.clear();
    lcd.setCursor(5, 2);
    lcd.setFontSize(FONT_SIZE_MEDIUM);
    lcd.print("SENSOR ERROR");
  }
  delay (100);

  Serial.println(digitalRead(seletor));

  //lcd.clear();
  // lcd.setCursor(0, 2);
  //lcd.setFontSize(FONT_SIZE_MEDIUM);
  //lcd.print("Lux:");
  //lcd.setCursor(35, 2);
  //lcd.setFontSize(FONT_SIZE_MEDIUM);
  //lcd.print(event.light);
  lcd.setCursor(2, 0);
  lcd.setFontSize(FONT_SIZE_MEDIUM);
  lcd.print("Abs:");
  lcd.setCursor(40, 0);
  lcd.setFontSize(FONT_SIZE_MEDIUM);
  lcd.print(nm);
  lcd.setCursor(70, 0);
  lcd.setFontSize(FONT_SIZE_MEDIUM);
  lcd.print("nm");
  lcd.setCursor(40, 12);
  lcd.setFontSize(FONT_SIZE_LARGE);
  lcd.print("     ");
  lcd.setCursor(40, 12);
  lcd.setFontSize(FONT_SIZE_XLARGE);
  lcd.print(Absorbancia);
  delay(100);

  // Write the results to the SD Card
  logging();
}

void logging()
{
  DataFile = SD.open("data.csv", FILE_WRITE);
  if (DataFile) {
    DateTime now = RTC.now();
    DataFile.print(now.day(), DEC);
    DataFile.print('/');
    DataFile.print(now.month(), DEC);
    DataFile.print('/');
    DataFile.print(now.year(), DEC);
    DataFile.print(',');
    DataFile.print(now.hour(), DEC);
    DataFile.print(':');
    DataFile.print(now.minute(), DEC);
    DataFile.print(':');
    DataFile.print(now.second(), DEC);
    DataFile.print(",");
    DataFile.print(Absorbancia);
    DataFile.print(",");

    if (nm == 630) {
      DataFile.print("630nm");
    }
    else if (nm == 520) {
      DataFile.print("520nm");
    }
    else if (nm == 420) {
      DataFile.print("420nm");
    }
    DataFile.println();
    DataFile.close();
  }
  delay(100);
}

 

Files

LTE 2024 - Educational Technology Lab - IB - UNICAMP