Electron Interfacing to Azure IoT Hub

@RWB Indeed - hope this helps:

How to transmit data from elektron to PowerBI directly

My company wants a simple asset tracker that stores data in a database and visualizes them in PowerBI. To avoid a LAMP setup with API I used Microsoft's iot hub to transmit the data from several elektrons to AZURE

Parts

Particle asset tracker
Active GPS antenna

How to transmit data

  • include tinygps++

String payload = String::format( "{ "ts":%lu, "lat":%f, "lng":%f, "alt":%f, "spd":%f, "sat":%f, "dop":%i }",gps.time.value(),gps.location.lat(),gps.location.lng(),gps.altitude.meters(),gps.speed.kmph(),gps.satellites.value(),gps.hdop.value());
Particle.publish("db", payload, PRIVATE);

iot hub integration

Make sure you add blanks before every escape character when formatting the string.

Particles iot hub will not transmit json as a string unless you add the fields as custom json under advanced settings. For the case above it looks like:

{
"gpstime": "{{ts}}",
"latitude": "{{lat}}",
"longitude": "{{lng}}",
"altitude": "{{alt}}",
"speed": "{{spd}}",
"satellites": "{{sat}}",
"hdop": "{{dop}}",
"source": "{{PARTICLE_DEVICE_ID}}",
"published_at": "{{PARTICLE_PUBLISHED_AT}}"
}

So far that is the same as described here. Make sure to setup the iot hub on AZURE first and have the credentials and name of the hub available.

Azure iot hub - stream analysis

You cannot make a mistake when setting up an iot hub. Simply click and wait. Name of iot integration must comply with iot hub name indeed. iot hub receives data but to convert, store or forward them to PowerBI you want to add a stream analysis. When added to your AZURE define an stream analysis input, yes, iot hub and an output PowerBI. At that point AZURE asks you to authorize your PowerBI account.
To push the data through the analysis without changes simple add

SELECT
*
INTO
PowerBI
FROM
UTMtrack

PowerBI setup

In PowerBI, there is nothing to do. When stream analysis is started, the stream automatically shows up in PowerBI sources because you have authorized in your stream analysis

Now you can use you elektron data in PowerBi:

3 Likes