O'Reilly logo

Getting Started with the Internet of Things by Cuno Pfister

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

VoltageMonitor

Example 11-1, supports GET requests for a measured variable resource. One resource is supported: an ASCII representation of the current value of the voltage produced by the attached potentiometer.

Example 11-1. VoltageMonitor

using Gsiot.Server;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

public class VoltageMonitor
{
    public static void Main()
    {
        // ground and power for the potentiometer
        var lowPort = new OutputPort(Pins.GPIO_PIN_A0, false);
        var highPort = new OutputPort(Pins.GPIO_PIN_A2, true);

        var voltageSensor = new AnalogSensor
        {
            InputPin = Pins.GPIO_PIN_A1,
            MinValue = 0.0,
            MaxValue = 3.3
        };

        var webServer = new HttpServer
        {
            RelayDomain = "gsiot-FFMQ-TTD5",
            RelaySecretKey =
                "o5fIIZS5tpD2A4Zp87CoKNUsSpIEJZrV5rNjpg89 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required