Tinkers Projects

Imagine | Develop | Create

Temperature Logger

Categories: PLEX
Temperature LoggerMain
Temperature Logger0
Temperature Logger1
Temperature Logger2

Temperature Logger

Categories: PLEX
This is a temperature logger to log the temperature over time. I have been wanting to make one of these for a while. It will be used to see how Low and high the temperature during the days away camping. It uses the Plex board from https://tinkersprojects.com/project/plex-controller/ with a DS18B20 temperature sensor. The data from the sensor is logged every second and Additional sensors can be added.

Code for Project

GNU General Public License v3.0
#include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>

#define upPIN 0
#define startstopPIN 1
#define downPIN 18

#define InPinA 17
#define InPinB 16
#define InSePinA 13
#define InSePinB 12
#define InSePinC 11
  
#define OutPinA 14
#define OutPinB 15
#define OutSePinA A5
#define OutSePinB A6
#define OutSePinC A7

#define chipSelect 10

unsigned int data[16];
unsigned long delaytime = 1;
unsigned long timeslogged = 0;
unsigned long currenttime = 0;
File dataFile;
LiquidCrystal lcd(2, 3, 4,5, 6, 7);

void setup() 
{
  lcd.begin(16, 2);
  pinMode(startstopPIN, INPUT);
  pinMode(downPIN, INPUT);
  pinMode(upPIN, INPUT);
  pinMode(InSePinA, OUTPUT);
  pinMode(InSePinB, OUTPUT);
  pinMode(InSePinC, OUTPUT);

  while(!SD.begin(chipSelect)) 
  {
    lcd.autoscroll();
    lcd.setCursor(0,0);
    lcd.print(" SD Card failed ");
    lcd.setCursor(0,1);
    lcd.print("Press start to try again");
    while(digitalRead(startstopPIN)==LOW){}
    while(digitalRead(startstopPIN)==HIGH){}
  }

  dataFile = SD.open("datalog.csv", FILE_WRITE);
  while(!dataFile) 
  {
    lcd.setCursor(0,0);
    lcd.print(" SD Card failed ");
    lcd.setCursor(0,1);
    lcd.print("Error opening file for logging");
  }

  lcd.clear();
  lcd.noAutoscroll();
  lcd.print("Log every:");
  lcd.print(delaytime);
  lcd.print("S");
  lcd.setCursor(0,1);
  /*
  while(digitalRead(startstopPIN)==LOW)
  {
    while(digitalRead(upPIN)==HIGH)
    {
      delaytime++;
      if(delaytime>=99999)
      {
        delaytime = 99999;
      }
    }
    while(digitalRead(downPIN)==HIGH)
    {
      delaytime--;
      if(delaytime<=0)
      {
        delaytime = 0;
      }
    }
  }
  */
  dataFile.println("num,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16");
  dataFile.flush();
  lcd.clear();
  lcd.print("Starting in:3");
  delay(1000);
  lcd.setCursor(12,0);
  lcd.print("2");
  delay(1000);
  lcd.setCursor(12,0);
  lcd.print("1");
  delay(1000);

  lcd.clear();
  lcd.print("Times Logged:");
  currenttime = millis();
}

void loop() 
{
  for(int i=0;i<8;i++)
  {
    selectLED(i);
    data[i]   = analogRead(InPinA);
    data[i+8] = analogRead(InPinB);
  }
  
  dataFile.print(timeslogged);
  
  for(int i=0;i<16;i++)
  {
    dataFile.print(",");
    dataFile.print(data[i]);
  }

  dataFile.println();
  dataFile.flush();
  
  timeslogged++;
  lcd.setCursor(0,1);
  lcd.print(timeslogged);
  
  while(currenttime+1000>millis()){}
  currenttime = millis();
  
}



void selectLED(byte A)
{
  switch (A) {
    case 0:
        digitalWrite(InSePinA, LOW);
        digitalWrite(InSePinB, LOW);
        digitalWrite(InSePinC, LOW);
      break;
    case 1:
        digitalWrite(InSePinA, HIGH);
        digitalWrite(InSePinB, LOW);
        digitalWrite(InSePinC, LOW);
      break;
    case 2:
        digitalWrite(InSePinA, LOW);
        digitalWrite(InSePinB, HIGH);
        digitalWrite(InSePinC, LOW);
      break;
    case 3:
        digitalWrite(InSePinA, HIGH);
        digitalWrite(InSePinB, HIGH);
        digitalWrite(InSePinC, LOW);
      break;
    case 4:
        digitalWrite(InSePinA, LOW);
        digitalWrite(InSePinB, LOW);
        digitalWrite(InSePinC, HIGH);
      break;
    case 5:
        digitalWrite(InSePinA, HIGH);
        digitalWrite(InSePinB, LOW);
        digitalWrite(InSePinC, HIGH);
      break;
    case 6:
        digitalWrite(InSePinA, LOW);
        digitalWrite(InSePinB, HIGH);
        digitalWrite(InSePinC, HIGH);
      break;
    case 7:
        digitalWrite(InSePinA, HIGH);
        digitalWrite(InSePinB, HIGH);
        digitalWrite(InSePinC, HIGH);
      break;
    case 8:
        digitalWrite(InSePinA, LOW);
        digitalWrite(InSePinB, LOW);
        digitalWrite(InSePinC, LOW);
      break;
    break;
  }
}
This is a temperature logger to log the temperature over time. I have been wanting to make one of these for a while. It will be used to see how Low and high the temperature during the days away camping. It uses the Plex board from https://tinkersprojects.com/project/plex-controller/ with a DS18B20 temperature sensor. The data from the sensor is logged every second and Additional sensors can be added.