I've already asked for input in the project guidance section but since it's complete now I'd like to present this little hack here.
I've combined my Gamebuino with two DS 1820 digital temperature sensors to make a thermometer that compares outside to inside temperature and sounds alarms when it's time to let cool outside air in or when to close the windows once it's cooler inside.
Quick demo:
The DS 1820 digital temperature sensors use the 1-wire protocol so I'm just connecting them to the I2C ports for convenience, not to actually talk I2C (1-wire also allows multiple parallel devices on one bus, which is why I connected one sensor to each port)
Here's the data sheet for the DS1820 and the 1-wire Library and Dallas Temperature Control Library.
The wiring I used is straight forward: GND to I2C GND, VDD to I2C 3V3 and DQ to I2C SDA (which is A4 or Pin 18 respectively)
then just include the libraries in the sketch and set up with the right pin
- Code: Select all
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 18 // Pin 18 / A4 SDA of I2C
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
and then read the temperatures like so
- Code: Select all
sensors.requestTemperatures();
temp_outside = sensors.getTempCByIndex(0);
temp_inside = sensors.getTempCByIndex(1);
(there's also a handy Fahrenheit conversion function)
Since the 1-wire library can address the sensors by index and the order is determined by their unique id the port I plug each of them into is irrelevant.
I weatherproofed both sensors with the help of a friend who had some molding silicone left over, but next time I'll try coating them in nail polish instead because I assume that's going to dampen the temperature response less than millimeters of silicone.
Curious to hear your thoughts on this or any tips and improvements.
-- Peter