Skip to content

StephanieMak/IoT-Maker-Den-Windows-for-IoT

 
 

Repository files navigation

Internet of Things Maker Den on Windows 10 for IoT on Raspberry Pi 2

See the Wiki for more information.

##Software Requirements (as at May 2015)

  1. Windows 10 (build 10122) or above
  2. Visual Studio 2015 (Community Edition (free), Professional or above)

##Getting Started For information on setting up your Raspberry Pi 2 running Windows 10 for IoT and your development environment see http://ms-iot.github.io/content/GetStarted.htm.

##Acknowledgements

  1. The Component library was inspired by the Raspberry# IO .NET/Mono IO Library for Raspberry Pi project
  2. The MQTT Client Library for .Net and WinRT

##Hardware

###Barebones

  1. Raspberry Pi 2. With no sensors or Explorer HAT Pro attached the Raspberry Pi can publish memory usage data enough to get you started and publishing data:)

###Ideal Hardware This lab is built around the Explorer HAT Pro as it has a four channel ADC, capacitive touch pads, four coloured LEDs, two H-bridge motor drivers, 5V input and output.

  1. Raspberry Pi 2
  2. Explorer Pro HAT
  3. Light Dependent Resistor
  4. Analogue Temperature Sensor

###Optional Extras 5. Adafruit Mini 8x8 LED Matrix 6. Breakout Board for Electret Microphone

Explorer Pro HAT Notes:

  1. Explorer HAT uses an output driver chip called the ULN2003A, which contains a set of transistor pairs called a Darlington Array. It transforms the small logic signal of the Pi into something capable of driving much bigger loads, such as motors, steppers, lights and more.
  2. The 4 outputs on Explorer HAT can sink 5V, but not source. This means you need to connect your load to one of the 5V pins, and then to the output. When you turn the output on it will connect your circuit to ground, allowing current to flow and your load to turn on. This is the opposite of using a bare Pi GPIO pin, where you might connect to the pin and then to ground; keep this in mind!

#What is The Internet of Things Maker Den?

The Internet of Things Maker Den is designed to be an accessible hands on experience with hardware prototyping and building a Universal Windows App that you will deploy to a Raspberry Pi 2 running Windows 10 for IoT..

The goal of the lab is to learn something about wiring circuits (with plenty of guidance), deploying code and streaming your sensor data to Microsoft Azure.

The Maker Den is implemented on top of the Internet of Things Solutions Framework.

#What is the Internet of Things Solution Framework?

The Internet of Things Solution Framework for Windows 10 on IoT is a general purpose extensible pluggable foundation to support sensors, actuators, data serialisation, communications, and command and control.

Alt text

Extensible/pluggable framework supporting

  1. Sensors
  • Physical: Light, Temperature
  • Virtual: Memory Usage, Diagnostics
  • Sensor data serialised to a JSON schema
  1. Actuators
  • Led, Relay, Generalised Output Pin
  • Adafruit mini 8x8 LED Matrix on HT16K33 I2C Controller
    • Low and high level pixel frame transformation primitives
    • Alphanumeric character drawing and scrolling capability
  1. Converters
  1. Drivers

  2. Command and Control

  • Control relays etc via the communications layer
  1. Communications
  • Pluggable – currently implemented on MQTT (Mosquitto MQTT Server running on Azure)
  1. Supported and Tested
  • Windows 10 for IoT on Raspberry Pi 2
  • Supports Visual Studio 2015

IoT Dashboard

The IoT Dashboard allows you to visualise the data streamed to Azure.

IoT Dashboard

You can install the IoT Dashboard from here. Note, you will need to allow to run from unknown publisher.

##Creating your first applications

First App

The only requirement is an Internet connected Raspberry Pi 2 running Windows 10 for IoT

This example will publish data to Azure and the IoT Dashboard

  1. From Visual Studio 2015 open the MakerDen.cs file in the MakerDen Project
  2. Modify the DevId in the StartNetwork Services method
  3. Ensure your Raspberry Pi is internet connected
  4. Ensure Visual Studio set to deploy to your "Remote Machine"
  5. Click Start to compile, deploy and run your application on the Raspberry Pi
  6. Open the IoT Dashboard and your data will appear as a guage

MakerDen.cs

using Glovebox.Adafruit.Mini8x8Matrix;
using Glovebox.IO.Components;
using Glovebox.IO.Components.Actuators;
using Glovebox.IO.Components.Sensors;
using Glovebox.IoT;
using System.Threading;

namespace MakerDen
{
    public class MakerDen : IoTServices
    {        
        public MakerDen() : base(false) { } // if Explorer Hat installed set : base(true)

        public void Main()
        {
            // Replace "myPi2" with a unique 3 to 5 character identifier. Use your initials or something similar.  
            // This identifier will be visible on the IoT Dashboard
            StartNetworkServices("myPi2", "YourNetworkId");

            using (SensorMemory memory = new SensorMemory(5000, "mem01"))
            {
                memory.OnAfterMeasurement += OnAfterMeasurement;
                Util.Delay(Timeout.Infinite);
            }
        }  //  End of Main()
    }
}

###Blinky

Blinky is the "Hello, World!" of the Internet of Things World

This example assumes you have a Explorer Pro HAT

MakerDen.cs

using Glovebox.Adafruit.Mini8x8Matrix;
using Glovebox.IO.Components;
using Glovebox.IO.Components.Actuators;
using Glovebox.IO.Components.Sensors;
using Glovebox.IoT;
using System.Threading;

namespace MakerDen
{
    public class MakerDen : IoTServices
    {
        public InitMakerDen() : base(true) { } // if Explorer Hat installed set : base(true)

        public void Main()
        {
            using (Led red = ExplorerLedRed)
            {
                while (true)
                {
                    red.On();
                    Util.Delay(1000);
                    red.Off();
                    Util.Delay(1000);
                }
            }
        } // End of Main()
    }
}

Or wire up your own LED. Follow this wiring diagram

MakerDen.cs

using Glovebox.Adafruit.Mini8x8Matrix;
using Glovebox.IO.Components;
using Glovebox.IO.Components.Actuators;
using Glovebox.IO.Components.Sensors;
using Glovebox.IoT;
using System.Threading;

namespace MakerDen
{
    public class MakerDen : IoTServices
    {
        public InitMakerDen() : base(false) { } // if Explorer Hat installed set : base(true)
                  
        public void Main()
        {
            using (Led red = new Led(18, "led"))
            {
                while (true)
                {
                    red.On();
                    Util.Delay(1000);
                    red.Off();
                    Util.Delay(1000);
                }
            }
        } // End of Main()
    }
}

###Light sensor activated light

MakerDen.cs

using Glovebox.Adafruit.Mini8x8Matrix;
using Glovebox.IO.Components;
using Glovebox.IO.Components.Actuators;
using Glovebox.IO.Components.Sensors;
using Glovebox.IoT;
using System.Threading;

namespace MakerDen
{
    public class MakerDen : IoTServices
    {                
        public InitMakerDen() : base(true) { } // if Explorer Hat installed set : base(true)

        public void Main()
        {
            using (SensorLight light = new SensorLight(adc, Timeout.Infinite, "light01"))
            using (Led redLed = ExplorerLedRed)
            {
                while (true)
                {
                    if (light.Current < 70)
                    {
                        redLed.On();
                    }
                    else
                    {
                        redLed.Off();
                    }
                    Util.Delay(500);
                }
            }
        } // End of Main()
    }
}

###Ultimate

All singing dancing with Explorer Hat, Light and Temperature Sensors plus Adafruit Mini 8x8 LED Matrix that publishes data to Azure :)

MakerDen.cs

using Glovebox.Adafruit.Mini8x8Matrix;
using Glovebox.IO.Components;
using Glovebox.IO.Components.Actuators;
using Glovebox.IO.Components.Sensors;
using Glovebox.IoT;
using System.Threading;

namespace MakerDen
{
    public class MakerDen : IoTServices
    {        
        public InitMakerDen() : base(true) { } // if Explorer Hat installed set : base(true)

        public void Main()
        {
            // Replace "myPi2" with a unique 3 to 5 character identifier. Use your initials or something similar.  
            // This identifier will be visible on the IoT Dashboard
            StartNetworkServices("myPi2", "YourNetworkId");

            using (Relay relay = new Relay(ExplorerPins.Output.One, "relay01"))
            using (SensorTemp temp = new SensorTemp(adc, 4000, "temp01"))
            using (SensorLight light = new SensorLight(adc, 1000, "light01"))
            using (SensorMemory memory = new SensorMemory(5000, "mem01"))
            using (AdaFruitMatrixRun matrixRun = new AdaFruitMatrixRun("matrix01"))
            {
                //Enable data publishing
                temp.OnBeforeMeasurement += OnBeforeMeasure;
                temp.OnAfterMeasurement += OnAfterMeasurement;

                light.OnBeforeMeasurement += OnBeforeMeasure;
                light.OnAfterMeasurement += OnAfterMeasurement;

                memory.OnBeforeMeasurement += OnBeforeMeasure;
                memory.OnAfterMeasurement += OnAfterMeasurement;

                Util.Delay(Timeout.Infinite);
            }
        } //end of Main()
    }
}

See Lab code snippets for more examples

##Explorer Hat Layouts ###Layout One

####Required components 2. Explorer HAT Pro 3. Light Dependent Resistor 4. Analogue Temperature Sensor

Layout Image
Wiring Basic wiring
Components Explorer Hat Pro Layout (Basic)

###Layout Two ####Required components

  1. Explorer HAT Pro
  2. Light Dependent Resistor
  3. Analogue Temperature Sensor
  4. Adafruit Mini 8x8 LED Matrix
Layout Image
Wiring Just wiring
Components Explorer Hat Pro Layout (with Adafruit mini 8x8 matrix)

###Layout Three ####Required components

  1. Explorer HAT Pro
  2. Light Dependent Resistor
  3. Analogue Temperature Sensor
  4. Adafruit Mini 8x8 LED Matrix
  5. Breakout Board for Electret Microphone
Layout Image
Wiring Explorer Hat Pro Layout (with additional analog for sound sensor plus Adafruit mini 8x8 matrix)
Components Explorer Hat Pro Layout (with additional analog for sound sensor plus Adafruit mini 8x8 matrix)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%