|Software apps and online services:|
In this project, we will setup an mcDemo205 to acquire its location, using GPS, and then send it out using Sigfox to Microsoft's Azure IoT Hub. From there, we will bring the data into Microsoft's Power BI so that we can display the locations on a map!
The mcThings platform allows you to send information using mcAir and Sigfox! For this example, we are using the mcDemo205 device (which can communicate on both networks). In this case, we'll use mcAir to program the device and then send the information to the cloud using Sigfox.
The mcThings platform includes 2 main components: mcModules/mcDevices and mcGateways. A powered and connected mcGateway creates the mcAir network (up to 200m range under optimal conditions) and bridges the information between the mcModules (within range) to and from the Internet. Using the IDE (mcStudio) and mcScript (ultra-low power programming language - a subset of VB.NET) allows you to wirelessly connect, debug and program modules with your customized scripts.
Note - You also require an mcDongle to complete firmware updates on the modules/devices and gateways! We recommend looking at the mcModule120 Dev kit which includes everything you need to get going!!
You first need to login or sign up for an Azure account (you can sign up for free and get $200 credit to start testing it out).
After you are up and running, you need to setup your IoT hub within Azure. Try out this tutorial and you can also search for others and videos online.
Create an IoT hub using the Azure portal : https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-create-through-portal
After you activate and connect your device to Sigfox (contact your region's Sigfox Network Operator for more details), you need to setup your callback so that the data from the mcDemo205 that arrives at the Sigfox backend is parsed properly and directed to your Azure IoT Hub.
Within the Callback menu, the Azure IoT hub integration is ready to go:
You need to create your custom payload configuration, get your connection string from Azure (to direct the information to your account) and write the JSON body. Sigfox provides support information on their website to learn more. Microsoft also provides information on their support page.
For this example, we will use the below information on the backend:
We'll program the device to get a GPS location once every 10 minutes and send the coordinates via Sigfox. The device will look for a minimum of 3 GPS satellites and timeout after 2 minutes if no signal is found.
On boot, the device will set itself to the Sigfox RC2 radio zone (US & Mexico). You can also set the device to RC4 (South America, Australia, New Zealand).
We then pack the message up and send it to Sigfox where it will be parsed by the information we entered into our Sigfox callback and relayed to our IoT Hub
The code for programming is found at the bottom of this project.
There are plenty of tutorials out there that describe all the cool stuff you can do within Power BI. Check these ones out:
Visualize real-time sensor data from Azure IoT Hub using Power BI: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-live-data-visualization-in-power-bi
The Power BI samples, a tutorial:: https://docs.microsoft.com/en-us/power-bi/sample-tutorial-connect-to-the-samples
We plotted our locations onto a map including the specific Lat/Long coordinates:
We also plotted and measured the longest message that we sent from the device to the base station during the experiment:
Thanks for reading!
mcDemo205 GPS CodemcScript
Class GPSMicrosoft ' Message Types Const MSGTYPE_LOCATION As Byte = 1 ' Configuration Constants Const GPS_TIMEOUT_uS As Integer = 120000000 '120 second timeout Const GPS_MIN_SAT_COUNT As Integer = 3 'minimum satellites to get a fix Shared Event Boot() ' Set Sigfox radio zone to US Lplan.SigfoxRadioZone(SigfoxRadioZone.US) End Event Shared Event StartLocationAcquisition() RaiseEvent Every 10 Minutes Led2 = True Thread.Sleep(100000) Led2 = False Device.StartGPS(GPS_TIMEOUT_uS, GPS_MIN_SAT_COUNT) End Event ' Called when GNSS location aquired or timeout occurred Shared Event LocationDelivery() ' Get latitude Dim Lat As Float = Device.GetLatitude() ' Get longitude Dim Lng As Float = Device.GetLongitude() ' Get GNSS fix time Dim timeIntUs As Integer = Device.GetGpsFixTime() ' Create Sigfox list of byte Dim sigfoxMsg As ListOfByte = New ListOfByte() ' Verify if the lat and lng were properly obtained sigfoxMsg.AddByte(MSGTYPE_LOCATION << 2) If Lat.IsNaN() Then Lat = 0.0 End If If Lng.IsNaN() Then Lng = 0.0 End If ' Add data to Sigfox message sigfoxMsg.AddFloat(Lat) sigfoxMsg.AddFloat(Lng) 'sigfoxMsg.AddByte(GetTemperature()) If Lat <> 0.0 Then ' Send Sigfox Message Lplan.Sigfox(sigfoxMsg) ' Turn off LED2 to indicate Sigfox transmission complete Led2 = False End If End Event End Class
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!