connectthedots - my galileo based weather station and first entry into iot

37
My Weather Station 15 Minutes of Learning on my First IoT Project [email protected] :: blogs.msdn.com/devfish :: @de

Upload: joe-healy

Post on 04-Aug-2015

163 views

Category:

Technology


0 download

TRANSCRIPT

My Weather Station15 Minutes of Learning on my First IoT Project

[email protected] :: blogs.msdn.com/devfish :: @devfish

My Weather Station15 Minutes – Yeah right! Never invite the vampire into your own house

[email protected] :: blogs.msdn.com/devfish :: @devfish

The Hardware

Galileo2

SparkFun Weather Shield

SparkFun Weather Shield

• Arduino shield • Barometric pressure, relative humidity, luminosity and temperature• Optional sensors such as wind speed, direction, rain gauge and GPS

for location, timing.

ConnectTheDots.io

• ConnectTheDots.io - open source project • Created by Microsoft Open Technologies • Get tiny devices connected to Microsoft Azure• Take advantage of Azure advanced analytic services such as Azure

Stream Analytics and Azure Machine Learning

ConnectTheDots.io

ConnectTheDots.io

• Code samples, configuration scripts and guides• Set up devices and sensors• Configure Microsoft Azure services to view and analyze the data • We encourage everyone to submit code samples or configuration

documentation

ConnectTheDots.io

• Connect The Dots starter solution" - build a simple temperature sensing network• Use commodity devices available locally or online - for example an

Arduino UNO board with a weather shield, connected to a Raspberry Pi sending data to an Azure website.

ConnectTheDots.io

Software Prerequisites

• Microsoft Azure subscription• Visual Studio 2013 – Community Edition or above

Azure Setup

• In my project we had a central hub for the various weather sensors to deploy to • Easy-peasy for me, but ya’ll will have to run your own• https://github.com/MSOpenTech/connectthedots/blob/master/

Azure/AzurePrep/AzurePrep.md

Create Azure resources for IoT infrastructure• Solution given to create event hubs for us. Build and run it.

ConnectTheDots\Azure\AzurePrep\AzurePrep.sln

Will create• Two Event Hubs, EHDevices and EHAlerts • or a single EHDevices • C reates four endpoints for AMQP comms

Azure – Save our Settings

Note the device connection strings displayed - you will need them later

• Service Bus management connection string (i.e. for use in Service Bus ExploEndpoint=sb://ctdtest1-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=zzzzzzz

• Device AMQP address strings (for Raspberry Pi/devices):amqps://D1:[email protected]://D2:[email protected]://D3:[email protected]://D4:[email protected]

Create web.config

• Nice helper for this

ConnecttheDots\Azure\AzurePrep\CreateWebConfig\bin\Release\CreateWebConfig.exe

• Gives you web.config you can pull into your project

Hardware prerequisites for Connect The Dots starter solutionDirectly connected devices:

• Intel Galileo running a C++ application and sending data from an Arduino compatible Weather Shield over AMQP• Intel Edison running a node.js application sending data from a TI SensorTag BLEn sensor kit over HTTP/REST• Gadgeteer device running a C# .Net Micro Framework application sending Gadgeteer sensors data over AMQP• Raspberry Pi 2 running Windows 10 IoT Core and a Universal Application sending dummy data over HTTP/REST• Windows Phone C# application sending the phone sensors (light and accelerometer) over HTTP/REST• Windows Phone C# application sending a data from a paired Microsoft Band (accelerometer, body temperature, heartbeat)over HTTP/REST

Gateways: • Raspberry Pi supporting several types of device connections (see below) and running a C# service on top of Mono, or .NET

Framework on Windows, sending data over AMQP.

Gateway connected devices (devices connecting to a gateway to send their data) • Arduino UNO with one or several of the following sensors

• Accelerometer Memsic2125• Temperature sensor DS18B20• Simple sound sensor• Sparkfun weather shield

• Arduino DUE with one or several of the following sensors: • Temperature sensor DS18B20

• Wensn Sound Level Meter connected to the Gateway over USB

Setup Tasks

• Clone or copy the projects to your machine• Azure prep - Creating basic Azure resources• Device setup - Configuring your device(s)• Sample website deployment - Publishing a generic sample website for

viewing the data

Devices connecting directly to Azure

• Devices powerful enough to support a secure IP connection

Galileo

Galileo Setup

• Links on website are all wrong• Navigate to http://ms-iot.github.io/content/ • Select appropriate board

Galileo Setup

• 16gig card required• Must clean format it to FAT32• Update firmware – see online docs• Download Intel Galileo - Windows Developer Program For IoT –

Windows Image (WIM) from links• Install to card

cd /d %USERPROFILE%\Downloadsapply-bootmedia.cmd -destination {YourSDCardDrive} -image {.wimFile downloaded above} -hostname mygalileo -password admin

Galileo Setup – Boot Windows

• Connect Ethernet cable to board and hub• Plug in {correct} power supply• MicroSD light turns on as it boots• Ethernet lights after boot show its alive

Galileo Setup – Telnet in

• Galileo watcher will show if G on network• “Telnet mygalileo” • User/pw = Administrator/admin• Shut it down before unplugging• shutdown /s /t 0

Visual Studio

• Pull down appropriate client from GitHub• Open in Visual Studio• Edit the appSettings used to

configure the AMQPS connection to Event Hub using the information received from setting up the Azure services using the ConnectTheDotsCloudDeploy tool

Main.cpp

• Uncomment for appropriate shield

// #define SIMULATEDATA// #define USEONBOARDSENSOR// #define USEGROVESTARTERKIT// #define USESPARKFUNWEATHERSHIELD

Run the Scenario

• Once you have setup the services, published the site, provisioned and connected your devices, you will see data coming up on your website at the URL you chose when deploying the site.• You should see average temperature measurements showing up in the

web browser every 20 seconds.• If you select “All”, you should see raw readings from the device coming

in every second. If the temperature exceeds 75 degrees (F), you should see an alert showing in the alerts table, once every 20 seconds while the temperature on any of the devices exceeds 75 degrees (F). If you cover the shield, you will see an alert telling you the light is turned off.

Happy Weather Station

Lessons Learned

Power Supply

• Read the docs• Pay attention to which supply you grab

Run on boot

• Option to make program ‘run on boot’• It would just hang. Init problem?• Instead, deploy, then telnet in• Start program manually via cmd prompt• Then just close telnet – don’t logout• Program will run happily

SD Card Can Be Too Big

• All I had was 60g card• 60g no good with FAT32• Formatting big SD cards

takes a while when you are changing the file system

Tlist + kill

• Want to stop a running app without rebooting• Tlist to see processes• Then “kill” the process

number

Ethernet requirement

• Pain the the butt• Need to have board on same network to make it work• “dev hub” is a good thing• “Ethernet adapter” for s3 is a good thing• Bought one of these for future play - IOGEAR Universal Ethernet to

Wi-Fi N Adapter for Home or Office GWU627

Resources

• https://github.com/MSOpenTech/connectthedots/• http://dfwiki.devfish.net/technology.Internet-of-Things.ashx• http://www.weatherforschools.me.uk/html/weatherboxes.html• Tampa Internet of Things Meetup - http://www.meetup.com/Tampa-

Bay-NET-Microframeworks-Developer-Group/

All done!

[email protected] :: blogs.msdn.com/devfish :: @devfish