Code Monkey home page Code Monkey logo

thermostat's Introduction

Spark Open Source Thermostat

This repo contains all of the software goodies produced in a 18-hour Spark Team Hackaton described in detail on the Spark Blog.

Hardware

The thermostat display is composed of 3 Adafruit Mini 8x8 LED Matrix boards.

The temperature and humidity are sensed using a Honeywell HIH6131-021-001.

These are all controlled by the Spark Core using a common I2C bus where pin D0 is SDA and pin D1 is SCL. The displays (from left to right) are on I2C addresses 0x70, 0x71, and 0x72.

Schematic

The details of the circuit design and implementation can be viewed via EAGLE (a free program for PCB design, downloadable here). The eagle file is in the hardware/EAGLE folder.

Physical Design

3D model sketch-up files are available in hardware/folder. If you're viewing this on GitHub (and using a modern browser), you can view a 3D rendering of it too.

Firmware

To build firmware for this product, you'll first need to be able to build Spark Core firmware by following the instructions shown here.

Once you have that working, you can simply copy all of the files from /firmware in this repo into core-firmware/src and run make again to build. (i.e. cp thermostat/firmware/* core-firmware/src)

Alternatively, you could use the Spark Web IDE.

Server Setup

The server components are:

  • a Rails 3.2 app
  • Sidekiq and Redis for background job processing

Development was done on OS X.

Dependencies

  • Ruby 2.0 (recommended to use rvm, rbenv, chruby, or other ruby version manager) (this app is ruby-2.0.0-p247)
  • bundler: gem install bundler
  • Install redis: brew install redis
  • Install foreman: download package from here https://github.com/ddollar/foreman
  • bundle install

Run Locally

In one terminal:

redis-server /usr/local/etc/redis.conf

(following instructions from homebrew install)

In another terminal:

bash script/start_server.sh
  • Note: You might need to change the SPARK_CORE_DEVICE_ID and SPARK_CORE_ACCESS_TOKEN env vars in this .sh file for this to work.

Hit http://localhost:5000 in a browser

Dev tips

You can put binding.pry pretty much anywhere in the code to bring up an interative debuging console. Then hit a brower make or whatever, and in the terminal where the start_server.sh script ran, you can type commands (like a var name) and see their value, etc.

The "SQLite Professional Read-Only" OS X app is a nice free app to look at the data the app is generating in real time.

When developing, it's nice to be able to destroy everything and start fresh when you are hacking:

bash script/bomb_and_rebuild.sh

What's Next?

Get your hack on, :), have fun. If you do something cool with anything in here, consider sharing it on the community site.

Check out some of these other related open thermostat projects:

If you want to list your cool open thermostat project here, issue a pull request.

If your are interested in continuing the effort to build an easy-to-build-and-install Spark powered open-source thermostat, please contact [email protected] or create a GitHub issue. Though we'd love to do this ourselves, we don't currently have the bandwidth here at Spark. Hope to hear from you.

thermostat's People

Contributors

hagenburger avatar joegoggins avatar kennethlimcp avatar towynlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thermostat's Issues

Code will not compile in Web IDE

Hi there!

Newbie here trying to pull off the hacked Nest thermostat for a school project. So I guess my issue is, the codes located in Spark/thermostat/firmware aren't compatible to the Spark Web IDE, as it runs only .cpp and .h and some of the files are either .mk and .c . after finding a .cpp version of glcdfont.c, it raised issues in the code relating to code that I guess is integrated in the firmware in the Spark Core.

Is there anywhere else where I should be accessing the codes to use in the Web IDE or is the hacked Nest thermostat not achievable without local development?

I hope I'm phrasing all this correctly!

Any help greatly appreciated.

Here's the error text:

In file included from ../inc/spark_wiring.h:29:0,
from Adafruit_GFX.h:4,
from Adafruit_GFX.cpp:34:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]

warning "Defaulting to Release Build"

^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/spark_wiring_stream.h:36,
from ../inc/spark_wiring_i2c.h:30,
from Adafruit_LEDBackpack.h:21,
from Adafruit_LEDBackpack.cpp:21:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]

warning "Defaulting to Release Build"

^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/spark_wiring_stream.h:36,
from ../inc/spark_wiring_i2c.h:30,
from Adafruit_LEDBackpack.h:21,
from application.cpp:1:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]

warning "Defaulting to Release Build"

^
application.cpp: In function 'void saveTemperature()':
application.cpp:53:3: error: 'Serial' was not declared in this scope
Serial.println("Saving temperature to flash");
^
application.cpp:55:58: error: 'sFLASH_WriteBytes' was not declared in this scope
sFLASH_WriteBytes(values, DESIRED_TEMP_FLASH_ADDRESS, 2);
^
application.cpp: In function 'void loadTemperature()':
application.cpp:60:3: error: 'Serial' was not declared in this scope
Serial.println("Loading and displaying temperature from flash");
^
application.cpp: In function 'int setTemperatureFromString(String)':
application.cpp:81:3: error: 'Serial' was not declared in this scope
Serial.print("Setting desired temp from web to ");
^
application.cpp: In function 'void setup()':
application.cpp:117:3: error: 'Serial' was not declared in this scope
Serial.begin(9600);
^
application.cpp: In function 'void loop()':
application.cpp:139:5: error: 'Serial' was not declared in this scope
Serial.print("I2C Status bits are ");
^
application.cpp:161:5: error: 'Serial' was not declared in this scope
Serial.print("Potentiometer reading: ");
^
application.cpp:183:7: error: 'Serial' was not declared in this scope
Serial.print("Setting desired temp based on potentiometer to ");
^
make: *** [application.o] Error 1

I'm getting the following build errors on your web IDE

Adafruit_GFX.cpp:39:0: warning: "pgm_read_byte" redefined [enabled by default]
#define pgm_read_byte(addr) ((const unsigned char *)(addr))
^
In file included from ../wiring/inc/spark_wiring.h:37:0,
from Adafruit_GFX.h:4,
from Adafruit_GFX.cpp:34:
../wiring/inc/spark_wiring_arduino.h:32:0: note: this is the location of the previous definition
#define pgm_read_byte(x) (
(x))
^
thermostat.cpp:8:18: error: variable or field 'setupMatrix' declared void
void setupMatrix(Adafruit_8x8matrix m);
^

thermostat.cpp:8:18: error: 'Adafruit_8x8matrix' was not declared in this scope
thermostat.cpp: In function 'void saveTemperature()':
thermostat.cpp:56:58: error: 'sFLASH_WriteBytes' was not declared in this scope
matrix2.clear();
^

thermostat.cpp: In function 'void setup()':
thermostat.cpp:111:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]
{
^
thermostat.cpp:113:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]

^
thermostat.cpp:114:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]
matrix1.begin(0x70);
^
thermostat.cpp:115:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]
matrix2.begin(0x71);
^
thermostat.cpp:116:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]
matrix3.begin(0x72);
^
make[2]: *** [../build/target/user/platform-0-lthermostat.o] Error 1
make[1]: *** [user] Error 2
make: *** [main] Error 2
Ready.

If I remove the include "application.h" I get the following build errors

Adafruit_GFX.cpp:39:0: warning: "pgm_read_byte" redefined [enabled by default]
#define pgm_read_byte(addr) ((const unsigned char *)(addr))
^
In file included from ../wiring/inc/spark_wiring.h:37:0,
from Adafruit_GFX.h:4,
from Adafruit_GFX.cpp:34:
../wiring/inc/spark_wiring_arduino.h:32:0: note: this is the location of the previous definition
#define pgm_read_byte(x) (
(x))
^
thermostat.cpp: In function 'void saveTemperature()':
thermostat.cpp:55:58: error: 'sFLASH_WriteBytes' was not declared in this scope
matrix2.clear();
^

thermostat.cpp: In function 'void setup()':
thermostat.cpp:110:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]
{
^
thermostat.cpp:112:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]

^
thermostat.cpp:113:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]
matrix1.begin(0x70);
^
thermostat.cpp:114:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]
matrix2.begin(0x71);
^
thermostat.cpp:115:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:270): Spark is now Particle. [-Wdeprecated-declarations]
matrix3.begin(0x72);
^
make[2]: *** [../build/target/user/platform-0-lthermostat.o] Error 1
make[1]: *** [user] Error 2
make: *** [main] Error 2
Error: Could not compile. Please review your code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.