mcThings
Published © GPL3+

GPS Asset Tracking Using the mcDemo205, SIGFOX & Microsoft!

Using the Sigfox network, an mcDemo205 device and Microsoft's Azure IoT hub, we'll display locations using powerful visualization tools!

EasyFull instructions provided1 hour917
GPS Asset Tracking Using the mcDemo205, SIGFOX & Microsoft!

Things used in this project

Hardware components

mcDemo205
mcThings mcDemo205
×1
mcGateway110
mcThings mcGateway110
×1

Software apps and online services

Microsoft Azure
Microsoft Azure
Sigfox
Sigfox
mcStudio
mcThings mcStudio

Story

Read more

Schematics

mcDemo205 Product brief

Code

mcDemo205 GPS Code

mcScript
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

Credits

mcThings

mcThings

2 projects • 44 followers
Use mcThings to quickly & easily create, test and deploy IoT solutions for industrial, business/commercial and individual needs!
Contact

Comments

Add projectSign up / Login