Page 1 of 1

Arduino Function value to glcd

Posted: Sun Oct 22, 2017 10:14 pm
by michaelbennett3443
I am new to Arduino and I'm trying my first pro mini. i was able to find some ds1302 code from github that runs perfectly, my problem is trying to add some lm35 code to also display temperature data as well as the time data.

The code doesn't seem to run the celsius and fahrenheit functions. i have attached my code any help will be appreciated.



//Required library - http://www.rinkydinkelectronics.com/library.php?id=5
//Blog Post - http://overskill.alexshu.com/ds1302-rea ... w-arduino/

#include "U8glib.h"
#include <DS1302.h>
#include <PreciseLM35.h>
//int float pinLM35 = A0;
const int pinLM35 = A0;
PreciseLM35 lm35(pinLM35, DEFAULT);

DS1302 rtc(2, 3, 4);
U8GLIB_ST7920_128X64 u8g(13, 11, 12, U8G_PIN_NONE);

void setup(void) {
rtc.halt(false);
rtc.writeProtect(false);
// Setup Serial connection
//Serial.begin(9600);

// The following lines can be commented out to use the values already stored in the DS1302
// Once you flash the arduino with the correct time.

//rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY
//rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(6, 8, 2010); // Set the date to August 6th, 2010

// assign default color value
if ( u8g.getMode() == U8G_MODE_R3G3B2 )
u8g.setColorIndex(255); // white
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
u8g.setColorIndex(3); // max intensity
else if ( u8g.getMode() == U8G_MODE_BW )
u8g.setColorIndex(1); // pixel on
}
void draw(void) {
u8g.setFont(u8g_font_04b_03);
u8g.drawStr( 2,5, "******************************");
u8g.drawStr( 13,10, "Arduino Pro Mini Control ");
u8g.drawStr( 24,20, (rtc.getTimeStr()));
u8g.drawStr( 1,20, "TIME: ");
u8g.drawStr(70,20, "Temp (C): ");
u8g.drawStr (80,20, (lm35.readCelsius()));
u8g.drawStr( 25,30, rtc.getDOWStr());
u8g.drawStr(70,30, "Temp (F): ");
u8g.drawStr(3,30, "DAY: ");
u8g.drawStr(80,30, (lm35.readFahrenheit()));
u8g.drawStr( 24,40, rtc.getDateStr());
u8g.drawStr(1,40, "DATE: ");
u8g.drawStr(70,40, "AREF : ");
u8g.drawStr(80,40, (lm35.readPreciseAref()));
u8g.drawStr( 15,55, "DS1302 Real Time Clock");
u8g.drawStr( 2,65, "********************************");
}

void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage()); //u8g.nextPage()

// rebuild the picture after some delay
delay(500);
}
Code: Select all