My second proof of concept application for the Mikrobus.Net Quail and EthClick uploads temperature and humidity data to Xively every 30 seconds for display and analysis.
The Xively REST API uses an HTTP PUT which initially didn’t work because the payload was not getting attached.
I patched the AssembleRequest method in the EtherClick driver to fix this issue.
private byte[] AssembleRequest() { var a = RequestType; a += " " + Path + " " + Protocol + "\r\nHost: "; a += Host + "\r\n"; foreach (object aHeader in Headers.Keys) a += (string)aHeader + ": " + (string)Headers[aHeader] + "\r\n"; a += "\r\n"; // Cache-Control: no-cache\r\n //Accept-Charset: utf-8;\r\n if (Content != null && Content != string.Empty && (RequestType == "POST" || RequestType == "PUT")) a += Content; return Encoding.UTF8.GetBytes(a); }
The code reads the WeatherClick temperature and humidity values then assembles a CSV payload which it uploads with an HTTP PUT
</pre> public class Program { private const string xivelyHost = @"api.xively.com"; private const string xivelyApiKey = @"YourAPIKey"; private const string xivelyFeedId = @"YourFeedID"; public static void Main() { WeatherClick weatherClick = new WeatherClick(Hardware.SocketOne, WeatherClick.I2CAddresses.Address0); weatherClick.SetRecommendedMode(WeatherClick.RecommendedModes.WeatherMonitoring); EthClick ethClick = new EthClick(Hardware.SocketTwo); ethClick.Start(ethClick.GenerateUniqueMacAddress("devMobileSoftware"), "QuailDevice"); // Wait for an internet connection while (true) { if (ethClick.ConnectedToInternet) { Debug.Print("Connected to Internet"); break; } Debug.Print("Waiting on Internet connection"); } while (true) { Debug.Print("T " + weatherClick.ReadTemperature().ToString("F1") + " H " + weatherClick.ReadHumidity().ToString("F1") + " P " + weatherClick.ReadPressure(PressureCompensationModes.Uncompensated).ToString("F1")); HttpRequest request = new HttpRequest(@"http://" + xivelyHost + @"/v2/feeds/" + xivelyFeedId + @".csv"); request.Host = xivelyHost; request.RequestType = "PUT"; request.Headers.Add("Content-Type", "text/csv"); request.Headers.Add("X-ApiKey", xivelyApiKey ); request.Content = "OfficeT," + weatherClick.ReadTemperature().ToString("F1") + "\r\n" + "OfficeH," + weatherClick.ReadHumidity().ToString("F1") ; request.Headers.Add("Content-Length", request.Content.Length.ToString()); var response = request.Send(); if (response != null) { Debug.Print("Response: " + response.Message); } else { Debug.Print("No response"); } Thread.Sleep(30000); } } }

MikrobustNet Quail with Eth and Weather Clicks
This proof of concept code appears to be reliable and has run for days at a time. The IP stack looks like it needs a bit more work.