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

how to a read temperature from the web


  • Please log in to reply
No replies to this topic

#1 laik777

laik777

    Member

  • Members
  • PipPip
  • 12 posts

Posted 19 July 2011 - 02:35 PM

Hey
I am new here.
I would like to know how to read a temperature from the web.

This is my program to read the temperature and it s working well:

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace i2c_bus_temp
{
    public class Program
    {
       public static void Main()
       {
           byte[] buffer_read = new byte[2];
           byte[] buffer_write = new byte[1];


           I2CDevice.Configuration config = new I2CDevice.Configuration(0x48, 100); // naslov naprave v   hexa,binarno je1001000, zadnji trije določajo A2 A1 A0.
          I2CDevice RTC = new I2CDevice(config);

           buffer_write[0] = 0x00;

           I2CDevice.I2CReadTransaction tran_read = I2CDevice.CreateReadTransaction(buffer_read);
           I2CDevice.I2CWriteTransaction tran_write = I2CDevice.CreateWriteTransaction(buffer_write);


           while (true)
           {
               I2CDevice.I2CTransaction[] tran = new I2CDevice.I2CTransaction[] { tran_write };

               int data = RTC.Execute(tran, 100);

               Debug.Print("\nThe number of data transfered is: " + data.ToString());

               tran = new I2CDevice.I2CTransaction[] { tran_read };

               data = RTC.Execute(tran, 100);

               int tempH;
               int tempL;
               tempH = buffer_read[0]*8;  
               tempL = buffer_read[1]/32;
               Debug.Print("\nThe number of data transfered is: " + (tempH+tempL)/8.0 +" °C");
               Thread.Sleep(1000);
           }


       }

    }
}

I will be hapy if someone could connect my temperature to the web with using this program:

using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
using Blinq.Netduino.Web;

namespace ServerExample
{
    /// <summary>
    /// Example for using the Blinq.Netduino.Webserver class
    /// </summary>
    public class Program
    {

     
       static InputPort bb = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);

      
       static WebServer server = new WebServer(80);

       public static void Main()
       {
           bool buttonState = false;

          
           server.CommandReceived += new WebServer.CommandReceivedHandler(server_CommandReceived);
           
           server.AllowedCommands.Add(new WebCommand("button", 0));

         
           server.Start();

       }

      
       private static void server_CommandReceived(object source, WebCommandEventArgs e)
       {
           Debug.Print("Command received:" + e.Command.CommandString);
           switch (e.Command.CommandString)
           {
               
               case "button":
                   {
                      
                       e.ReturnString = "<html><body><p>Butoon je v stanju: " + !bb.Read() + "</p></body></hmtl>";
                       break;
                   }
           }
       }
    }
}


Thanks in advance:)

Edited by Stefan, 19 July 2011 - 02:59 PM.
Added [code] tags





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.