Temperature sensor and Open-Your-Windows Alert

Advice on general approaches or feasibility and discussions about game design

Temperature sensor and Open-Your-Windows Alert

Postby lastfuture » Tue Jul 21, 2015 9:40 am

Hi everyone,

I've had it with these temperatures so I've decided to turn my Gamebuino into a monitor that sits near a window, compares the outside to the inside temperature and alerts me with a sound when it's time to open the windows because it has gotten cooler outside than inside.

On the software side of things everything looks great with manually set temperatures. If the temperature difference passes a threshold of 1.5 °C or -1.5 °C I get an alert that I can dismiss which is telling me to open or close the windows. Once dismissed an alert won't fire again until the temperature difference has crossed the zero mark (making sure it won't alert me again after dismissing due to slight temperature fluctuations).

It's also internally already mapping values from 0-1023 to temperatures to be prepared for analog input later. Of course the mapped temperature range is arbitrary right now and needs to be calibrated once I attach temperature probes.

Video of demo in action:


Now I need some guidance on the hardware side of things, hooking up the sensors. I'm going to buy two simple analog temperature probes that are within the range of temperatures I'm expecting. (EDIT: Thermistor was the term I was missing. I'm going to buy two thermistors.)

I'm assuming I can just use the raw analog pins 4 and 5 by hooking one probe up to I2C DAT and the other to I2C CLK and using the I2C port's GND for both, but not actually using the I2C protocol.

I'm also assuming the I2C GND is the pin at the rectangular solder pad, correct?

Should I cut the I2C pullup jumper and use my own pullup resistors or will it serve my purpose just fine? I have not a lot of experience but 4k7 feels like it might be too much. Just a gut feeling though, you guys can probably tell me.

Any other ideas or tricks when it comes to the hardware side of things?
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Temperature sensor and Open-Your-Windows Alert

Postby lastfuture » Tue Jul 21, 2015 5:04 pm

I've found a part called DS1820 that's a digital 1-wire temperature sensor (using the 1-wire protocol) with a 0.5 °C resolution. Conveniently it seems to need a 4k7 pull-up resistor, so I think I can wire this directly via the I2C port's GND and one of the DAT or CLK pins. It should in theory work to put both sensors onto the same pin since they've got unique IDs for individual polling. I'll try this out later and report back.
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Temperature sensor and Open-Your-Windows Alert

Postby lastfuture » Tue Jul 21, 2015 6:50 pm

Success!
I've got one DS1820 connected and reporting plausible values! Reading two sensors should be as simple as wiring them in parallel, so theoretically I should be able to make the same thing again, connect it to the other I2C port and address it at Index 1 instead of 0 (see sketch below)

Image

Here's the data sheet for the DS1820 and the 1-Wire Library and Dallas Temperature Control Library

The wiring is straight forward: GND to I2C GND, VDD to I2C 3V3 and DQ to I2C SDA (which is A4 or Pin 18 respectively)

The test sketch for the simple test-thermometer is this then:
Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
#include <OneWire.h>
#include <DallasTemperature.h>

Gamebuino gb;

#define ONE_WIRE_BUS 18 // Pin 18 / A4 SDA of I2C
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
extern const byte font5x7[]; //a large, comfy font

void setup() {
  //pinMode(12, INPUT);
  sensors.begin();
  gb.begin();
  gb.display.setFont(font5x7);
  gb.titleScreen(F("Temperature Test"));
  gb.display.fontSize = 2;
  gb.display.clear();
  gb.display.persistence = true;
  gb.battery.show = false;

}

void loop() {
  if (gb.update()) {
    if ((gb.frameCount%70) == 0) {
      sensors.requestTemperatures(); // Send the command to get temperatures
      // -127 °C means not connected, 85 °C is the init value
      gb.sound.playTick();
      gb.display.clear();
      gb.display.print(sensors.getTempCByIndex(0));
      gb.display.println(F(" C"));
    }
  }
}
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Temperature sensor and Open-Your-Windows Alert

Postby Sorunome » Tue Jul 21, 2015 8:23 pm

This is looking like some awesome stuff!
And yes, the temperatures have been insane indeed ^^
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Temperature sensor and Open-Your-Windows Alert

Postby lastfuture » Tue Jul 21, 2015 9:03 pm

Alright, it's working!

Image

Next: Buying a DS1820 that's waterproof. I hear they're available with a metal capsule and waterproof tube around the cables
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm


Return to Project Guidance & Game development

Who is online

Users browsing this forum: No registered users and 114 guests

cron