Termometru digital

de George Sand


Adaugat in 2017-04-27 10:04:09



Termometru digital

folosind Arduino 328P (UNO R3), LCD 5110 Nokia, RTC DS3231, senzor temperatura DS18B20

Cod sursa .ino

#include 
#include 


static const byte sensorPin = 0;
static const byte ledPin = 13;

static const byte LCD_WIDTH = 84;
static const byte LCD_HEIGHT = 48;

static const byte CHART_HEIGHT = 5;


static const byte DEGREES_CHAR = 1;
static const byte degrees_glyph[] = { 0x00, 0x07, 0x05, 0x07, 0x00 };

// A bitmap graphic (10x2) of a thermometer...
static const byte THERMO_WIDTH = 10;
static const byte THERMO_HEIGHT = 2;
static const byte thermometer[] = { 0x00, 0x00, 0x48, 0xfe, 0x01, 0xfe, 0x00, 0x02, 0x05, 0x02,
                                    0x00, 0x00, 0x62, 0xff, 0xfe, 0xff, 0x60, 0x00, 0x00, 0x00
                                  };

static PCD8544 lcd;
DS3231  rtc(SDA, SCL);

void setup() {
  lcd.begin(LCD_WIDTH, LCD_HEIGHT);

  lcd.createChar(DEGREES_CHAR, degrees_glyph);
  lcd.setContrast(65);
  pinMode(ledPin, OUTPUT);
  rtc.begin();
  ///rtc.setTime(21, 48, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(24, 4, 2017);

  analogReference(INTERNAL);
}


void loop() {

  int reading = analogRead(sensorPin);
  digitalWrite(ledPin, HIGH);

  float voltage = reading * 5.0;
  voltage /= 1024.0;

//formula este propie dar o puteti modifica dupa necesitatii
  float temp = (voltage - 1.1) * 10 ;  //converting from 10 mv per degree wit 500 mV offset

  lcd.setCursor(0, 0);
    lcd.print("D: ");
  lcd.print(rtc.getDateStr());
  lcd.setCursor(0, 1);
   lcd.print("O: ");  
  lcd.print(rtc.getTimeStr());

  lcd.setCursor(0, 2);
  lcd.print("T: ");
  lcd.print(temp, 1);
  lcd.print(" \001C ");

  lcd.setCursor(0, 3);
  lcd.print("MICRONIK GRUP M www.micronikgrupm.ro");

  digitalWrite(ledPin, LOW);
  delay(1000);
}


La lcd pinul este urmatorul :

PCD8544(unsigned char sclk = 3, /* clock (display pin 2) */
unsigned char sdin = 4, /* data-in (display pin 3) */
unsigned char dc = 5, /* data select (display pin 4) */
unsigned char reset = 6, /* reset (display pin 8) */
unsigned char sce = 7); /* enable (display pin 5) */

Pentru senzorul de temperatura pinul este urmatorul :

static const byte sensorPin = 0; // analogic A0

Pentru RTC

//static const int SDA = 4; //analogic A4
//static const int SCL = 5; //analogic A5

DS3231 rtc(SDA, SCL);

Cateva poze cu proiectul finit :


Tag-uri cautare senzor temperatura RTC DS3231 LCD 5110 Nokia Arduino 328P (UNO R3 Arduino DS3231 DS18B20
Trimite unui prieten aceasta postare
sau distribuie postarea la tine pe perete
Inapoi

Lasa un comentariu


Razvan U 2017-05-03 13:12:07.0

Opinia carcotasului...Daca se inlocuieste Arduino UNO cu Arduino NANO se obtine un produs finit mai compact. Deeeci posibilitatea de a adauga o baterie si card SD