Compare previous and current message in Stream Analytics

Last week I was testing the temporary storage in IoT Edge. I was interested in the stability so I wanted to know if messages were missing or maybe even coming in twice.

I have this heartbeat module which produces a counter. So I am able to generate messages which can be measured as a sequence.

One way is to check this using your eyes 🙂

But this can be seen as a more generic issue, comparing two messages after each other. So I was thinking about Azure Stream Analytics. This should be the perfect tool for this job.

Let’s check out how we can compare subsequent messages using Stream Analytics.

Continue reading “Compare previous and current message in Stream Analytics”
Advertenties

Custom IoT Hub assignment in Device Provisioning Service

In my previous blog, I have shown how to provision a device using a real TPM using the Device Provisioning Service (DPS).

Once you are able to provision your IoT devices to the Azure IoT Platform using a DPS, a whole new world of possibilities opens up for you.

Before, you registered your device to one IoTHub. To change it, you had to go to the device and fix it. But now you are able to make a choice between multiple IoT Hubs within the cloud, dynamically!

But what strategy are you going to use?

Microsoft provides three standard strategies out of the box:

  1. Lowest latency (select the nearest IoT Hub)
  2. Evenly weighted distribution (select the IoT Hub with the least amount of devices)
  3. Static configuration (just select one yourself. This is the situation as before)

But there is a new strategy which is very flexible:

This fourth strategy makes use of a custom Azure Function which you can write yourself.

You could, for instance, access a database and read some data before you make the decision to which IoTHub you assign this device.

Let’s see how we can build a custom function ourselves and get the most out of it.

Continue reading “Custom IoT Hub assignment in Device Provisioning Service”

Prototype an IoT Dashboard with Adafruit IO

Last week I built this great demo with an Azure IoT Edge running on Industrial hardware, reading temperature, humidity, fan activity and led activity. But there was something missing…

I needed a simple dashboard to represent the values which were ingested by my Azure IoTHub and sent to an Azure Function.

Normally I build a basic website myself or I use tooling like PowerBI. It’s not that hard to get something sufficiently running for a demo.

But the last couple of weeks I was looking around for generic, off-the-shelf IoT Dashboards. And I had a couple of questions about their capabilities. What is on the market? What connectivity do they use? How many messages can I Ingest per time window? How do I configure the visual components? Etc.

I have reviewed a number of them and then I was checking out Adafruit IO.

This is what they see about themselves:

“Our simple client libraries work with the most popular devices such as the Adafruit Feather Huzzah, ESP8266, Raspberry Pi, Arduino, and more.”

I was triggered by the ‘more’ part. Does it also work with non-Adafruit devices? Because I know Adafruit from their DIY electronics shop, I was interested in what they are offering. And I was pleasantly surprised.

Let’s take a look at how we can integrate Adafruit IO in a generic demo with industrial hardware.

Continue reading “Prototype an IoT Dashboard with Adafruit IO”

Azure IoT Client SDK now supports IoT device modules

Silently, Microsoft introduced modules in IoT Devices.

No, I’m not talking about IoT Edge modules, these are modules for IoT Devices which can connect to the IoT Hub directly.

Before, we used the device client to communicate with clients and the IoTHub. And we used the Device Twin to configure the device with desired properties.

This approach is still valid. But in addition, we can also separate the client logic in multiple modules. And each module can send messages and receive a Module Twin configuration.

Let’s see how this works.

Continue reading “Azure IoT Client SDK now supports IoT device modules”

Testing Azure IoTHub Manual failover

The Azure IoTHub is the center of all the IoT efforts of Microsoft. Over the last couple of years (or even months) we see a lot of innovations from that side.

The latest addition is the Manual failover which is now in preview.

This makes it possible to move a complete IoTHub (with eg. all of its devices and routes) to the ‘sister region’. For example, an IoTHub living in West US 2 will move to West Central US. And you can move it back too.

The manual failover is a good starting point for having a more resilient IoTHub. It’s not perfect, there is a chance that unread messages or data is lost. Failover is hard:

But it’s a perfect way to test the ‘automatic’ failover which Microsoft provides when something happens with the region your IoTHub is living in.

I wanted to test this failover. And I wanted to build a client-side solution so I would not lose any messages.

Let’s see how it can be tested.

Continue reading “Testing Azure IoTHub Manual failover”

Take back control over IoTHub messages in Azure Functions

Azure Functions are a blessing for IoT solutions. To be so flexible executing code whenever messages are arriving, every IoT project is fully depending on it.

But one of the biggest frustrations is the casting of (EventHub) messages towards a string! Only the message body is left! Once a message is passed on to an Azure Function, I only have access to the body of the message. I can not access the (routing) properties anymore.

And before we got Azure Functions, we had to work with Stream Analytics. And I still do! And it’s so nice to have access to the IoT Hub values like the device name of the message. Because I am working with Azure Functions, I have to put it in the Message body first???

It would be great to have access to both the properties and the IoTHub values!

Well, it’s possible now with some clever casting…

Continue reading “Take back control over IoTHub messages in Azure Functions”

Writing commands to IoT Edge Modbus Modules

Microsoft provides several out-of-the-box modules for their Azure IoT Edge platform. If we do a quick search at the Public Docker repository, we see modules like

  • microsoft/iot-edge-opc-publisher
  • microsoft/iot-edge-opc-proxy
  • microsoft/azureiotedge-modbus-tcp
  • etc,

I already have described in a previous blog, how to consume and read data from that Modbus module. After checking out the documentation and some testing, I found out how to write commands back to the device too.

Let’s check out how we can use this in a Custom C# module. After that, we use it in an Azure Functions Module. So let’s do a deeper dive into Azure Functions on the IoT Edge as well.

Continue reading “Writing commands to IoT Edge Modbus Modules”