4/16 - It's working. Update on bottom of page 2, or check the Twitter feed.
Figured this deserves a new thread since the other one was for a Bluetooth concept.
The plan is to build a wifi enabled hygrometer and thermometer that will Tweet the conditions inside my cabinet every two hours to www.twitter.com/MyHumidor. If the humidity dips below a certain level, I'm thinking 63%, it will dispatch a warning email to my personal email every 12 hours. It will run off a 9v battery.
----
I'm not the first person to make a Tweetidor. It was first done by this guy:
http://74.125.113.132/search?q=cache:KcQvlQwdjzcJ:longashes.org/blog/2009/09/16/tweetidor-the-humidor-that-tweets+http://longashes.org/blog/2009/09/16/tweetidor-the-humidor-that-tweets&cd=1&hl=en&ct=clnk&gl=us
The first wifi version was built by this guy: http://asynclabs.com/forums/viewtopic.php?f=18&t=132
His Twitter feed: http://twitter.com/jhumidor
----
Here's my project as it sits now:
I'm using a SHT15 humidity and temp sensory from www.sparkfun.com
The brain is an arduino microcontroler (www.arduino.cc) also bought from sparkfun
The wifi shield is from www.asynclabs.com
Today I will receive a prototyping shield which I'll use to make the thing look a bit prettier.
----
So far I've been playing with the code for the sensor. Yesterday I had it tracking the temp and humid in my bedroom while was at work. It rained around 3pm and it was cool to see the temp and humidity curves converge.
The next step will be playing with the code for the wifi shield to get it to play nice with my home network and Twitter. Unfortunately my router is one of the very few wifi APs that is not compatable with the wifi shield I'm using so that'll be a small delay in the project's development.
Stay posted. I hope to get this thing done relatively soon.
--------
4/19/2010
It's finished. Here's my final code:
Figured this deserves a new thread since the other one was for a Bluetooth concept.
The plan is to build a wifi enabled hygrometer and thermometer that will Tweet the conditions inside my cabinet every two hours to www.twitter.com/MyHumidor. If the humidity dips below a certain level, I'm thinking 63%, it will dispatch a warning email to my personal email every 12 hours. It will run off a 9v battery.
----
I'm not the first person to make a Tweetidor. It was first done by this guy:
http://74.125.113.132/search?q=cache:KcQvlQwdjzcJ:longashes.org/blog/2009/09/16/tweetidor-the-humidor-that-tweets+http://longashes.org/blog/2009/09/16/tweetidor-the-humidor-that-tweets&cd=1&hl=en&ct=clnk&gl=us
The first wifi version was built by this guy: http://asynclabs.com/forums/viewtopic.php?f=18&t=132
His Twitter feed: http://twitter.com/jhumidor
----
Here's my project as it sits now:
I'm using a SHT15 humidity and temp sensory from www.sparkfun.com
The brain is an arduino microcontroler (www.arduino.cc) also bought from sparkfun
The wifi shield is from www.asynclabs.com
Today I will receive a prototyping shield which I'll use to make the thing look a bit prettier.
----
So far I've been playing with the code for the sensor. Yesterday I had it tracking the temp and humid in my bedroom while was at work. It rained around 3pm and it was cool to see the temp and humidity curves converge.
The next step will be playing with the code for the wifi shield to get it to play nice with my home network and Twitter. Unfortunately my router is one of the very few wifi APs that is not compatable with the wifi shield I'm using so that'll be a small delay in the project's development.
Stay posted. I hope to get this thing done relatively soon.
--------
4/19/2010
It's finished. Here's my final code:
Code:
/*
* A simple sketch that uses WiServer to send a tweet with the current system time every 90 minutes
*/
#include <WiServer.h>
#include <SHT1x.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
#define dataPin 7
#define clockPin 6
SHT1x sht1x(dataPin,clockPin); //data and clock pins for SHT1x
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,2}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"XXXXXXXX"}; // max 32 bytes
unsigned char security_type = 2; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"XXXXXXX"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------
// Auth string for the Twitter account
char* auth = "TWITTERUSERNAME:PASSWORD"; // Base64 encoded USERNAME:PASSWORD
long intervalHum = 30000; //set the interval for temp and humidity to be checked
long intervalTweet = 5400000; // Set the interval for tweets - 1.5 Hrs
float humidity; // Init humidty variable
float temp_f; // Init temp variable
int tweet = 0; /*Used to tweet once on initial startup. Otherwise
would have to wait until <intervalTweet> expires */
long previousMillis = 0;
long previousMillisTweet = 0;
long tweetTime = 0; // Time (in millis) when the next tweet should be sent
// This function generates a message with the current system time
void currentTemp() {
WiServer.print("[");
WiServer.printTime(millis()); // Append time Arduino has been running - gets around duplicate tweet filtering
WiServer.print("] ");
WiServer.print("Humidor temp and humidity is: ");
WiServer.print(temp_f);
WiServer.print("° F and ");
WiServer.print(humidity);
WiServer.print("%");
}
// A request that sends a Tweet using the currentTime function
TWEETrequest sentMyTweet(auth, currentTemp);
void setup()
{
// Initialize WiServer (we'll pass NULL for the page serving function since we don't need to serve web pages)
WiServer.init(NULL);
// Enable Serial output and ask WiServer to generate log messages (optional)
Serial.begin(9600);
WiServer.enableVerboseMode(true);
}
void loop()
{
if (tweet == 0) // Tweets once at inital startup. Next tweet won't happen for <intervalTweet>
{
++tweet; // Increment initial tweet count
Serial.println("Tweeting...");
sentMyTweet.submit();
}
// Set the temp and humidity to be checked every 30 seconds (defined by <intervalHum> global variable
// If you don't set this to a reasonable number the arduino seems to get so busy running the
// temp check functions it doesn't have time to run the WiShield TCP/IP stack - ergo all IP comms break
if (millis() - previousMillis > intervalHum)
{
previousMillis = millis();
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
}
// Set a tweet to occur every two hours (defined by <intervalTweet> global variable)
if (millis() - previousMillisTweet > intervalTweet)
{
previousMillisTweet = millis();
Serial.println("Tweeting");
sentMyTweet.submit();
}
WiServer.server_task();
}
Last edited: