Inspiration

Tea.

What it does

Creates the perfect cup of tea just for you. Perfect temperature. Perfect ratio. Perfect balance.

How I built it

We used a MKR1000 with a temperature sensor and a pressure sensor, Laser cut a box (using Solidworks), attached a Lithium-ion battery so we could disconnect it from our laptop, and made an app (called Cuppa). We also used Thingspeak and a feature called a Read Channel feed: https://api.thingspeak.com/channels/927162/feeds.json?api_key=GO50C2CTS11LWLB0&results=2, which we used the app to parse the two pieces of data.

The code is posted below:

(hash)include (hash)include

char ssid[] = "Cuppa"; // your network SSID (name) char pass[] = "cuppatest"; // your network password

int status = WL_IDLE_STATUS;

// Initialize the Wifi client library WiFiClient client;

// ThingSpeak Settings char server[] = "api.thingspeak.com"; String writeAPIKey = "3MDUFKKV65MU3YMV"; int safeTemp = 250; unsigned long lastConnectionTime = 0; // track the last connection time const unsigned long postingInterval = 40L * 1000L; // post data every 40 seconds

//String combineValue; const int forceInPin = A1; const int tempInPin = A2; const int red = A3; const int green = A4; //float forceInit = analogRead(forceInPin); int forceValue = 0; int tempValue = 0;

void setup() {

pinMode(red, OUTPUT); pinMode(green, OUTPUT); Serial.begin(115200); // setup serial***

// attempt to connect to Wifi network while ( status != WL_CONNECTED) { Serial.println("Attempting to connect."); // Connect to WPA/WPA2 Wi-Fi network status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection
delay(10000);

} Serial.println("Wifi connected!"); }

void loop() { // if interval time has passed since the last connection, // then connect again and send data if (millis() - lastConnectionTime > postingInterval) { httpRequest(); Serial.println("Data sent."); }

int temp = analogRead(tempInPin); //Serial.println(temp); if (temp > safeTemp){ digitalWrite(red, HIGH); digitalWrite(green, LOW); } if (temp <= safeTemp){ digitalWrite(green, HIGH); digitalWrite(red, LOW); } }

void httpRequest() {

forceValue = analogRead(forceInPin); tempValue = analogRead(tempInPin);

tempValue = (tempValue - 125)*4.09; if(tempValue < 100){ tempValue = 100; } if(tempValue > 999){ tempValue = 999; }

Serial.println(forceValue); Serial.println(tempValue);

String data = String(String(forceValue, DEC) + String(tempValue, DEC));

//Serial.println(data1); //Serial.println(data2);

// create data string to send to ThingSpeak //String data1_string = String("field1=" + data1); //String data2_string = String(data2);

//String data = data1_string + data2_string; Serial.print("Combined data: "); Serial.println(data);

// close any connection before sending a new request client.stop();

//bool val1 = client.connect(server,80); //bool val2 = client.connect(server,80); //bool val3 = client.connect(server,80); // POST data to ThingSpeak if (client.connect(server,80)) { client.println("POST /update HTTP/1.1"); client.println("Host: api.thingspeak.com"); client.println("Connection: close"); client.println("User-Agent: ArduinoWiFi/1.1"); client.println("X-THINGSPEAKAPIKEY: "+writeAPIKey); client.println("Content-Type: application/x-www-form-urlencoded"); client.print("Content-Length: "); client.print(data.length()); client.print("\n\n"); client.print(data); Serial.println("We made it");

// note the last connection time
lastConnectionTime = millis();

} }

Challenges we ran into

We had lots of trouble working the Wifi on the MKR1000. For some reason, our code would only run on Matt's laptop (exact same copy-pasted code)

Accomplishments that I'm proud of

I am proud that eventually, we were able to get our product to work despite our troubles. I did not see many other teams creating an app, so I am proud of that.

What we learned

Most importantly, we learned how to troubleshoot. We spent hours searching through forums for solutions to our problems and spent hours in Detkin with multiple TAs. I think that was a valuable experience and shows how you should never postpone working on a project until the last day because you never know what you will run in to (not that we did.)

What's next for The Perfect Cuppa

Possibly add a servo to automatically take the teabag out.

Short Video

https://youtu.be/PuVMTHbVvOk

Built With

Share this project:
×

Updates