5
\$\begingroup\$

I'm building an advanced thermostat on an arduino with the following goals:

  • Use a rotary encoder (with pushbutton) as the only input device
  • Use LCD display (standard 16x2)
  • Use a real time clock
  • Ability to schedule temperature changes
  • Ability to 'ramp' between changes (ex: start at 45 degF, end at 50degF 3 days later with a linear increase between start and end date)

I have much of this project finished but where I've stalled out is building a 'scheduler' function and finding a good menu method. Can someone please suggest a function that would work as a scheduler and give some examples of a menu that might work well with this project?

asked Apr 9, 2013 at 18:41
\$\endgroup\$
1
  • \$\begingroup\$ Could you provide more details about what type of menu are you thinking of ? What requirements are you trying to fulfill ? \$\endgroup\$ Commented Apr 10, 2013 at 8:12

2 Answers 2

2
\$\begingroup\$

For the scheduler, use the Time library. Maintain an array that mentions what change must happen when (create your own protocol for this, for example take "2000/40" to mean "change the thermostat to 40 at 20:00").

Now, in your main loop, set up loop() with a wait period of a second or so. (Since you're taking input as well, you cannot afford to have a longer wait period). Now, just compare your array values with the stuff returned by hour() and minute(), and trigger the changes as needed.

Ramping is also easy, just divvy up the temperature change by every hour. So, the ramp from 45 to 50 in 3 days, just set the Arduino to increase the temperature by 1 every 14 hours.

answered Apr 10, 2013 at 1:34
\$\endgroup\$
0
\$\begingroup\$

I'm the author of arduino-menusystem, a library for building a menu system on the arduino. Below is an example (there are more in the repository):

#include <MenuSystem.h>
// Menu variables
MenuSystem ms;
Menu mm("");
MenuItem mm_mi1("Level 1 - Item 1 (Item)");
MenuItem mm_mi2("Level 1 - Item 2 (Item)");
Menu mu1("Level 1 - Item 3 (Menu)");
MenuItem mu1_mi1("Level 2 - Item 1 (Item)");
// Example variables
bool bRanCallback = false;
bool bForward = true;
// Menu callback function
// In this example all menu items use the same callback.
void on_item1_selected(MenuItem* p_menu_item)
{
 Serial.println("Item1 Selected");
 bRanCallback = true;
 bForward = true;
}
void on_item2_selected(MenuItem* p_menu_item)
{
 Serial.println("Item2 Selected");
 bRanCallback = true;
}
void on_item3_selected(MenuItem* p_menu_item)
{
 Serial.println("Item3 Selected");
 bRanCallback = true;
 bForward = false;
}
// Standard arduino functions
void setup()
{
 Serial.begin(9600);
 // Menu setup
 mm.add_item(&mm_mi1, &on_item1_selected);
 mm.add_item(&mm_mi2, &on_item2_selected);
 mm.add_menu(&mu1);
 mu1.add_item(&mu1_mi1, &on_item3_selected);
 ms.set_root_menu(&mm);
}
void loop()
{
 Serial.println("");
 // Display the menu
 Serial.println(ms.get_current_menu()->get_selected()->get_name());
 // Simulate using the menu by walking over the entire structure.
 ms.select();
 if (bRanCallback)
 {
 if (bForward)
 ms.next();
 else
 ms.prev();
 bRanCallback = false;
 }
 // Wait for two seconds so the output is viewable
 delay(2000);
}

There's more information on the above GitHub page and also in the blog post Arduino menu system library.

answered Nov 25, 2015 at 8:15
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.