- 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
- A MATRIX Kit
- Speakers
If you haven't already, be sure to set up your Raspberry Pi with your MATRIX Device.
- MATRIX Creator SetupOnce set up, ensure you enable SSH on your Raspberry Pi.
Follow the steps below in order for Rhasspy to work on your Raspberry Pi.
2. Creating an IntentOpen 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.
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();
}
ImportantInformation
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 Farenheit, 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 RelayDepending 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 RC and 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 require 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.
This is the schematic for the a 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 CaseWe 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.
Comments