Twitter icon
Facebook icon
LinkedIn icon
Google icon
Reddit icon
StumbleUpon icon
Del.icio.us icon

Voice Control Your Thermostat with a MATRIX Device - Rhasspy

Added to IoTplaybook or last updated on: 02/08/2021
Voice Control Your Thermostat with a MATRIX Device - Rhasspy

Story

Required Hardware

  • Raspberry Pi 3B/B+ or 4 - Only tested on 3B but this should work on any.
  • MATRIXCreator - Raspberry Pi does not have a built-in microphone, the MATRIXCreator has an 8 mic array - Buy MATRIX Creator.
  • Power adapter for Raspberry Pi.
  • Micro SD Card (Minimum 8 GB) - An operating system is required to get started. You can download Raspbian and use the guides for Mac OS, Linux and Windows on the Raspberry Pi website.
  • (Optional) A USB Keyboard & Mouse, and an external HDMI Monitor - we also recommend having a USB keyboard and mouse as well as an HDMI monitor handy. You can also use the Raspberry Pi remotely, see this guide from Google.
  • Speakers that can connect to (and preferably be charged by) the Raspberry PI

OR

 

Things used in this project

Hardware components

MATRIX Creator
MATRIX Labs MATRIX Creator
 
× 1

Matrix

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
Tested using 3 Model B, 2 and 4 should also work
× 1

Newark

Adafruit

thePiHut

SparkFun

Female/Female Jumper Wires
Female/Female Jumper Wires
 
× 3

Newark

Adafruit

Gravity: Digital 5A Relay Module
DFRobot Gravity: Digital 5A Relay Module
 
× 3

DFRobot

Software apps and online services

 
Rhasspy
 
  Rhasspy

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Let's Get Started

If you haven't already, be sure to set up your Raspberry Pi with your MATRIX Device.

1. Install MATRIX Libraries and Rhasspy

Follow the steps below in order for Rhasspy to work on your Raspberry Pi.

2. Creating an Intent

Open Rhasspy's web interface by opening your browser to http://YOUR_PI_IP_HERE:12101 and then click on the Sentences tab. All intents and sentences are defined here.

By default, there are a few example sentences in the text box. Remove the default intents and add the following:

[ReadTemp]
tell [me] [the] [current] temperature
(what is | what's) the temperature
how (hot | cold) is it

[SetTemp]
set [the] temperature to (0..100){temp} [degrees] [celsius] [fahrenheit]
make it (0..100){temp} [degrees] [celsius] [fahrenheit]

Here, ReadTemp and SetTemp are intents. You can change the wording to anything that works for you as long as you keep [ReadTemp] and [SetTemp]unchanged, as these intent names will be used in the code.

3. Catching the Intent

Install git on your Raspberry Pi.

sudo apt install git

Download the repository.

git clone https://github.com/matrix-io/rhasspy-thermostat

Navigate to the folder and install the project dependencies.

cd rhasspy-thermostat
npm install

Run the program

node index.js

Alternatively

If you want to add this to your existing Rhasspy intent catcher JS file, download relay.js and add the following code to your file.

let relay = require('./relay.js'); // near the top somewhere
... 
// this section below where you actually catch intents
if ("ReadTemp" === data.intent.name)
{
    relay.startWaiting();
    relay.tellTemp();
    //respond with the temperature
    say("The current temperature is "+ Math.floor(relay.currentTemperature()) + " degrees Celsius");
    relay.sleep(3000);
    relay.stopWaiting();
}
if ("SetTemp" === data.intent.name)
{
    relay.startWaiting();
    relay.makeTemp(data.slots.temp-1,data.slots.temp+1);
    relay.stopWaiting();
}

Important Information

relay.js includes the code required to turn the relay on and off, control the leds, and collect the temperature. This relay will control power to the thermostat.

By default the temperature is read and set in Celsius. To convert to Fahrenheit, use the equation (C x 9 / 5) + 32 = F on the equation used to assign the currentTemperature variable its value, i.e.

Set the lowestTemperature and highestTemperature variables inrelay.js to the lowest and highest temperature you want the thermostat to go to; this also sets the relative number of leds that turn on when displaying the temperature.

5. Wiring the Relay

Depending on the relay you use, the main connections to input to the relay are power (VCC), ground (GND), and signal (IN).

For the relay below, you would connect 5V from your MATRIX device to VCC, the ground pin from your MATRIX device to GND, and GPIO pin 0 to IN to match the relay.js file.

Before starting this part, flip the breaker in your house that powers the thermostat you will be working on. That way there is no electricity running through the wires while you are handling them.

Open up the wall thermostat you chose. Under the plastic there will be 6 wires:

  • G: The G terminal controls the fan relay and is responsible for turning the blower fan on and off automatically or manually via the thermostat.
  • RC: The RC terminal is the 24-volt cooling power supply.
  • RH: The RH terminal is the 24-volt heating power supply. (Note: The RCand RH terminals are jumpered together in a four-wire heat/cool system and a single-stage heat pump system, but not in a five-wire heat/cool system.)
  • Y/O: The Y/O terminal is used to control the cooling condenser. When the thermostat calls for cooling, signals are sent to power up the condenser and the blower fan, cooling your home.
  • W/B: The W/B terminal controls the heat relay or valve. When the thermostat calls for heat, a signal is sent to power up the furnace and the blower fan or the boiler, heating your home.
  • Y1: The Y1 terminal is used for the compressor contact in a single-stage heat pump installation.

If there is a Y1 wire, set it aside. Keep in mind that not all homes use the heater, such as homes in the South; rather they use the ambient heat of the environment to slowly warm the house while the cooler is off. If this is the case, only the G and Y/O wire are truly necessary to get the thermostat to work.

If you truly want to use the heater, two diodes are required, so that power doesn't flow back from the blower to the cooler or from the blower to the heater while only one of the relays is on.

The schematic below is a representation of the situation in which the heater would be incorporated. The wire to the left of the relays is supposed to be connected to the power supply, while the wires on the right represent the blower (middle), cooler (bottom), and heater (top) wires. Since the blower needs to be used when turning on the heater or cooler, the blower is connected to the NO terminals of both relays and two diodes are attached to each of its ends preventing the power from going to the other relay.

the wire to the left of the relays is supposed to be connected to the power supply, while the wires on the right represent the blower (middle), cooler (bottom), and heater (top) wires.

the wire to the left of the relays is supposed to be connected to the power supply, while the wires on the right represent the blower (middle), cooler (bottom), and heater (top) wires.

This is the schematic for the simple "cool only" HVAC system, with the blower and cooler connected to the NO side of the relay.

Disconnect the G, Y/O, and RH/RC wires from the thermostat for a cool-only HVAC system. These are the only wires that will be used for this guide.

The relay has 3 outputs that you could connect the 3 live wires from the wall to. The signal from your MATRIX device controls the COM port, so one the RC/RH wires has to be connected to the COM port and the blower and cooler to the NO port. NO means "normally open", and NC means "normally connected".

7. Printing & Assembling the Case

We designed a case to replace the wall thermostat with the MATRIX Creator + Raspberry Pi assembly. If you would like to print a similar case, find the STL files attached here.

The back piece of the case has a hole for all the wires to go through. The back piece is secured to the front piece through a pressure fit. Both pieces have holes to screw the piece onto the wall.

And there you have it! Your custom thermostat complete with an enclosure and ready to be controlled using voice commands.

Enjoy the laziness.

Custom parts and enclosures

Case files

matrix-io / rhasspy-thermostat - Read More

Latest commit to the master branch on 12-18-2020 - Download as zip

Code

rhasspy-thermostat

Link to all the code you might need for this

matrix-io / rhasspy-thermostat - Read More

Latest commit to the master branch on 12-18-2020 - Download as zip

Credits

Llum Acosta

Llum Acosta

Alfred Gonzalez

Alfred Gonzalez

Innovation Manager at MATRIX Labs

Contact

Thanks to Alexis Cruz.

 

Hackster.io

This content is provided by our content partner Hackster.io, an Avnet developer community for learning, programming, and building hardware. Visit them online for more great content like this.

This article was originally published at Hackster.io. It was added to IoTplaybook or last modified on 02/08/2021.