Archive | June, 2021

7 Day Office Thermostat

3 Jun

This is for someone who works from home usually four days a week. Every now and then the days get shifted around, so it needs to be easy to say “I’d normally be here today and away tomorrow, but I’m leaving now and I won’t be here tomorrow”.

Also, this unit is for a small outbuilding that can get very cold overnight, so it has to two temperature settings. One for “I’m going to be here today so start warming up to XX degrees an hour before my usual start” and one for “Even if I’m not here, turn the heater on if it gets below YY degrees.

Design decisions:

  • Get the basic functionality working with an Arduino based approach, then later add an ESP32 based WiFi capability.
  • Separate out all the 240V circuitry from the Arduino and human interface bits, with two separate boxes.
  • Use 3D printing to keep parts aligned and vaguely tidy.

Power switching box:

My first version of this was a decidedly “chunky” unit built of CNC cut MDF and acrylic. The circuitry worked but it lacked aesthetic appeal.

There’s nothing much inside this box, just small power supply and a 20A SSR (Solid State Relay).

I decided to redo the unit, and this time I drew up a detailed Fusion 360 CAD, even to including some of the wires.

With this CAD, I could print out small plastic parts to help align things on a lasercut mdf base. The laser also marked placement outlines to help assemble it. Printed PLA parts glue really well to MDF with wood glue. When I revised the base I just levered them off (taking some mdf with them), then soaked the mdf off to reuse them.

I found a cheap extension cord and chopped it in half to supply the power in and power out cords. A 3m section of CAT5 ethernet cable connects the two boxes, with GX16-6 connectors (I didn’t want to use normal ethernet connectors in case someone plugged one end into a computer).

The controller box:

I decided to use one of these cheap “LED&KEY” boards that comes with 8 x 7-segment displays, 8 LEDs, and 8 push button switches. All they require is +5V, GND, and 3 pins on the Arduino. (I saw these used on a Clough42 video and immediately bought a bunch).

The remainder of the parts were an Arduino Nano (clone), DHT11 temperature/humidity sensor, a DS3231 real time clock with battery, and a couple of TTP223 based capacitive touch sensors.

Note: I later tested the Omron SSR and realised it only drew 11mA, so got rid of the transistor buffer.

This time I drew up a 3D printed case, which incorporated mountings for the various parts, and had holes for the display LEDs to poke out.

I also 3D printed some little “pushers” to poke through the holes and press on the push buttons.

This all looked very good.

One problem is that the thin (2mm) PLA allows the other LEDs (on the Nano, RTC, and LED&KEY board) to show through. It’s not really much of a problem and I could always put some tape over them.

I needed to add some printed labels to the buttons and I decided to go with a new technique. I exported the layout as a DXF from Fusion 360 into Inkscape and drew up a pattern, including the lines to cut out. I passed this to my vinyl cutter (“Silver Bullet” brand) and used its SureCutsALot software to print the pattern with registration marks, then align the cutter to those registration marks and precisely cut out the holes. This worked extremely well and is a technique I’ll certainly use again.

On the final version, I printed/cut the cover in 210gsm card, then put it on some baking paper and sprayed heavily with clear gloss polyurethane. This made it look and feel much more like plastic.

The final result looks quite nice.

Except when you look at wiring on the back.

Here I’ve used the reverse of my usual technique and glued small MDF islands down to the PLA. These are 6mm thick with holes tapped for M3 screws which hold small terminal strips for soldering. It works, and makes the soldering easier, but it’s not pretty.

The software:

The program running on here is pretty simple (about 700 lines) with by far the bulk of it to do with using the buttons to edit the settings. The actual code to measure the temperature and control the heater is only a few lines.

  // CONTROL //
  unsigned long newControlTime = millis();
  if (newControlTime - oldControlTime > controlInterval) {
    oldControlTime = newControlTime;
    if (isValidTime && isValidTemp) {
      if (HereButtonPressed || (!beforeStart && !afterFinish && (settings[setTHISWEEK + DayOfWeekOffset].value == 1))){
        //HERE mode
        float target = settings[setTEMPHERE].value;
        heaterOn = (lastTemperature < target);
      } else {
        //AWAY mode
        float target = settings[setTEMPAWAY].value;
        heaterOn = (lastTemperature < target);
      }
    }else {
      heaterOn = false;
      Serial.println("Control: not valid.");
    }
    //write to digital output for SSR
    digitalWrite(SSRDATAPIN, heaterOn);
  }

Conclusion:

It works!

I can think of lots of improvements, but it works and I learned a lot of new techniques.

Alas, the recipient really wants WiFi connectivity so she can change the settings (particularly whether she is here/away today) without going out (in the cold) to the shed. So the next part of this project will be hooking up an ESP32 which will send and receive information from the Arduino (via serial), and present the settings as a web server on the home network.