Print to TFT display temperature sensor DS18b20 readings, not to serial monitor.
hi,
i have been unable print ds18b20 temerature sensor st7735 tft screen adafruit. 128 x 160. prints fine serial monitor.
i had expected following section calling temperature in celsius able print? appreciated.
the following far have been able get.
regards,
wayne
i have been unable print ds18b20 temerature sensor st7735 tft screen adafruit. 128 x 160. prints fine serial monitor.
i had expected following section calling temperature in celsius able print? appreciated.
code: [select]
{
sensors.requesttemperatures(); // send command temperatures.
mytemp0 = (sensors.gettempcbyindex(0));
mytemp1 = (sensors.gettempcbyindex(1));
{the following far have been able get.
code: [select]
#include <spi.h>
#include <tft.h>
// libraries ds1820 , onewire
#include <onewire.h>
#include <dallastemperature.h>
//you can use (4 or) 5 pins
//#define sclk 4
//#define mosi 5
#define cs 6 // pin definition uno
#define dc 7 // pin definition uno
#define rst 8 // pin definition uno
// can connect arduino reset
float mytemp0;
float myhightemp0;
float mylowtemp0 = 50;
float mytemp1;
float myhightemp1;
float mylowtemp1 = 50;
onewire onewire(2); // setup onewire instance communicate devices.
dallastemperature sensors(&onewire);
// create instance of library
tft tftscreen = tft(cs, dc, rst);
void setup()
{
// put line @ beginning of every sketch uses glcd:
tftscreen.begin();
// clear screen black background
tftscreen.background(0, 0, 255);
// write static text screen
// set font color white
tftscreen.stroke(0,0,0);
// set font size
tftscreen.settextsize(2);
// write text top left corner of screen
tftscreen.text("temperatures :\n ",10,0);
// set font color white
tftscreen.stroke(50,50,50);
// set font size
tftscreen.settextsize(1);
// write text top left corner of screen
tftscreen.text("fridge temperature :\n ",10,20);
// write text top left corner of screen
tftscreen.text("pot 1 temperature :\n ",10,30);
// ste font size large loop
tftscreen.settextsize(1);
sensors.begin();
serial.begin(9600);
}
void loop()
{
readtemp(); // read temperature.
serialprint(); // write results serial monitor.
}
void readtemp() // call sensors.requesttemperatures() issue
// global temp request devices on bus.
{
sensors.requesttemperatures(); // send command temperatures.
mytemp0 = (sensors.gettempcbyindex(0));
mytemp1 = (sensors.gettempcbyindex(1));
{
tftscreen.stroke(255,255,255);
tftscreen.settextsize(1);
tftscreen.print(mytemp0);
}
// set high or low temp.
if (mytemp0 < mylowtemp0)
{
mylowtemp0 = mytemp0;
}
if (mytemp0 > myhightemp0)
{
myhightemp0 = mytemp0;
}
if (mytemp1 < mylowtemp1)
{
mylowtemp1 = mytemp1;
}
if (mytemp1 > myhightemp1)
{
myhightemp1 = mytemp1;
}
}
void serialprint()
{
serial.print("current fridge temp 0: ");
serial.print(mytemp0);
serial.print("c");
serial.print(" lowest temp 0: ");
serial.print(mylowtemp0);
serial.print("c");
serial.print(" highest temp 0: ");
serial.print(myhightemp0);
serial.print("c");
serial.print("\t\t");
serial.print(" current pot plant temp 1: ");
serial.print(mytemp1);
serial.print("c");
serial.print(" lowest temp 1: ");
serial.print(mylowtemp1);
serial.print("c");
serial.print(" highest temp 1: ");
serial.print(myhightemp1);
serial.println("c");
delay(2500);
}
regards,
wayne
Arduino Forum > Using Arduino > Sensors > Print to TFT display temperature sensor DS18b20 readings, not to serial monitor.
arduino
Comments
Post a Comment