Skip to the content
PCBKitNew board
2 layers46.5 × 65 mmCave, the printed circuit board in 3D

An open source, low-cost, Raspberry Pi powered, smart thermostat.

Size
46.5 × 65 mm
Copper layers
2
Thickness
1.6 mm
Parts
31
Nets
55
Pads
116
Tracks, vias
264, 1
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
13 Aug 2017
Updated
16 Jun 2022

Overview

Cave is an open-source printed circuit board by VectorSpaceHQ, from the VectorSpaceHQ/Cave repository on GitHub, published under the GPL-3.0 licence. It is a 2-layer board of 46.5 × 65 mm with 31 parts on 55 nets, routed with 264 tracks and 1 via.

It is built around the DS18B20, LM2576S-5.0 and LM386. Its parts include 7 capacitors, 7 resistors, 6 diodes, 4 connectors and 3 ICs. It belongs with the home automation and IoT boards of this library.

Main components

3

README

README.rst

An open source, low-cost, Raspberry Pi powered, smart thermostat. Caves are generally cooler than nests.

Overview

This program's goal is to maximize the amount of time spent in the comfort zone while minimizing the energy spent when the building is occupied.

Structure

This system is composed of a server, one or more thermostats, and optional nodes. Their purposes and interactions are as follows,

Server

The server hosts the MySQL database and the web interface. Its purpose is to collect and analyze the sensor data from the thermostat(s) and any additional nodes, and use that information to direct the thermostat(s). In essence, the server is smart. The server can be a dedicated computer or it can run on the Raspberry Pi, alongside the thermostat program.

Thermostat

The thermostat measures temperature and directly interfaces with the wiring of the HVAC unit. It reports all measurements to the server and its actions are determined by the server. The thermostat is intended to be the Raspberry Pi.

Nodes

Nodes are optional pieces of hardware that provide additional sensor data to the MySQL database such as temperatures, humidity, and motion. Nodes might be of value in large spaces or in rooms isolated from the thermostat.

Nodes publish data using the MQTT protocol. This is done rather than modifying the MySQL database directly, simply because these nodes are small and rarely support SQL, as in the case of the ESP8266. The RPi subscribes to the MQTT channel and inserts the data it receives into the SQL database.

Installation

clone the repository to the server and thermostat(s). :: git clone https://github.com/VectorSpaceHQ/Cave

Server

Install mysql server on the server. :: sudo apt-get install mysql-server

Install supporting packages. :: sudo apt-get install python3-dev python3-pip python3-setuptools libmysqlclient-dev python3-mysql

Generate the initial MySQL database manually, then run ./src/database.py to create the tables :: mysql CREATE DATABASE hvac; quit ./src/database.py

You can confirm that the hvac database was added to your mysql server, by loging in at http://localhost/phpmyadmin/

Install required python packages. :: sudo pip3 install -r ./src/requirements.txt

Install Mosquitto on the server for MQTT brokering. :: sudo apt-get install mosquitto

Modify server/token.txt and server/server.conf files with appropriate values based on your wiring and preferences.

Thermostat

Install required python packages. :: sudo pip3 install -r ./thermostat/requirements.txt

Modify thermostat/token.txt and thermostat/thermostat.conf files with appropriate values based on your wiring and preferences.

Enable SPI and 1-Wire. :: sudo raspi-config

Advanced Options > Enable SPI and 1-Wire

Services copy cave_server.service to /etc/systemd/system/ on the server copy cave_thermostat.service to /etc/systemd/system/ on the thermostat (RPi)

enable both of these services on their respective machines using sudo systemctl enable cave_server.service sudo systemctl enable cave_thermostat.service

Usage

On the server, :: ./server/server.py start

On the RPi thermostat run, :: ./thermostat/thermostat.py start

MySQL database

The database contains four tables.

ModuleInfo

This table contains an entry for each module (thermostat or node) connected to the system. It includes a unique ID, a description of the module's location, a firmware version, and boolean values to represent the presence of temperature, humidity, light, and motion sensors.

SensorData

This table logs all of the sensor readings, including the thermostat(s).

readingID, time, moduleID, location, temperature, humidity, light, sound, motion

ThermostatLog

This table logs only the thermostat readings.

timeStamp, mode, moduleID, MinTemp, MaxTemp, actualTemp, coolOn, heatOn, fanOn, auxOn

ThermostatSet

This table provides the current directive for the thermostat(s). The server writes to this table and the thermostat reads from it.

timeStamp, moduleID, targetTemp, targetMode, expiryTime, entryNo

SystemLog

This table logs the state of the entire system. timeStamp, Tthermostat, Toutside, Ttarget, Poccupancy

Testing

This software can be tested entirely on a single Raspberry Pi. Install the sample database found in /test, then run both the server.py and thermostat.py programs. :: mysql -uroot -p hvac < ./test/hvac_data.txt

text
python3 -m unittest discover

Hardware

Below is a wiring diagram for a Raspberry Pi zero with a temperature sensor, PIR sensor, and 4 channel relay.

.. image:: ext/thermostat_schematic_bb.png :align: center

** Standard thermostat pins *** Honeywell TH6320U2008 pin spacing of 5mm (https://www.mouser.com/ProductDetail/845-30.359), 1.3mm diameter. two 8 pin columns separated by 44.4mm (1.75in) *** Honeywell TH5320U1001 pin spacing of 5mm (https://www.mouser.com/ProductDetail/845-30.359), 1.3mm diameter. One 9 pin column.

HVAC 101

The following HVAC information is coppied directly from, https://github.com/Willseph/RaspberryPiThermostat

HVAC 101

HVAC (heating, ventilating, and air conditioning) can be implemented in different ways within a house or apartment, and varies for different countries based on the wiring and such. I'm not an expert in HVAC systems, I pretty much just learned enough to get by for this project, but here's a pretty useful guide: https://lrak.net/wiki/Thermostat_signals_and_wiring.html

My particular apartment uses a heat pump, which uses the very same compressor action for the air conditioner. The only difference is the air flow. This makes it possible to, in my case, use four wires from the HVAC panel behind the original thermostat for this project:

R (Red): This is the "common" wire, meaning that a circuit is completed when any of the other wires are connected to this one, hence the relay module. G (Green): This is the signal for the fan, which becomes activated when connected to R. Y (Yellow): This is the signal for the compressor. By default, the air flow is set to blow heat into the apartment. O (Orange): This is the signal to reverse the air flow from the compressor. With Y and O both active, the flow changes to blow cool air into the apartment. I broke this down to a pretty simple formula while I started writing the software for the controller:

R + G = Fan R + G + Y = Heater R + G + Y + O = Air conditioner

It's also very important to note that the wires coming out of my HVAC use a low voltage at 24V, not mains power. With a relay module completing the circuits, it should still work with mains electricity, but it is very dangerous and you should NOT mess with mains power unless you know exactly what you're doing! An accident involving high voltage and current can very easily kill you.

If your home HVAC does not use a compressor heat pump or for another reason you cannot use the same setup I'm using, you will have to do some research and potentially adjust the hvaccontroller.py script accordingly.

Parts

31
QtyValueFootprintReferences
4D_SmallDiode_THT:D_A-405_P7.62mm_HorizontalD1, D4, D5, D6
3220Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR5, R6, R7
2100uFCapacitor_THT:CP_Radial_D6.3mm_P2.50mmC5, C6
210uFCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC2, C3
10.047uFCapacitor_THT:C_Disc_D3.0mm_W1.6mm_P2.50mmC4
10.1uFCapacitor_THT:C_Disc_D3.0mm_W1.6mm_P2.50mmC1
110Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR4
11000uFCapacitor_THT:CP_Radial_D10.0mm_P2.50mmC7
1100uHInductor_THT:L_Axial_L5.3mm_D2.2mm_P7.62mm_Horizontal_Vishay_IM-1L1
110KResistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR2
110KPotentiometer_THT:Potentiometer_ACP_CA14-H2,5_HorizontalRV1
11KResistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR3
1DS18B20Package_TO_SOT_THT:TO-92_InlineU2
1D_SchottkyDiode_THT:D_A-405_P7.62mm_HorizontalD3
1LED_RCBGLED_THT:LED_D5.0mm-4_RGB_Staggered_PinsD2
1LM2576S-5Package_TO_SOT_THT:TO-220-5_VerticalU1
1LM386Package_DIP:DIP-8_W7.62mmU3
1LOGOcave:vs_logoG***
1MicrophoneConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalMK1
1PIRsensorConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ2
1PWRConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ3
1R_PHOTOResistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR1
1Raspberry_Pi_2_3Connector_PinHeader_2.54mm:PinHeader_2x20_P2.54mm_VerticalJ1
1RelayOutputConnector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_VerticalJ4

Questions

How big is the Cave PCB?

It measures 46.5 × 65 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Cave use?

31 parts, built around the DS18B20, LM2576S-5.0 and LM386. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Cave KiCad files?

From the VectorSpaceHQ/Cave repository on GitHub, at the commit this page was made from: the board is pcb/cave.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the Cave design in my own project?

Its repository publishes it under the GPL-3.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

Similar boards

  • 2 layers82.6 × 95.3 mmHive access pcb, the printed circuit board in 3D

    Hive access pcb

    Hive13/hive13-access-pcb

    KiCad files for the circuit board that controls doors.

    47 partsBSD-3-Clause
  • 2 layers62.9 × 47 mmESP32 CAN, the printed circuit board in 3D

    ESP32 CAN

    FL0WL0W/ESP32C3-CAN-Extender

    This module uses an ESP32C3 with WiFi and BLE. It has 3 configurable outputs (5V push pull, Open Drain, 12V pullup), 4 analog or digital inputs, CAN transceiver, and an automotive power supply so it can be installed…

    72 parts20GPL-3.0
  • 4 layers133.1 × 126.6 mmValiant turtle-2, the printed circuit board in 3D

    Valiant turtle-2

    simoninns/valiant-turtle-2

    The Valiant Turtle 2

    55 parts16GPL-3.0
  • 2 layers85 × 56 mmGrasPiB v1, the printed circuit board in 3D

    GrasPiB v1

    an-ven/graspib

    GPIB interface board for Raspberry Pi

    45 parts14
  • 2 layers172.2 × 82.8 mmPimoco, the printed circuit board in 3D

    Pimoco

    mlnoga/pimoco

    Telescope mount and focuser control with a Raspberry Pi

    22 parts11GPL-3.0
  • 2 layers111.4 × 88.4 mmMAZEBLAZE V3, the printed circuit board in 3D

    MAZEBLAZE V3

    SurajSonawane2415/MazeBlaze

    Developed a Line following and Maze Solving bot based on PID controller which can find the shortest path in a given maze.

    42 parts2
  • 2 layers235 × 235 mmRGB Panel R0, the printed circuit board in 3D

    RGB Panel R0

    bit-mechanic/Britecraft

    a remote controllable LED Panel

    299 parts1
  • 2 layers57.2 × 57.2 mmFlight Computer, the printed circuit board in 3D

    Flight Computer

    explosion33/IREC

    SARP Payload DomeCracker Gyro 2024-2025

    89 parts1MIT