IoT Maker Den migrated and implemented on Mono .NET on Raspberry Pi 2
Documentation in progress
Please refer to the IoT Maker Den on .NET Micro Framework on Netduino documentaion
This project can run with or without the configured prototype shield. See the code examples below for running barebones or with a fully configured Maker Den prototype shield.
#Setting up Mono on Raspberry Pi
More to come, but for now refer to this excellent article of setting up Mono on your Raspberry Pi.Getting started with the Raspberry Pi 2, for .NET developers
The Internet of Things Solution Accelerator for the .NET Micro Framework provides a pluggable foundation to support sensors, actuators, data serialisation, communications, and command and control.
- Sensors
- Physical: Light, Sound, Temperature, CPU Temperature
- Virtual: Memory Usage, Diagnostics
- Sensor data serialised to a JSON schema
- Actuators
- LED, Relay
- Adafruit Mini 0.8" 8x8 LED Matrix
- Low and high level pixel frame transformation primitives
- alphanumeric character and symbol drawing and scrolling capability
- Command and Control
- Control relays, send messages to a Adafruit Mini 8x8 Matrix etc via the communications layer
- Communications
- Pluggable – currently implemented on MQTT (Mosquitto MQTT Server running on Azure)
- Supported and Tested
- Raspberry Pi 2 and B+
- Visual Studio 2013 Community Edition, Express Desktop, Std, Pro and above
- Targets .NET 4.5 on Mono .NET on Raspberry Pi
The IoT Dashboard allows you to visualise the data streamed to Azure.
You can install the IoT Dashboard from here. Note, you will need to allow to run from unknown publisher.
#Prototype Board Layout
##Wiring and Component Layout
Click the image to see Maker Den on Raspberry Pi in Action. The Raspberry Pi 2 on the right, Netduino 2 Plus on the left.
Watch Maker Den on Raspberry Pi in action on YouTube
All parts are generally available worldwide. This is a peliminary parts list with links to sites where I purchased the parts for the Maker Den on Mono (.NET) on Raspberry Pi 2 (also supports Raspberry Pi B+). The links are for your reference only and in no way are these sites affiliated with Microsoft.
- Raspberry Pi 2
- MCP3002-I/P, 10 bit ADC Differential - 2 x ADC Channels
- MCP9701A-E/TO, 8 bit Analogue Temperature Sensor
- Light Dependent Resistor
- Prototyping Shield for Raspberry Pi Model B+
- Breadboard Mini Self-Adhesive
- Rubber Feet - Small Stick On - Pk.4 (or a case)
- Adafruit Mini 0.8" 8x8 LED Matrix
- 1 x 22k ohm resistor for Light Dependent Resistor
- 1 x 200 ohm resistor for the LED
Optional
Connect Ethernet port to router/internet.
This example does the following
-
Start network services and posts sensor data via MQTT to IoT Dashboard
-
Loads Sys for remote shutdown and reboot via MQTT,
-
Reports CPU Temperature,
-
Reports .NET Working set memory.
using Glovebox.Adafruit.Mini8x8Matrix; using Glovebox.RaspberryPi.IO.Actuators; using Glovebox.RaspberryPi.IO.Sensors; using Raspberry.IO.GeneralPurpose; using System.Threading; namespace MakerDenMono { class MainClass : MakerBaseIoT { public static void Main(string[] args) { InitializeDrivers(); StartNetworkServices("mono", true); using (Sys sys = new Sys("rpi")) using (SensorCPUTemp cpuTemp = new SensorCPUTemp(10000, "cpu01")) using (SensorMemory mem = new SensorMemory(2000, "mem01")) { cpuTemp.OnBeforeMeasurement += OnBeforeMeasure; cpuTemp.OnAfterMeasurement += OnMeasureCompleted; mem.OnBeforeMeasurement += OnBeforeMeasure; mem.OnAfterMeasurement += OnMeasureCompleted; Thread.Sleep(Timeout.Infinite); } } } }
Connect Ethernet port to router/internet.
This example does the following
-
Start network services and posts sensor data via MQTT to IoT Dashboard
-
Loads Sys for remote shutdown and reboot via MQTT,
-
Reports CPU Temperature,
-
Reports .NET Working set memory.
-
Blinks LED for every sensor measurement
-
Relay support with remote on/off via MQTT
-
Adafruit Mini LED 8x8 Matrix running test pattern
-
LDR based light level sensor
-
Temperature sensor
using Glovebox.Adafruit.Mini8x8Matrix; using Glovebox.RaspberryPi.IO.Actuators; using Glovebox.RaspberryPi.IO.Sensors; using Raspberry.IO.GeneralPurpose; using System.Threading; namespace MakerDenMono { class MainClass : MakerBaseIoT { public static void Main(string[] args) { InitializeDrivers(); StartNetworkServices("mono", true); using (Sys sys = new Sys("system")) using (SensorCPUTemp cpuTemp = new SensorCPUTemp(10000, "cpu01")) using (SensorMemory mem = new SensorMemory(2000, "mem01")) using (led = new LedDigital(gpioDriver, ProcessorPin.Pin13, "led01")) using (Relay relay = new Relay(gpioDriver, ProcessorPin.Pin06, "relay01")) using (AdaFruitMatrixRun matrix = new AdaFruitMatrixRun(i2cDriver.Connect(0x70), "matrix01")) using (SensorLight light = new SensorLight(spiConnection, 1000, "light01")) using (SensorMcp9701a tempMcp9701a = new SensorMcp9701a(spiConnection, 15000, "temp02")) { cpuTemp.OnBeforeMeasurement += OnBeforeMeasure; cpuTemp.OnAfterMeasurement += OnMeasureCompleted; mem.OnBeforeMeasurement += OnBeforeMeasure; mem.OnAfterMeasurement += OnMeasureCompleted; light.OnBeforeMeasurement += OnBeforeMeasure; light.OnAfterMeasurement += OnMeasureCompleted; tempMcp9701a.OnBeforeMeasurement += OnBeforeMeasure; tempMcp9701a.OnAfterMeasurement += OnMeasureCompleted; Thread.Sleep(Timeout.Infinite); } } } }
