Giter VIP home page Giter VIP logo

connectthedots's Introduction

- THIS PROJECT IS DEPRECATED AND NO LONGER UNDER ACTIVE MAINTENANCE

ConnectTheDots.io is an open source project created by Microsoft to help you get tiny devices connected to Microsoft Azure IoT and to implement great IoT solutions taking advantage of Microsoft Azure advanced analytic services such as Azure Stream Analytics and Azure Machine Learning.

The project is built with the assumption that the sensors get the raw data and format it into a JSON string. That string is then sent to Azure IoT Hub, from which a Web app gathers the data and displays it as a chart. Optional other functions of the Azure cloud include detecting and displaying alerts and averages, however this is not required.

The JSON string is sent to Azure IoT Hub whether directly by the sensor device if it is capable of connecting to Azure IoT Hub or through a multi-protocol Gateway, which is how the Getting Started with Pi and Arduino sample does it. More details on each of those options are below.

In this project there are code samples, configuration scripts and guides that will help you set up devices and sensors, and configure Microsoft Azure services to view and analyze the data produced by those devices. Some of these samples have been provided by Microsoft, others by third parties; we encourage everyone to submit code samples or configuration documentation to grow this project.

This project contains several device samples all aimed at helping you connect your devices to Azure IoT, as well as visualize and gain insight from your data. Check out all the samples below, or follow the getting started walkthrough to learn more. Then, add some of your devices to the project!

We encourage the community to contribute to the project! See Contribute page for details.

What's new in the V2?

Plenty! The main change is the use of Azure IoT Hub instead of Event Hubs for connecting devices to the Cloud, but here is a list of what's new in V2

  • Migrated from Event Hubs to Azure IoT Hub for the devices connectivity to Azure IoT: IoT Hub offers a better security with a per device authentication, along with a bidirectional messaging infrastructure.
  • Replaced the Azure Prep tool with an ARM Template: you can now deploy the whole solution (including the WebSite) from a command line not only on Windows, but also no a Mac or a Linux machine!
  • Updated devices samples
    • Updated all the node.js samples to use the Azure IoT Hub SDK
    • Removed old devices samples (Galileo, .Net Micro Framework)
    • Updated the Gateway code to use Azure IoT Hub device SDK
    • Upgraded WP8 samples (Simulated Sensors and MS Band) to Windows 10 UWP apps
    • Added Xamarin samples
    • Added a sample for ESP8266 chips

Where is the V1 if I still want to use the old fashion way (using Event Hub)?

The V1 has been tagged and you can find the release as a binary here We also created a branch that we will not make additions to any more but will definitively track to merge your contributions.

Device basics

Data format

ConnectTheDots is built on the assumption that data from sensors is sent to Azure IoT Hub in a prescribed JSON format. The minimum structure, with required attribute names, is

{
    "guid":	"string",
    "organization":	"string",
    "displayname": "string",
    "location": "string",
    "measurename": "string",
    "unitofmeasure": "string",
    "timecreated": "string",
    "value": double/float/integer
}

This should all be sent as one string message to IoT Hub, for example as the following strings:

{"guid":"62X74059-A444-4797-8A7E-526C3EF9D64B","organization":"My Org Name","displayname":"Sensor Name","location":"Sensor Location","measurename":"Temperature","unitofmeasure":"F","timecreated":"1975-09-16T12:00:00Z", "value":74}

or

{"guid":"62X74059-A444-4797-8A7E-526C3EF9D64B","organization":"my org name","displayname":"sensor name","location":"sensor location","measurename":"Temperature","unitofmeasure":"F","timecreated":"1975-09-16T12:00:00Z", "value":74.0001}

Furthermore, the project is built upon the assumption that the sensors create and format this JSON string. For example, if using a sensor attached to an Arduino, the code running on the Arduino would send successive JSON strings, CRLF ended, out the serial port to a gateway such as a Raspberry Pi or Windows Tablet. The gateway does nothing other than receive the JSON string, package that into the right message format, adds the timecreated time stamp, and send it to Azure.

In the case of a directly connected device, the latest needs to send the JSON package to the IoT Hub leveraging one of the existing Azure IoT Hub device client SDKs.

All the device code included in this project, or submitted for inclusion, must conform to the JSON format requirement above.

Devices and Gateway

ConnectTheDots provides a Multi-protocol Gateway to collect data from devices that cannot, or should not, target the cloud directly. The Gateway code is tested on Mono for Linux and on the .NET Framework on Windows and is located in the source tree under Devices/Gateways/GatewayService, and is a simple system service.

To send data from a device to a gateway, you can just use the same exact data format and a device protocol adapter to implement any transport of your choice. The device protocol adapter is an assembly that implements the DeviceAdapterAbstract type to collect data from the device and enqueue them to the gateway for upload to the cloud. The Gateway automatically loads the device adapters from the Gateway binary directory, so deployment is extremely simple. You can find some examples under Devices/Gateways/GatewayService/DeviceAdapters, and the matching devices under Devices/GatewayConnectedDevices.

We even have some devices running in separate processes as a Python script, sending data to an adapter Gateway on a socket or a serial port connection. It does not get any easier than that!

Software prerequisites

In order to reproduce one of the ConnectTheDots.io scenarios, you will need the following:

  1. Microsoft Azure subscription (free trial subscription is sufficient)
  2. [optional] Visual Studio 2013 or above – Community Edition is sufficient. Note that if you are not planning to use the Gateway nor making changes to the dashboard, you will NOT need Visual Studio.
  3. [optional] WiX Toolset - if you want to build installer of Gateway for Windows

Getting Started

To get started with ConnectTheDots, you will need to go through the following basic steps:

  1. Deploying services: this is easily done using the automated deployment script.
  2. Setup devices: follow these instructions to provision devices in the IoT Hub and modify and deploy code sample

Available Devices

For a full list of devices and code samples check out the ever growing list of supported gateways and sensors.

connectthedots's People

Contributors

agentrx avatar anthonyngu avatar bretstateham avatar brianmanden avatar dinarisio avatar f2bo avatar ivanignatiev avatar ivorjberry avatar jepickett avatar jmservera avatar lt72 avatar manimaranm7 avatar markushorstmann avatar networkfusion avatar next-marianmoldovan avatar noopkat avatar olivierbloch avatar punitganshani avatar robotdad avatar scruffyfurn avatar spyrossak avatar toolboc avatar vladimirtsyshnatiy avatar ytechie avatar zachrperkel avatar zingpow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connectthedots's Issues

Event Alerts Webpage problem

Hi, today I try this project sample, it work fine.

But I notice WebPage won't receive alerts from EventHubs,

Aggregates always have output envets to EHAlerts
1

LightSensor and Alerts receive data from EHDevices but won't output anythings to EHAlerts
2

but ehalerts still recive some data?... but won't show on webpage.
3

here is ehdvices
4

i also adjust some query string to fit my sensors.(either alerts)
5

I check every step, but can't find why..

and when i create StreamingAnalytics, add output, it alias can't change, it is gray.
6

So alerts, lightsensor, aggregates these 3 stream analytics output name all call "output"

Remove handcoded paths from project

<add name="SerialPortSensor" 
     type="SerialPortListener.SerialPortListenerThread" 
     assemblyPath="..\..\SLAC\connectthedots1\Devices\Gateways\GatewayService\DataIntakes\SerialPortListener\bin\Debug\SerialPortListener.dll"/>

Suggestion: Script to clean up Azure resources from CTD

I've run the ConnectTheDots demo app a couple of times now, once for a user group, and again for an online conference.

While it's a great demo for showing end-to-end IoT communication, there's a lot involved in cleaning up the Azure resources used by the demo, and it would be great if this could be automated to some degree.
Perhaps it would be possible to have the app that performs a substantial portion of the setup also create a powershell script that could use the Azure command line APIs to remove the Service Bus and Storage resources it creates.

If I can find the time to go through the code and try my hand at hacking it together, and if I manage to make something that works, I'll submit it as a pull request.

After a task is popped from the gateway queue, we discard it if we fail to process it

After a task is popped from the gateway queue, we discard it if we fail to process it

// process all messages that have not been processed yet
while (--count >= 0)
{
var t = _DataSource.TryPop(); <<<<<<<<<<<<<<< HERE

                        Debug.Assert( _outstandingTasks >= 0 ); 

                        bool added = false;
                        try
                        {
                            // increment outstanding task count but be ready to decrement if we fail to add to the queue
                            Interlocked.Increment( ref _outstandingTasks );

                            Debug.Assert( tasks != null );

                            tasks.Add(
                                t.ContinueWith<Task>( popped =>
                                {
                                    Interlocked.Decrement( ref _outstandingTasks );

                                    // because the outstanding task counter is incremented before 
                                    // adding, we should never incur a negative count 
                                    Debug.Assert( _outstandingTasks >= 0 );

                                    if( popped.Result.IsSuccess )
                                    {
                                        if( _DataTransform != null )
                                        {
                                            return _DataTarget.SendMessage( _DataTransform( popped.Result.Result ) );
                                        }
                                        if( _SerializedData != null )
                                        {
                                            return _DataTarget.SendSerialized( _SerializedData( popped.Result.Result ) );
                                        }
                                    }
                                    else
                                    {
                                        throw new Exception( );
                                    }
                                    return popped;
                                } )
                            );

                            // the only case when we do not get here is if List.Add fails (tasks.Add) or
                            // if the task engine fails Task.ContinueWith (t.ContinueWith)
                            added = true;
                        }
                        catch
                        {
                            if( !added )
                            {
                                Interlocked.Decrement( ref _outstandingTasks );   
                            }

                            //
                            // TODO: Issue 
                            //
                            throw;
                        }
                    }

'truly' crosss platform API (was: Send Data API Format)

Hi there
Is someone is able to show a example of sending data to the hub with a more "generic" way; IE not using mono or any other layer.

For example posting data to the hub just using curl or a browser URL ?

Thanks for your help

Fix rc.local

autorun_once.sh not being launched by rc.local

Publishsettings file will be deleted on a clean build

Currently ConnectTheDotsCloudDeploy looks for the publish settings in the same directory as the .exe. This means that if the developer does a clean build the file will be deleted.

We need to look in a more sensible location.

Validate JSON ASAP

we need to validate incoming JSON sooner rather than later for efficiency and ability to log error where they make sense

Change name of RaspberryPiGateway to Gateway?

There is nothing specific, other than startup scripts, to the RaspberryPi within the Gateway. In fact during testing it is easier to use a Windows machine. Some folks might even prefer to use a Windows machine as the gateway.

For example, I have a Dell Windows 8 Tablet as a controller for my Hue lights in some of my rooms. Rather than install a Pi in these rooms I'd rather use the existing tablet as the Gateway.

It therefore seems to make sense to separate out the startup scripts from the Gateway code. THis would give us both a "RaspberryPiGateway" and a "Gateway" artifact.

Thoughts?

Unable to create azure resources for event hub

I tried to create azure resources as
cd ConnectTheDots\Azure\CloudDeploy\ConnecTheDotsCloudDeploy\bin\debug
ConnectTheDotsCloudDeploy.exe –n -ps

but when I run this command I am getting this error

Error:unrecognized argument: -n
Usage :ConnecttheDotsCloudDeploy -publishSettingFile [-NamePrefix ] [-Location ] [-website ]

Errors in deploying to Intel Galileo

I tried to deploy the sample application given for Intel Galileo but it is giving runtime errors. Has someone worked with Galileo?
I am getting the following errors

'ConnectTheDotsGalileo.exe' (Win32): Loaded 'C:\test\ConnectTheDotsGalileo.exe'. Symbols loaded.
'ConnectTheDotsGalileo.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
'ConnectTheDotsGalileo.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.
'ConnectTheDotsGalileo.exe' (Win32): Loaded 'C:\Windows\System32\kernel32legacy.dll'. Cannot find or open the PDB file.
'ConnectTheDotsGalileo.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file.
The program '[1924] ConnectTheDotsGalileo.exe' has exited with code -1073741515 (0xc0000135) 'A dependent dll was not found'.

Break main Connect The Dots into several ones

To allow for additional devices, Cloud services and scenarios to be added, we need to break the main solution into several ones. One for the Raspberry Pi + Arduino code, one for the Cloud Deploy tool, one for the Web site.
The Wiki will have to be adapted as well and the Step-by-Step document broke into several pages.
Once we have this in place, it will be easier to add devices, and then add services and scenarios.

AzurePrep: Check service name validity

ConnectTheDotsCloudDeploy requires that a name be submitted. This name has fairly stringent constraingts. Test for them before starting to create the service otherwise we get a partially complete service:

We need to check for (at least):

  • only letters and numbers – no spaces, dashes, underlines, etc
  • less than 17 characters (storage account names must be < 24 characters and we add "storage" to the end)

User specific config stored in autorun.sh

The user is currently instructed to manually configure autorun.sh which means the file cannot be reliably shared in version control without breaking other peoples builds.

This configuration needs to be moved to a properties file.

Invalid URI: The hostname could not be parsed.

servererror

Hello!

Today I started to follow the step by step guide to build the connect the dots project. While publishing the Connect The Dots website to my azure website the server returned an error. I enabled websockets in the Azure portal and already spent hours on this problem. I do not know what's wrong or how to fix this. If you need more information, please let me know.

Property or indexer 'Amqp.Message.Body' cannot be assigned to -- it is read only

Running the NETMF/Gadgeteer code (no changes) and I get this compilation error on the following line of code:
message.Body = new Data() { Binary = Encoding.UTF8.GetBytes(payload) };

Error:
Property or indexer 'Amqp.Message.Body' cannot be assigned to -- it is read only...

Here is the code block:
void SendAMQPMessage(string payload)
{
try
{
// 0 indicates the method is not in use
if (0 == Interlocked.Exchange(ref IsSendingMessage, 1))
{
// Create the AMQP message
var message = new Message();
message.Properties = new Properties()
{
Subject = "wthr",
CreationTime = DateTime.UtcNow,
ContentType = "text/json",
};

                message.MessageAnnotations = new MessageAnnotations();
                message.MessageAnnotations[new Symbol("x-opt-partition-key")] = DeviceID;
                message.ApplicationProperties = new ApplicationProperties();
                message.ApplicationProperties["time"] = message.Properties.CreationTime;
                message.ApplicationProperties["from"] = DeviceID;
                message.ApplicationProperties["dspl"] = DeviceName;
                //message.Properties.ContentType = "text/json";
                message.Body = new Data() { Binary = Encoding.UTF8.GetBytes(payload) };

                sender.Send(message);

                // release lock
                Interlocked.Exchange(ref IsSendingMessage, 0);
            }
        }
        catch (Exception e)
        {
            Debug.Print("Exception caught:" + e.Message);
        }
    }

Unable to view independent device streams when deploying ConnectTheDotsWebsite to Azure

It seems that when deploying ConnectTheDotsWebsite locally, I can view independent device streams as pictured below:

ScreenShot

However, when deploying ConnectTheDotsWebsite to Azure and enabling Web Sockets, the user only sees aggregate data from the ehalerts event hub. Selecting an independent device yields no data in the Temp / Humidity Graphs.

To reproduce, simply visit http://connectthedots.azurewebsites.net and select any of the available devices. Note that the only data displayed is the Average data from ehalerts.

DataIntakeLoader ctor does not check for various point of failures

for example, this code:

Assembly ass = Assembly.LoadFrom( e.AssemblyPath );
Type handlerType = ass.GetType( e.TypeName );

                    IDataIntake dataIntake = ( IDataIntake )Activator.CreateInstance( handlerType );

should check for null on the return types

(at the time I opened this bug, MSDN was down, so check may not be needed)

make all entries in JSON format lower case and no uderscores

current entries are inconsistent, please make all lower case and no under score

public class SensorDataContract
{
[DataMember(Name = "Value")]
public double Value { get; set; }

    [DataMember(Name = "GUID")]
    public int Guid { get; set; }

    [DataMember(Name = "Organization")]
    public string Organization { get; set; }

    [DataMember(Name = "DisplayName")]
    public string DisplayName { get; set; }

    [DataMember(Name = "UnitOfMeasure")]
    public string UnitOfMeasure { get; set; }

    [DataMember(Name = "MeasureName")]
    public string MeasureName { get; set; }

    [DataMember(Name = "Location")]
    public string Location { get; set; }

    [DataMember(Name = "time_created")]
    public DateTime Location { get; set; }

    [DataMember(Name = "time_arrived")]
    public DateTime Location { get; set; }

}

Alerts are not displayed on the web page.

It seems that the code to display alerts on the web page is missing. I could only see the table headers but nothing else.

Real Time Events

Time Device Alert Message
        </div>
    </div>

Can you help?
Thanks

web.config is modified by the application

Azure\ConnectTheDotsWebSite\web.config is modified by ConnectTheDotsCloudDeploy.exe Since this is a source file it should not be modified by the application itself.

We should move to having a template in source and saving the modified version in our local config for the application.

Device ID is set in autorun.sh

I'm only just starting to look at the gateway application and I'm not a C# developer so I may be missing something fundamental, but...

Program.cs generates Unique identifier for the device:

string deviceId = Guid.NewGuid().ToString ("N"); // Unique identifier for the device

However, this gets overwritten in autorun.sh:
-deviceid C8CA5B13-A550-4FF0-B823-46D8A2640880

It seems to me that autorun.sh should not set the device ID, otherwise every device in the network will have the same ID. I've verified that running without a DeviceID appears to work (on Windows and in a very limited test environment).

What are the implications of removing that switch from aytorun.sh, that is what is deviceID used for?

Server error while creating website

I created the website by following the same steps and published it but when running it I am getting the following error(The name I have given is "weatherstation")

Server Error in '/' Application.
EventHub names must conform to the following rules to be able to use it with EventProcessorHost: Must start with a letter or number, and can contain only letters, numbers, and the dash (-) character. Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names. All letters in a container name must be lowercase. Must be from 3 to 63 characters long.
Parameter name: leaseContainerName

[ArgumentException: EventHub names must conform to the following rules to be able to use it with EventProcessorHost: Must start with a letter or number, and can contain only letters, numbers, and the dash (-) character. Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names. All letters in a container name must be lowercase. Must be from 3 to 63 characters long.
Parameter name: leaseContainerName]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.