What's new

Wifi hygrometer build

Rating - 100%
20   0   0
Joined
Feb 23, 2009
Messages
700
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:


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:

funkejj

BoM December 09
Rating - 100%
255   0   0
Joined
Oct 7, 2009
Messages
2,626
Location
Camdenton, Mo
Ok so how much? I need one no I want two one for the top and one for the bottom of my humidor. This would be sweet.
 
Rating - 100%
20   0   0
Joined
Feb 23, 2009
Messages
700
It does have a 5v output... :)

I'm going wireless, hence the battery, but you can use a wall adaptor and control whatever power hungry devices you want with it.
 
Rating - 100%
17   0   0
Joined
Oct 5, 2009
Messages
783
Location
Blighty
I've had a timer built for me which runs PC fans and provides a power connection for LED lights. If I could power the wifi hygrometer from it as well that would be so sweet. (and geeky but thats only because i dont have it (yet)

Tempted to build a few extras ???
 
Rating - 100%
20   0   0
Joined
Feb 23, 2009
Messages
700
Ya man, if this works, I'm definitely down to make for the BOTL community. Let's see if I can get mine working first before I commit to anything more complicated.
 
Rating - 100%
4   0   0
Joined
Oct 22, 2009
Messages
198
Just curious, but was there any specific reason that you went with the WiFi Shield and Arduino Main Board as opposed to just using the Arduino Yellow Jacket 1.0?
 
Rating - 100%
20   0   0
Joined
Feb 23, 2009
Messages
700
No real reason.

I'd initially planned to do a Bluetooth hygro and had bought some bits for that including the arduino. I'm also a total beginner and the Duemilanove is a super easy platform to learn on and not have to deal with getting/building a USB connector, etc.

The Yellow Jacket is a great option, I'm just not there quite yet. If I could start over I'd go with the Blackwidow which has all the benefits of the Duemilanove but comes in about $20 cheaper than my set-up.
 
Rating - 100%
20   0   0
Joined
Feb 23, 2009
Messages
700
Made some progress this weekend:



It's now much prettier and compact.



The little red light means it's talking with my computer. Still need to play with it more to talk to my router and Twitter, but I'm getting close.
 

Bigdankcloud

I read your bs... alot
Rating - 100%
2   0   0
Joined
Aug 31, 2009
Messages
155
Location
Methuen, MA
I have a suggestion. Would it make sense to get the wires that go to the SHT15 to go to a connector that would work with a ribbon cable like the Cigar oasis cable, and then have the arduino outside? This is me thinking for those of us that have desktop humidors and dont want to give up the space. It would take some connectors and some more angry time with wiring, but it might be worth it.
 
Rating - 100%
20   0   0
Joined
Feb 23, 2009
Messages
700
Ya it'd be easy to put a longer connector on the SHT. I didn't because I don't want to put a hole in my humidor and I've got the space so it's easier for my to put the whole unit inside.
 
Top