Hans on IoT

ThingSpeak, MATLAB, and the Internet of Things

Tracking Office Temperature with FEZ Cobra (user project) 4

Posted by Hans Scharler,

[foxxjnm] tracks his office temperature with ThingSpeak. He had a temperature probe and a FEZ Cobra development board lying around, so he decided to connect them to the ThingSpeak API.

I have been playing around with the ThingSpeak API a little this week. I decided to get my FEZ Cobra reporting temperature data from my office at work. Why a temperature sensor you ask?… Because I had one laying around.. That was good enough for me, guess I’m simple like that.

FEZ Cobra Connected to ThingSpeak

[via codefox blog]

4 CommentsOldest to Newest

Stefaan Vandevelde replied on : 1 of 4
I'd like do do something similar on the FEZ Cobra. Would you share the code of the office temperature project ? (I'm only interested in the part that talks to ThingSpeak)
foxxjnm replied on : 2 of 4
The part that talks to TS is very simple: if (lastUpdate.Ticks < DateTime.Now.Subtract(new TimeSpan(0, 0, 300)).Ticks) { using (HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://api.thingspeak.com/update?key="+APIKey+"&field1=" + t.GetTemperatureFahrenheit().ToString())) { using (HttpWebResponse res = (HttpWebResponse)req.GetResponse()) { using (StreamReader sr = new StreamReader(res.GetResponseStream())) { response = sr.ReadToEnd(); if (response != "") { lastUpdate = DateTime.Now; } } } } } If you need more than this, or any explanation, please feel free to let me know.