Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Temperature Logging

WiFi Temperature Module

  • Please log in to reply
3 replies to this topic

#1 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 09 May 2015 - 04:38 PM

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:

Attached File  Netduino3WithModules.jpg   132.68KB   11 downloads

 

Now that we have WiFi and SSL, let see if we can do some data logging:

Attached File  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) 

 

https://youtu.be/cTAChlRlbSo


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 May 2015 - 05:03 PM

Hi Nevyn,

Very cool; thanks for posting this!

I think that one of my favorite things...is how simple it was to get up and running--especially with an online, SSL-based datalogging service. :)

Chris

P.S. BTW, your STM8S blog has been a pretty invaluable resource as we have been working on the new GoBus 1.5 firmware for STM8S. Thank you so much for hacking, blogging and doing so much cool stuff with Netduino.

#3 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 09 May 2015 - 05:16 PM

Chris,

 

I've been waiting for the SSL implementation for a while and it's good to see that it's finally here and with WiFi.  The code was really simple to get going.

 

Glad you found the STM8S blog articles useful.  I keep meaning to finish it off by adding some articles on I2C and now I have the Netduino 3 I have the perfect excuse :)

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#4 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 10 May 2015 - 03:09 PM

For those interested in the code changes between the original DHT22 module and the one working in on the Netduino 3 you might want to head over here.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter






Also tagged with one or more of these keywords: WiFi, Temperature Module

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.