I have a;
arduino mega 2560
20x4 LCD
DHT11 TempHum
8CH Relay
5 5v fans
esp wifi chip
analog temp
SD Card
3 digital buttons
I would like to display on the lcd a menu, and have pages beyond them.
For Example;
Display
Relays
AnalogTemp
DigTempHum
Fans
Timer
SD Card
Then the page beyond them would have adjustable settings relating to the menu item.
For Display it would be nice to choose what items to display for each line by the use of a array,
Relays can show the available channels if on/off and if selected can be turned on,
AnalogTemp displays the values of the sensor if sensor falls below certain value should it turn on a relay, DigTempHum would have the same thing as AnalogTemp, Fans would be setup like Relays,
and Timer would allow a time limit to be set for a desired function/ like turn off a relay after 5min.
I have got a tiny bit done up to the menu, I am including my code and 2 examples I really admire.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#define dht_apin A0 //Analog sensor pin is connected to.
#define DHTTYPE DHT11
volatile int sec, minute = 0, hour = 0;
DHT dht(dht_apin, DHTTYPE); //init dht libary
LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 20 chars and 4 line display
int b_1 = 2; //button 1 assigned to digital pin 3
int b_2 = 3; //button 2 assigned to digital pin 4
int b_3 = 4; //button 3 assigned to digital pin 5
void setup()
{
pinMode(b_1, INPUT_PULLUP);
pinMode(b_2, INPUT_PULLUP);
pinMode(b_3, INPUT_PULLUP);
dht.begin();//initialize dht sensor
delay(500);//delay to let system boot.
lcd.init(); // Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Garduino");
lcd.clear();
}
void loop()
{
float h = dht.readHumidity();//reads humidity
float t = dht.readTemperature();//reads temperature as C
float f = dht.readTemperature(true);//reads temperature as F
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
lcd.println("Failed to read from DHT sensor!");
return;
}
// Compute heat index
// Must send in temp in Fahrenheit!
float hi = dht.computeHeatIndex(f, h);
lcd.setCursor(0, 1);
lcd.print("Hum: ");
lcd.print(h);
lcd.print(" %");
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(t);
lcd.print("C ");
lcd.print(f);
lcd.print("F");
//lcd.print("Heat index: ");
//lcd.print(hi);
//lcd.println(" *F");
lcd.setCursor(0, 2);
//sec = millis() / 1000;
lcd.print("Time: ");
if (hour < 10) {
lcd.print("0");
lcd.print(hour);
lcd.print(":");
}
else {
lcd.print(hour);
lcd.print(":");
}
if (minute < 10) {
lcd.print("0");
lcd.print(minute);
lcd.print(":");
}
else {
lcd.print(minute);
lcd.print(":");
}
if (sec < 10) {
lcd.print("0");
lcd.print(sec);
}
else {
lcd.print(sec);
}
lcd.print(" ");
sec++;
if (sec > 800) {
minute++;
sec = 0;
}
if (minute > 59) {
hour++;
minute = 0;
}
if (hour > 12) {
hour = 1;
}
if (digitalRead(b_1) == HIGH) {
hour++;
if (hour > 12)
hour = 1;
}
if (digitalRead(b_2) == HIGH) {
minute++;
if (minute > 59)
minute = 0;
}
}
I really like the way the github version is written, it's efficient and not long, but single page only.
Could I add a switch statement in and modify the screens variable to acquire a 2nd page?
As for the pastebin version, it's config'd for a 16x2LCD, could the drawcursor function be rewritten in a more efficient way?
Also I have 3 buttons, 1 for select, 1 increase, and 1 decrease
Was thinking maybe use multiclick and doubleclick select for back or just add a 4th button.
Saving data from sensors to the sd card would be great as well but the menu is more important right now to me.
I know you guys have much greater experience then myself, and dont know where else to turn for guidance, any help is so greatly appreciated!

