11. Input devices

assignment

individual assignment:

 measure something: add a sensor to a microcontroller board
 that you have designed and read it

group assignment:

 probe an input device's analog levels and digital signals

individual assignment:

Making the board for my project

I planned to meseure temperature for my project this week whit a termistor NTC of 100K and 1 satchakit

here is the the satcha kit i found here

now its time to machine the pcb.

And after that soldering all the componants

here is the schema and the board i ha made in kicad to include my thermistor to be able to mesure temp.

here is the kicad files

Testing with the board with all the good connection to program with myfabisp

I have made my program with arduino

Here you have the pin connection for the atmega 328p with arduino

And here you have my code

// shema pinout : https://camo.githubusercontent.com/d7b8053397a8ad942514cdc9b36636bb368a4c16/687474703a2f2f692e696d6775722e636f6d2f55734b464d454f2e6a7067
//tutoriel LCD : https://www.arduino.cc/en/Tutorial/HelloWorld?from=Tutorial.LiquidCrystal
// tutoriel thermistance : https://learn.adafruit.com/thermistor/using-a-thermistor

#include <LiquidCrystal.h>

// définition des variables globales
double temp = 0;

//définition des pins
#define pinThermistor 14
#define pinLEDrouge 13
#define pinMOSFET 15

// définition des constantes
#define T 215

// resistance at 25 degrees C
#define THERMISTORNOMINAL 100000      
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25   
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 100000      

int samples[NUMSAMPLES];

//config du LCD
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2; //adapter les pins (fait)
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // put your setup code here, to run once:

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(0,0);
  lcd.print("Temperature ");

  //config des pins
  pinMode(pinLEDrouge,OUTPUT);
  pinMode(pinMOSFET,OUTPUT);
  pinMode(pinThermistor,INPUT);

}

void loop(void) {
  uint8_t i;
  float average;

  // take N samples in a row, with a slight delay
  for (i=0; i< NUMSAMPLES; i++) {
   samples[i] = analogRead(pinThermistor);
   delay(10);
  }

  // average all the samples out
  average = 0;
  for (i=0; i< NUMSAMPLES; i++) {
     average += samples[i];
  }
  average /= NUMSAMPLES;


  // convert the value to resistance
  average = 1023 / average - 1;
  average = SERIESRESISTOR / average;

  float steinhart;
  steinhart = average / THERMISTORNOMINAL;     // (R/Ro)
  steinhart = log(steinhart);                  // ln(R/Ro)
  steinhart /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)
  steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
  steinhart = 1.0 / steinhart;                 // Invert
  steinhart -= 273.15;                         // convert to C
lcd.setCursor(0,1);

  lcd.print(steinhart);
  lcd.write(223);
  lcd.print("C");
  delay(1000);


  // put your main code here, to run repeatedly:

  //checker la valeur de température
  //acquérir le signal de l'ADC

  //convertir la valeur en °C


  //si en dessous de 240°C, on chauffe et on allume la LED de chauffe
  //si au dessus de 240°C, on arrête de chauffer et on allume  la LED de stabilisation
  if(steinhart<=T){
    digitalWrite(pinMOSFET, HIGH);
    digitalWrite(pinLEDrouge, HIGH);

  }else{
    digitalWrite(pinMOSFET, LOW);
    digitalWrite(pinLEDrouge, LOW);

  }
}

you can also see that i have include a LCD (normally it is the work for week12) to be able to see the temperature. Here is the result.

developpent of my own board

see my final project to see my future Board

Original files

carte thermistance