Today Amazon delivered a bright new shiny blue box containing a Netduino 3 WiFi
First task, see if I can get the temperature and humidity module working with the board. Took a little while as I did not have any compiled binaries. Got there in the end though:
Netduino3WithModules.jpg 132.68KB 11 downloads
Now that we have WiFi and SSL, let see if we can do some data logging:
TemperatureData.jpg 72.36KB 7 downloads
The application was simple enough, let start with some initialisation:
RgbLed rgb = new RgbLed(); SevenSegmentDisplay display = new SevenSegmentDisplay(); DHT22 dht = new DHT22(); display.SetBrightness(0.5); display.SetValue("----"); // // Wait until we have an IP address. // while (IPAddress.GetDefaultLocalAddress() == IPAddress.Any) { Thread.Sleep(10); } display.ClearValue();
Now we can move on to the main loop. Here the temperature and humidity is read from the DHT22 sensor. First the temperature is displayed and the LED turns blue. Next the humidity is displayed and the LED turns green. Finally the temperature is put into a URL for Phant and the temperature is written to the web:
while (true) { dht.GetReadings(); // // Blue LED indicates temperature reading. // rgb.SetColor(0, 0, 128); display.SetValue((double) dht.Temperature, 1); Thread.Sleep(5000); // // Green LED indicates humidity reading. // rgb.SetColor(0, 128, 0); display.SetValue((double) dht.Humidity, 1); Thread.Sleep(5000); // // Send data to Sparkfun's Phant data logging service. // rgb.SetColor(128, 0, 0); string uri = "https://data.sparkfun.com/input/--- Public Key Here ---?Temperature=" + dht.Temperature.ToString(); using (var request = (HttpWebRequest) WebRequest.Create(uri)) { request.Headers.Add("Phant-Private-Key: --- Private Key Here ---"); using (var response = request.GetResponse()) { using (var stream = response.GetResponseStream()) using (var reader = new StreamReader(stream)) { string line = reader.ReadLine(); do { Debug.Print(line); line = reader.ReadLine(); } while (!reader.EndOfStream); } } } }
Compulsory unboxing along with the module working (skip to 1:20 if you want to see the board working)