#include <LiquidCrystal.h>;
#include <DS18B20.h>;
#include <DHT.h>;
#include <OneWire.h>;
#include <DallasTemperature.h>;
#include "U8glib.h" // U8glib library for the OLED
// const
// select the pins used on the LCD panel
const int rs = 13, rs2 = 11, rs3 = 9,en = 12, en2 = 10, en3 = 8, d4 = 6, d5 = 5, d6 = 4, d7 = 3;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
LiquidCrystal lcd2(rs2, en2, d4, d5, d6, d7);
LiquidCrystal lcd3(rs3, en3, d4, d5, d6, d7);
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_FAST);
#define ONE_WIRE_BUS 2
//DS18B20 ds(8);
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//char
byte customChar[8] = {
0b00111,
0b00101,
0b00111,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
//EMF Bar
byte Bar[8] = {
B11111,
B00000,
B11111,
B11111,
B11111,
B11111,
B00000,
B11111
};
byte L[8] = {
B00111,
B01000,
B10100,
B10100,
B10100,
B10111,
B01000,
B00111
};
byte R[8] = {
B00111,
B01000,
B10110,
B10101,
B10110,
B10101,
B01000,
B00111
};
byte EndMark[8] = {
B10000,
B01000,
B00100,
B00100,
B00100,
B00100,
B01000,
B10000
};
byte EmptyBar[8] = {
B11111,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B11111
};
byte peakHoldChar[8] = {
B11111,
B00000,
B01110,
B01110,
B01110,
B01110,
B00000,
B11111
};
//var
int lcd_key = 0;
int chk;
//lcd.init(); // Initiate the LCD module
//lcd.backlight();
float hum; //Stores humidity value
float temp; //Stores temperature value
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
//setup
void setup()
{
Serial.begin(9600);
sensors.begin();
dht.begin();
lcd.begin(16, 2); // start the library
lcd.createChar(0, customChar);
lcd.setCursor(0,0);
lcd.print(" (L1)");
lcd2.begin(16, 2);
lcd2.createChar(0, customChar);
lcd2.setCursor(0,0);
lcd2.print(" (L2)");
lcd3.begin(16, 2);
lcd3.createChar(0, customChar);
lcd3.setCursor(0,0);
lcd3.print(" (L3)");
}
void loop()
{
//Read data and store it to variables hum and temp
sensors.requestTemperatures();
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to lcd
lcd.print("H:");
lcd.print(hum);
lcd.print("% ");
//LCD 1
lcd.setCursor(0,1);
lcd.print("Temp1 :");
lcd.print(sensors.getTempCByIndex(0));
lcd.write((uint8_t)0);
lcd.println("C _");
lcd.setCursor(0,0);
//LCD 2
lcd2.print("Temp2 : ");
lcd2.print(temp);
lcd2.write((uint8_t)0);
lcd2.println("C");
lcd2.setCursor(0,1);
//OLED
u8g.firstPage();
do
{
draw();
}
while( u8g.nextPage() );
//delay(500);
}
void draw(void)
{
u8g.setFont(u8g_font_10x20); // select font
u8g.drawStr(8, 15, "Temperatuur");
u8g.setPrintPos(33,40);
//u8g.drawRFrame(15, 20, 100, 30, 10); // draws frame with rounded edges
u8g.println(temp); //Prints the temp
u8g.println(" C");
}