Skip to content

Instantly share code, notes, and snippets.

@dydx
Created January 20, 2012 06:01
Show Gist options
  • Select an option

  • Save dydx/1645597 to your computer and use it in GitHub Desktop.

Select an option

Save dydx/1645597 to your computer and use it in GitHub Desktop.
Hardware base station for reading climate data along with a nice Processing GUI for your viewing pleasure
#include <SHT1x.h>
#define dataPin 4
#define clockPin 5
SHT1x sht1x(dataPin, clockPin);
void setup() {
Serial.begin(9600);
}
void loop() {
double temp_f, humidity;
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
Serial.print(temp_f);
Serial.print(":");
Serial.println(humidity);
delay(100);
}
/**
Thermometer station - temperature and humidity display
Joshua Sandlin <[email protected]>
*/
import processing.serial.*;
Serial climateSensor;
String rawData, tempF, humidity;
int x = 10;
PFont fontA;
void setup() {
size(400, 130);
background(102);
// establish a connection to our serial port (xbee)
// and clear out any mid-transaction cruft.
String serialPort = Serial.list()[0];
climateSensor = new Serial(this, serialPort, 9600);
climateSensor.clear();
rawData = climateSensor.readStringUntil(10);
rawData = null;
fontA = loadFont("FreeMono-48.vlw");
textFont(fontA, 32);
}
void draw() {
if( climateSensor.available() > 0) {
rawData = climateSensor.readStringUntil(10);
if( rawData != null) {
background(102);
// data from the station is sent in the format:
// "temp:humidty", so we split it at ":"
text("Temperature: ", 30, 50);
text(rawData.split(":")[0], 275, 50);
text("Humidity: ", 30, 85);
text(rawData.split(":")[1], 275, 85);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment