Ewon TechForum
Providing technical solutions to technical requests


MQTT - eWON Flexy to Microsoft Azure (Self-signed certificate authentication)
simon Offline
eWON Support
#16
Hi Gaëtan,

Indeed, that's something weird with Azure. I have never managed (neither took the time :-( ) to read my data from the cloud. I heard the data can be viewed using specific SQL queries.
On my side, I see the messages on the Device Explorer tool. Have you tried from a different Internet connection ? or from a different PC ?

If someone else could give us a procedure, it would be very cool ;-)

Simon
Reply

gaetan.baert Offline
Junior Member
#17
Hello Simon,


I got it working based on this article:
http://thinglabs.io/labs/edison/grove/visualize/

I created an Event Hub followed by a Stream Analytics Job, in which I defined an Input, an Output and a Query.
Then I started the Stream Analytics Job and my data is automatically transferred into a SQL-database, which can be queried by other programs also.


Gaëtan
Reply

simon Offline
eWON Support
#18
Gaëtan,

Congrats ! This is excellent !

Thanks for sharing with the community !

Simon
Reply

alo_dafo Offline
Junior Member
#19
Hello! 

I tried following the steps, but I'm having some problems.

First, I'm using Azure IoT Central, not IoT Hub.
IoT Central is a "simplified" version to speed up the connection of devices.

I can upload the certificate generated by the site, but then the site asks me to create a verification certificate (proof of possession).
See attached image.

How can I do this?

I found some examples using OpenSSL but I don't really understand how to do.

Has anyone else used eWON Flexy connected to Azure IoT Central?

As I understand, SAS only works for one year and then needs to be renewed? I need to be able to extend the time, as I cannot update the SAS keys on all machines (100+ eWONs).

/Daniel


Attached Files
.png   help1.png (Size: 31,51 KB / Downloads: 11)
Reply

simon Offline
eWON Support
#20
Hi Daniel,

I have never used Azure IOT central but that's indeed interesting.
Have you found out how to connect an Ewon ? If no, I will plan some time to look at this soon. Is it for a real project or just for a POC ? What is the urgency ?

Simon
Reply

tedsch Offline
Junior Member
#21
Shared Access Signatures for Azure can be set to longer than one year.

I was able to create one with a time frame of ten years and then one for 100 years.  Not sure the hardware would last this long, no offense intended Simon.

I have connected a Flexy to Azure IOT Hub which is what is used under the hood of the Azure IOT Central applications.
Reply

simon Offline
eWON Support
#22
Hi Ted,

That's great you managed to create SAS key for a longer period (of course 100 years is too much Big Grin)
Could you explain how you did ?

Regarding your sentence "I have connected a Flexy to Azure IOT Hub which is what is used under the hood of the Azure IOT Central applications. "
Do you mean that Daniel can use my script (first post of this thread) to connect the Azure IOT Hub and use the device in IOT central ? If yes, how to make this link ?

Thanks!

Simon
Reply

tedsch Offline
Junior Member
#23
I used Visual studio 2019 to create the SAS for the device.

Download/Install Visual Studio 2019.  Open the application without any code, there is an option for that it is just in small print.

Once it is open then go to view cloud explorer.  Here you will need to enter the credentials for the Azure account that you are working with.

Then you should be able to see a section labeled IOT hubs.  Expand that section and the IOT hub(s) will be displayed.  (Bonus Info if you right click on a hub and select monitor you can see any IOT data that is coming into that hub.)

Expand the IOT hub and select the created device and then right click on the device and select create SAS.  You will be prompted for the number of hours for the token lift.   Once it is created it will be copied to your clipboard.

https://docs.microsoft.com/en-us/visuals...ew=vs-2019

https://devblogs.microsoft.com/visualstu...-studio-2/

Below is an example of the changes needed for the MQTT connect section. This is using just the cafile and a SAS token to connect to Azure IOT hub. The SAS token is actuall being stored in a sting tag on the Flexy unit. This way we can update the SAS token on all our devices remotely.

The device must be created in the Azure IOT hub first. When creating the device just use the defaults do not select 509 self signed.
(Bonus info you can also create a device using Visual Studio cloud explorer.)

MQTT "Open",DeviceId$,IotHubName$ + ".azure-devices.net"
Mqtt "SetParam","Port","8883"
MQTT "setparam", "log", "2" // 0=info 1=warning 2=error 3=verbose
MQTT "setparam", "keepalive", "30"
MQTT "setparam", "TLSVERSION", "tlsv1.2"
MQTT "setparam", "PROTOCOLVERSION", "3.1.1"
MQTT "setparam", "cafile","/usr/AzureCA.crt"
Mqtt "SetParam","Username",IotHubName$+ ".azure-devices.net/"+DeviceId$+"/api-version=2016-11-14"
MQTT "setparam", "password", SAS_TOKEN_VALUE@
Mqtt "Subscribe", TopicToSubscribe$,1
Mqtt "Connect"
Reply

simon Offline
eWON Support
#24
Hi Ted,

Thanks for sharing that with the community!! That's really appreciated !!
I have tried it and it works perfectly !


.png   2020-01-10_15-52-24.png (Size: 67,77 KB / Downloads: 18)

Simon
Reply

alo_dafo Offline
Junior Member
#25
(07-01-2020, 04:47 PM)simon Wrote: Hi Daniel,

I have never used Azure IOT central but that's indeed interesting.
Have you found out how to connect an Ewon ? If no, I will plan some time to look at this soon.  Is it for a real project or just for a POC ? What is the urgency ?

Simon

Hello Simon,

This is a real case, however we are reviewing which cloud platform to use.
For now we will proceed with Mindsphere but we want to be able to use Azure as well.

I will review Ted's replies and see if I can implement this to Iot Central.
I could ofcourse use IoT hub but I'd prefer Iot Central as this is is a much simpler solution.

Thanks,
Daniel
Reply

alo_dafo Offline
Junior Member
#26
(10-01-2020, 04:53 PM)simon Wrote: Hi Ted,

Thanks for sharing that with the community!! That's really appreciated !!
I have tried it and it works perfectly !



Simon

Hello Simon and Ted,

So I'm quite a newbie to Azure, SAS and MQTT.

The information I have from IoT Central is as the image below shows:

.jpg   IoTC_SAS.jpg (Size: 34,99 KB / Downloads: 8)

I also have my application-ID (ed256466-****-****-****-************) and my app URL (https://appname.azureiotcentral.com)

The catfile as described, which is that? The one generated by your website? Or another one?

The link "learn more" lead to this:
https://docs.microsoft.com/sv-se/azure/i...-using-sas
But I do not understand how to proceed.

Perhaps you have some idea?
Reply

egutierrez Offline
Junior Member
#27
(08-01-2020, 09:56 PM)tedsch Wrote: I used Visual studio 2019 to create the SAS for the device.

Download/Install Visual Studio 2019.  Open the application without any code, there is an option for that it is just in small print.

Once it is open then go to view cloud explorer.  Here you will need to enter the credentials for the Azure account that you are working with.

Then you should be able to see a section labeled IOT hubs.  Expand that section and the IOT hub(s) will be displayed.  (Bonus Info if you right click on a hub and select monitor you can see any IOT data that is coming into that hub.)

Expand the IOT hub and select the created device and then right click on the device and select create SAS.  You will be prompted for the number of hours for the token lift.   Once it is created it will be copied to your clipboard.

https://docs.microsoft.com/en-us/visuals...ew=vs-2019

https://devblogs.microsoft.com/visualstu...-studio-2/

Below is an example of the changes needed for the MQTT connect section.  This is using just the cafile and a SAS token to connect to Azure IOT hub.  The SAS token is actuall being stored in a sting tag on the Flexy unit.  This way we can update the SAS token on all our devices remotely. 

The device must be created in the Azure IOT hub first.  When creating the device just use the defaults do not select 509 self signed. 
(Bonus info you can also create a device using Visual Studio cloud explorer.)

MQTT "Open",DeviceId$,IotHubName$ + ".azure-devices.net"
  Mqtt "SetParam","Port","8883"
  MQTT "setparam", "log", "2" // 0=info 1=warning 2=error 3=verbose
  MQTT "setparam", "keepalive", "30"
  MQTT "setparam", "TLSVERSION", "tlsv1.2"
  MQTT "setparam", "PROTOCOLVERSION", "3.1.1"
  MQTT "setparam", "cafile","/usr/AzureCA.crt"
  Mqtt "SetParam","Username",IotHubName$+ ".azure-devices.net/"+DeviceId$+"/api-version=2016-11-14"
  MQTT "setparam", "password", SAS_TOKEN_VALUE@
  Mqtt "Subscribe", TopicToSubscribe$,1
  Mqtt "Connect"
Hello Ted,

I'm following your method and I would like to know how did you do to store the SAS Token in the ewon (the SAS Token generated in visual studio). What kind of tag did you use? 
Any guide or advice is important to me, since this is the first ewon with I work.

Thanks and regards.


Attached Files
.jpg   ewon pic.JPG (Size: 38,29 KB / Downloads: 5)
Reply

simon Offline
eWON Support
#28
Hi,

To me, he stored it into a string Tags (supported as of firmware 13.1).

Simon
Reply

egutierrez Offline
Junior Member
#29
(19-01-2020, 09:52 AM)simon Wrote: Hi,

To me, he stored it into a string Tags (supported as of firmware 13.1).

Simon

Hi Simon, thanks for your replay.

My ewon has a previous version firmware and it hasn´t that kind of tag so finally I used your method and I got a certificate for 10 years. That's enough to this case.

Now I'm finding out how to visualize the data I'm sending to iot hub. Any idea according to your experience is welcome.

Thanks again.

Elías.
Reply

tedsch Offline
Junior Member
#30
Visualizing the data is something that I struggled with for a bit as well. There are multiple ways to "see" the data.

If you just want to see it roll through as it is sent to the IOT hub just to make sure things are working then use Visual Studio and do a data monitor on the IOT Hub.

After that there are many more ways to "see/use" the data that require a bit of work and it all depends on what the end goal is for the data.

Our case we wanted the data split out into multiple streams for processing before storing in Azure Table Storage. We used the built in event hub and when a new message is placed in the IOT hub it is moved onto an Azure queue. This queue is used to kick off some processing steps that are using Azure Functions to review the messages and take action accordingly.

There are other options of moving the data to service bus queue, Azure blob storage, Azure SQL Server, Azure data lake......... the list goes on. (Disclaimer not an Azure expert just an Azure user)

As you tell from the vast amount of information about IOT there are many ways, methods, vendors to ingest IOT data.

(19-01-2020, 09:52 AM)simon Wrote: Hi,

To me, he stored it into a string Tags (supported as of firmware 13.1).

Simon
That is correct.  Glad string tags were included as it made things easier to maintain.

(13-01-2020, 05:17 PM)alo_dafo Wrote:
(10-01-2020, 04:53 PM)simon Wrote: Hi Ted,

Thanks for sharing that with the community!! That's really appreciated !!
I have tried it and it works perfectly !



Simon

Hello Simon and Ted,

So I'm quite a newbie to Azure, SAS and MQTT.

The information I have from IoT Central is as the image below shows:


I also have my application-ID (ed256466-****-****-****-************) and my app URL (https://appname.azureiotcentral.com)

The catfile as described, which is that? The one generated by your website? Or another one?

The link "learn more" lead to this:
https://docs.microsoft.com/sv-se/azure/i...-using-sas
But I do not understand how to proceed.

Perhaps you have some idea?

Not sure the Flexy units are capable of supporting configuration from the Cloud.  Any addition of a Flexy unit to the IOT hub seems to have to be done manually.  I usually go and manually add a Flexy device to the Azure IOT hub.
Reply



Possibly Related Threads…
9 hours ago
Last Post: simon
09-03-2020, 02:29 PM
Last Post: simon
06-03-2020, 06:39 PM
Last Post: simon
  Creating Totaliser Within eWON Started by Josh
3 Replies - 1.076 Views
14-02-2020, 06:06 PM
Last Post: simon
  eWON and ThingWorx Started by simon
13 Replies - 6.428 Views
17-01-2020, 05:55 PM
Last Post: ltitel
07-01-2020, 03:34 PM
Last Post: simon
  Flexy and Microsoft Power BI Started by simon
19 Replies - 8.689 Views
10-12-2019, 11:25 AM
Last Post: simon
02-12-2019, 11:25 PM
Last Post: simon
27-11-2019, 10:30 PM
Last Post: simon
22-10-2019, 10:42 AM
Last Post: simon



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy