Project showcase
The Angry Humidor (Humidor Monitor)

The Angry Humidor (Humidor Monitor) © GPL3+

This project takes hourly temperature and humidity readings from a humidor. A Web API sends the readings to Azure SQL and Twitter.

  • 3,890 views
  • 1 comment
  • 17 respects

Components and supplies

Abx00004 iso both
Arduino MKR1000
How cool is this little bugger?
×1
1899 00
Adafruit Humidity and Temperature Sensor
Library worked great
×1
Humidor
×1

Apps and online services

About this project

I WiFi enable something that that non-geeks would say "why did you do that?"   I added a MRK1000 to a humidor.  Every hour it sends temperature and humidity reading.

Now according geek laws, if you WiFi enable something that should not be Wifi enable, you must give it a Twitter account too.  So I did not want to lose my geek card, so created a twitter account for it.

The tweets are automated and random.  They are designed to be generally disgruntled.  The humidor thinks it is better than other humidors and it is not happy that it needs to report the temp and humidity to humans. This is how that project gets its name.

How it works is very simple. I used the Wifi101 Library's repeating example to create a post to a WEB API I wrote to get the temperature and humidity every hour.  The Web API writes the data to a database.   One out of a hundred readings will create a somewhat random sentence (generated much like a the Mad Libs books) and send a tweet via the Twitter API. www.randallcole.com/home/humidor pulls the data for the last 30 readings.   Sadly my wife can now track how many cigars I smoke by looking at the humidity drops.  Please don't tell her.

I would really like to thank Microsoft, Arduino, Adafruit and Hackster.io. I had a lot of fun doing this and I learned a lot. This was my first Arduino project.

Code

C# code to grab the values for the website. C#
This C# code with collect the data from the humidor, send it to azure, and create a somewhat random tweet to send to twitter.
  public ActionResult Index(string name, string code, string temp, string humitiy)
        {
           
            if (code == "Security GUID") //not strong but something
            {

                string message = dao.daoWrite.Humidor(name, temp, humitiy); //Writes to AZURE
                
                ViewBag.Message = message;
                Random rnd = new Random();
                int number = rnd.Next(0, 100);
                //number = 1;

                if (number == 1)
                {
                    string[] person = { "human", "buffoon", "idiot", "simpleton", "clown", "meat sac"};
                    string[] owner = { "owner", "creator", "proprietor", "coder", "engineer", "proprietor", "coder", "engineer" };
                    string[] contact = { "Email", "Tweet", "Send a text to", "Send a smoke signal to", "Please call", "Contact" };

                    Random rndcontact = new Random();
                    Random rndperson = new Random();
                    
                    Random rndowner = new Random();
                    int randomcontact = rndcontact.Next(0,5);
                    int randomperson = rndperson.Next(0,5);
                    int randomowner = rndowner.Next(0,7);
                    

                    string tweet = (String.Format("{0} my {1} {2}, my temperature is {3} F and the humidity is {4} percent", contact[randomcontact], person[randomperson], owner[randomowner], temp, humitiy));
                    ViewBag.Message = tweet;
                    twitter.send(tweet);  // tweet away!
                  
                }
            }
            else
            {
                ViewBag.Message = "false";
            }


            return View();
        }
MKR1000 Code to collect and send the data to the website.Arduino
I will update the code when I have time or a SSL post. This code will get you started with a simple get string.
#include <SPI.h>
#include <WiFi101.h>
#include "Adafruit_HTU21DF.h" 
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
char ssid[] = "SSID";      //  your network SSID (name) change this
char pass[] = "SSIDPasswordUrMomBhot";   //change this
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

// Initialize the Wifi client library
WiFiClient client;

// server address:
char server[] = "www.website.com"; //change this
//IPAddress server(64,131,82,241);

unsigned long lastConnectionTime = 0;            // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 3600L * 1000L; // delay between updates, in milliseconds

void setup() {
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);


 
  /*Initialize serial and wait for port to open:
 
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
 */
if (!htu.begin()) {
//    Serial.println("Couldn't find sensor!");
    while (1);
  }
  
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
//    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }
 
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
  //  Serial.print("Attempting to connect to SSID: ");
  //  Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    digitalWrite(6,HIGH);
delay(10000);
digitalWrite(6,LOW);
    
  }
  // you're connected now, so print out the status:
//  printWifiStatus();
}

void loop() {
 
  // if there's incoming data from the net connection.
  // send it out the serial port.  This is for debugging
  // purposes only:
  
  while (client.available()) {
    char c = client.read();
        digitalWrite(6,HIGH);
  }
digitalWrite(6,LOW);

  // if ten seconds have passed since your last connection,
  // then connect again and send data:
  if (millis() - lastConnectionTime > postingInterval) {
    httpRequest();
  }

}

// this method makes a HTTP connection to the server:
void httpRequest() {
float tempC = 0;
float tempF = 0;
tempC = htu.readTemperature();
tempF = (tempC * 1.8)+ 32;
float humi = htu.readHumidity();

if (humi < 68)
{
digitalWrite(7,HIGH);
}
else
{
 digitalWrite(7,LOW); 
}

  // close any connection before send a new request.
  // This will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection:
  if (client.connect(server, <port>)) //change this
  {
//   Serial.println("connecting...");
    // send the HTTP PUT request:
    client.print("GET /?name=H2&code=1&temp=");client.print(tempF);client.print("&humitiy=");client.print(humi);client.println(" HTTP/1.1");   
    client.println("Host: www.website.com:<port>"); //change this
    client.println("User-Agent: ArduinoWiFi/1.1");
    client.println("Connection: close");
    client.println();
   
    // note the time that the connection was made:
    lastConnectionTime = millis();
  }
  else {
    // if you couldn't make a connection:
 // Serial.println("connection failed");
      digitalWrite(6,HIGH);
      delay(200);
      digitalWrite(6,LOW);
      delay(200);
      digitalWrite(6,HIGH);
      delay(200);
      digitalWrite(6,LOW);
      delay(200);
      digitalWrite(6,HIGH);
      delay(200);
      digitalWrite(6,LOW);
      delay(200);
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Custom parts and enclosures

HTU21D-F Temperature + Humidity Sensor
Best Sensor for your humidor
Sensors schem

Comments

Similar projects you might like

IoT for coins

Project tutorial by Erik Moran

  • 8,373 views
  • 1 comment
  • 42 respects

GPS Datalogger, Spatial Analysis, and Azure IoT Hub.

Project tutorial by Shawn Cruise

  • 18,275 views
  • 4 comments
  • 70 respects

Modular Smart-Home IoT Node

Project showcase by Team id-IOT

  • 5,060 views
  • 2 comments
  • 23 respects

MKR1000 Temp and Humidity Sensor

Project tutorial by Don Coleman

  • 18,136 views
  • 11 comments
  • 31 respects

Arduino Environmental Monitoring

Project showcase by Prajay Basu

  • 14,510 views
  • 1 comment
  • 28 respects

PlantAnalyzer

Project in progress by Ryan Michaud

  • 8,439 views
  • 3 comments
  • 33 respects
Add projectSign up / Login