Send data do Cloud (IotHub) - c#

I need to send this data below to the cloud, I've tried to mix it with a code in IoT Hub called SimulatedDevice, but I Always have some errors.
if (reading.IsValid)
{
this.TotalSuccess++;
this.Temperature = Convert.ToSingle(reading.Temperature);
this.Humidity = Convert.ToSingle(reading.Humidity);
this.LastUpdated = DateTimeOffset.Now;
this.OnPropertyChanged(nameof(SuccessRate));
// this.WriteData();
}
To do that, I've to mix the code above with this code here: IoT-hub C#: get started from azure.microsoft.com.
In my case I've to send temperature an humidity, someone could help? To send this information to the cloud? How could I mix these both.

I'm supposing you're running your app on windows IoT devices(like raspberry pi), so you need to develop UWP app, the reference you provide is for console app, which does not run on windows IoT devices.
There's an nice VS extension called Connected Service for Azure IoT Hub, as below,
After you install it, you can "connect to Azure IoT" Hub in the "Add Connected Service" pop up, all the necessary references will be automatically added, and an AzureIoTHub.cs file is created too.
Note you'll need to add "Windows IoT Extension for the UWP" extension to you project otherwise you'll run into error.
After you are done, you can update the data to your Azure IoT Hub. I have verified it on my raspberry pi 2 with IoT Core 14393.
Alternatively, there's an UWP sample app from azure-iot-sdk github repo, note that you'll need to reference "Windows.Azure.Devices.Client" instead of "Windows.Azure.Devices.Client.WinRT". It also works with my rapberry pi 2.

Related

How to Use Azure Notification Hub without updating IOS Application

I am working in Azure notification hub, and the notifications send to the IOS applications. Following ,
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-ios-apple-push-notification-apns-get-started
But the problem is my IOS application currently using about 1000 users. So the users do not want update his app. The question is - any option to implement Azure notification hub in IOS application without updating the App.? In my hand device Id stored in DB. And also I have certificates.
I think write a console application and add all device id to azure notification hub. Is it possible?
Per my experience, it seems to be not possible to migrate from APNS to Azure Notification Hub for your iOS app without any code changes, because you must have to add the Nofication Hub ListenSharedAccess connect string into your app project. Actually, the architecture migration for your app is from Fig 1 to Fig 2, as below, it will cause necessary code changes. Unless there is some mechanism of hot-patching in your app, but it was not allowed by Apple.
Fig 1.
Fig 2.
Yes, you can register all your existing device tokens with the Notification Hub using the API of your choice. Then have your app back-end register new tokens with the notification hub as they come in.

Suitable Device management for use with Azure resource

I am developing an Web App. Its main functionality is
to provide options to get data from different devices and
display them on Dashboard
My Current Flow
When it was started
A device will be sending data
This data from the device will to be placed in Azure Table Storage.
As and when the data gets into Azure the latest received data will be flashing (displayed) in my web app Dashboard.
The app is now getting bigger
we are expecting to get data from more than one device
each device may have same\different parameters & values to send to the Azure
So management of the parameters corresponding to each device too needs to be handled
For all this, its required to make the app manage the devices- like
registering new device,
allow edit\delete of the devices
maintaining the device related parameters
...
...
My Query
In this scenario would the device with IoT Hub serve my cause?
Or Should I make my web app only to manage (add\edit\del..) devices
Or is there any better option in Azure to manage device that send data to be placed on the Azure resource?
Please share your thoughts.
In this scenario would the device with IoT Hub serve my cause?
Device management with IoT Hub can serve you cause. Please refer to Overview of device management with IoT Hub, in this article there is introduction about Azure IoT Hub.
Or Should I make my web app only to manage (add\edit\del..) devices
Or is there any better option in Azure to manage device that send data to be placed on the Azure resource?
The repository of Microsoft Azure IoT SDK for .NET contains IoT service SDKs, you can use this SDK in you web app to manage the devices.The basic features of the tool DeviceExplorer in this repository are similar with your requirements, such as device management, receiving message from devices, sending data to devices by call method on devices. Even though, this tool is a desktop application, you can try to transplant the features in web app.

IoT share file between apps

I'm doing my first steps on Microsoft IoT on a Raspberry pi 3.
I was able to deploy and run the application.
However, I need to run two application, one is going to write a file with events, and the other is going to pick up the batch and send it to Azure.
I was wondering what file location/ path should I use, as the App path changes with every new build.
Should I develop as a single app instead?
Kind Regards,
Juan
Not sure if it fits your scenario, but sounds like the purpose of a second app is to pick up some parameters and send to Azure. So, maybe it's time to consider using App Service.
In general, App service is a background task that runs in the backgound, with on-time event triggers. You can pass in parameters when your app triggers the service, and gets return data when necessary.
If hope it helps.

How to use Notification Hub on UWP?

Why cannot I install Microsoft Azure Notification Hub library and (or) Microsoft Azure Service Bus through NuGet into Universal Windows app project? In Windows 8.1/Phone 8.1 apps all works perfectly, not like in Windows 10.
As of July 2016 Notification Hubs SDK is not available for UWP. The product team is aware of it and working on providing it.
At the moment, there are two ways to workaround it:
Use WindowsAzure.Messaging.Managed Nuget package as described in Getting started with Notification Hubs for Windows Universal Platform Apps
Use REST API.
#quillaur, certain Hubs SDKs are open sourced. But, unfortunately, not Windows ones at the moment.
What do you mean that notification
I'm not ready to know you want to do and
I know that you can use ms cloud to push info
[DataContract]
public clas OAuthToken
{
[DataMember(Name="access_token")]
public string AccessToken{set;get;}
[DataMember(Name="token_type)]
public string TokenType{set;get;}
}
And win10 UWP may download the library in GitHub but I can't find it now.

Push Notification working only on one device (android)

I am developing for android on Xamarin (c#), I followed this guide to setup a notification system with Microsoft azure :
http://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-notification-hubs-android-get-started/#register
The thing is that then I tested on both of my devices only one received the notification, and for some reason on the azure hub server I see only one registered device, I thought maybe be there is a problem with my other phone and even tried to install the application on my friend phone and it didn't work either .
I will not post any code here because its exactly like in the guide I posted just with my information (google id, and hub name and so on..)
The first phone (on this one the notification works) is running version 4.2.2, and having a root premonitions if it make any difference.
The second phone (not working) is running version 4.4.2.
Any ideas or suggestions ? Thank's in advance.

Categories

Resources