README.md 5.09 KB
Newer Older
Jan Wagemakers's avatar
Jan Wagemakers committed
1 2
# Thermostat

Jan Wagemakers's avatar
Jan Wagemakers committed
3 4 5 6 7 8 9
This is a personal project where I'm creating a *smart* thermostat. The idea
is to make a *dumb* thermostat where you can change the setpoint over
**bluetooth**. A small computer like the Raspberry Pi communicates with this
*dumb* thermostat over bluetooth to make the *dumb* thermostat *smart*.

Theoretically it is possible to let just a computer like the Raspberry Pi
control the heating, but I don't trust computers enough to let them do the
Jan Wagemakers's avatar
Jan Wagemakers committed
10 11 12
control directly. Think about things like sd-card or file system corruption,
which on occasion can happen. 

Jan Wagemakers's avatar
Jan Wagemakers committed
13 14
By making use of a *dumb* microcontroller based thermostat, it's still
possible to control the heating when the *smart* part fails.
Jan Wagemakers's avatar
Jan Wagemakers committed
15

16
## pic18f1320 : dumb thermostat
Jan Wagemakers's avatar
Jan Wagemakers committed
17

Jan Wagemakers's avatar
Jan Wagemakers committed
18 19
* [schematic diagram](https://gitlab.com/jan.wagemakers/thermostat/blob/master/pic18f1320/thermostat.png)
* software, written in assembler (gpasm - GNU PIC assembler)
Jan Wagemakers's avatar
Jan Wagemakers committed
20

Jan Wagemakers's avatar
Jan Wagemakers committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
### Commands

By using a HC-05 Bluetooth module connected to the pic18f1320
microcontroller it's possile to send commands to the thermostat.

The following commands are recognized by the thermostat:

<table style="overflow:hidden; width:auto;">
  <thead>
    <tr>
      <th> </th>
      <th>Command to µC</th>
      <th>Answer from µC</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Get current temperature (Process Value)</td>
      <td><code class="highlighter-rouge">PV?</code></td>
      <td><code class="highlighter-rouge">21.0</code></td>
    </tr>
    <tr>
      <td>Get current SetPoint</td>
      <td><code class="highlighter-rouge">SP?</code></td>
      <td><code class="highlighter-rouge">20.7</code></td>
    </tr>
    <tr>
      <td>Set SetPoint</td>
      <td><code class="highlighter-rouge">SP=20.6</code></td>
      <td><code class="highlighter-rouge">20.6</code></td>
    </tr>
    <tr>
      <td>Get OutPut (0/1)</td>
      <td><code class="highlighter-rouge">OP?</code></td>
      <td><code class="highlighter-rouge">0</code> or <code class="highlighter-rouge">1</code></td>
    </tr>
    <tr>
      <td>Set Outside Temperature</td>
      <td><code class="highlighter-rouge">OT=-1.6</code></td>
      <td><code class="highlighter-rouge">-1.6</code></td>
    </tr>
    <tr>
      <td>Set (Outside) Atmospheric pressure</td>
      <td><code class="highlighter-rouge">OA=0999</code></td>
      <td><code class="highlighter-rouge">0999</code></td>
    </tr>
    <tr>
      <td>Set Year</td>
      <td><code class="highlighter-rouge">YY=19</code></td>
      <td><code class="highlighter-rouge">19</code></td>
    </tr>
    <tr>
      <td>Set Month</td>
      <td><code class="highlighter-rouge">MM=03</code></td>
      <td><code class="highlighter-rouge">03</code></td>
    </tr>
    <tr>
      <td>Set Day</td>
      <td><code class="highlighter-rouge">DD=09</code></td>
      <td><code class="highlighter-rouge">09</code></td>
    </tr>
    <tr>
      <td>Set hour</td>
      <td><code class="highlighter-rouge">hh=10</code></td>
      <td><code class="highlighter-rouge">10</code></td>
    </tr>
    <tr>
      <td>Set minutes</td>
      <td><code class="highlighter-rouge">mm=58</code></td>
      <td><code class="highlighter-rouge">58</code></td>
    </tr>
    <tr>
      <td>unknown</td>
      <td><code class="highlighter-rouge">blabla</code></td>
      <td><code class="highlighter-rouge">?</code></td>
    </tr>
  </tbody>
</table>

Jan Wagemakers's avatar
Jan Wagemakers committed
100 101 102 103 104 105 106 107 108 109
### Pictures PCB

![pcb1](http://www.janwagemakers.be/jekyll/assets/images/2018/PCB1.png)

![pcb2](http://www.janwagemakers.be/jekyll/assets/images/2018/PCB2.png)

![pcb3](http://www.janwagemakers.be/jekyll/assets/images/2018/PCB3.png)

![pcb4](http://www.janwagemakers.be/jekyll/assets/images/2018/PCB4.png)

110 111
![pcb5](http://www.janwagemakers.be/jekyll/assets/images/2018/PCB5.png)

Jan Wagemakers's avatar
Jan Wagemakers committed
112
![case](http://www.janwagemakers.be/jekyll/assets/images/2019/CASE.png)
113

Jan Wagemakers's avatar
Jan Wagemakers committed
114 115 116 117 118 119
## Raspberry Pi : smart thermostat

JAVA Spring Boot program that:

* communicates with *dumb* thermostat over bluetooth
* checks if a user is home by checking smartphone/bluetooth 
Jan Wagemakers's avatar
Jan Wagemakers committed
120
* creates a web interface at port 8080
Jan Wagemakers's avatar
Jan Wagemakers committed
121 122 123
* reads the outside temperature and atmospheric pressure from https://tgftp.nws.noaa.gov/data/observations/metar/stations/
* use the outside temperature and atmospheric pressure to lower the setpoint if it's warm outside
* it's possible to add/delete/change "users","rules" and "configuration" by using the web interface 
Jan Wagemakers's avatar
Jan Wagemakers committed
124 125 126 127 128

## Source

[https://gitlab.com/jan.wagemakers/thermostat/](https://gitlab.com/jan.wagemakers/thermostat/)

Jan Wagemakers's avatar
Jan Wagemakers committed
129 130 131 132 133 134 135 136 137 138
## Demo

A demo version of the web interface is available at 
[http://janw.mooo.com:24388](http://janw.mooo.com:24388). 

Note that in this demo version it's not possible to change the database
("rules", "users", "configuration"). The current temperature it shows is
just a random value. It's just there to show the current
interface.

Jan Wagemakers's avatar
Jan Wagemakers committed
139 140 141 142 143 144 145 146
## Screenshots

### Index

![index](http://www.janwagemakers.be/jekyll/assets/images/2018/thermostat_index.png)

### Users

Jan Wagemakers's avatar
Jan Wagemakers committed
147
![users](http://www.janwagemakers.be/jekyll//assets/images/2018/thermostat_users.png)
Jan Wagemakers's avatar
Jan Wagemakers committed
148 149 150

### Rules

Jan Wagemakers's avatar
Jan Wagemakers committed
151
![rules](http://www.janwagemakers.be/jekyll//assets/images/2018/thermostat_rules.png)
Jan Wagemakers's avatar
Jan Wagemakers committed
152 153

### Log
Jan Wagemakers's avatar
Jan Wagemakers committed
154

Jan Wagemakers's avatar
Jan Wagemakers committed
155
![log](http://www.janwagemakers.be/jekyll//assets/images/2018/thermostat_log.png)