Things used in this project

Hardware components:
Mcdemo205 perspective 1000px cbplbgaklw
mcThings mcDemo205
×1
Mcgateway110 perspective 1000px iqkgknswa5
mcThings mcGateway110
×1
Software apps and online services:
W9gt7hzo
Microsoft Azure
Sigfox logo rgb j7ilnvhq6o
Sigfox
Mcstudio h8lhxdnyfz
mcThings mcStudio

Schematics

mcDemo205 Product brief

Code

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

Credits

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

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login