mcThingsTago.io
Published © GPL3+

Tago and mcThings IoT Monitoring and Dashboard!

An easy to setup, ultra-low power IoT temperature sensing network example using Tago and mcThings!

EasyFull instructions provided30 minutes303
Tago and mcThings IoT Monitoring and Dashboard!

Things used in this project

Hardware components

mcModule120 Dev Kit
mcThings mcModule120 Dev Kit
We recommend a kit for this example so that you have multiple modules to gather information from (Not required but you will need at least one mcModule, one mcGateway and an mcDongle)
×1

Software apps and online services

mcStudio
mcThings mcStudio
IDE for the mcThings platform
Tago
MQTT
MQTT

Story

Read more

Code

mcModule120 Tago code example

mcScript
Class TagoTemps
    
    Const TagoTopic As String = "tago/data/post"
    
    Shared Event CheckTemp() RaiseEvent Every 60 Seconds 
        Dim temp As Float = TempSensor.GetTemp() // Get Temp from sensor
        
        Dim variable As Json = New Json
        variable.Add("variable", "Temperature")
        variable.Add("unit", "F")
        variable.Add("value", temp)

        
        // Publish to Tago.io
        Lplan.Publish(TagoTopic, variable.ToListOfByte)
    End Event
    
    Shared Event CheckVoltage() RaiseEvent Every 5 Minutes
        Dim BattVolt As Integer = Device.BatteryVoltage// Get battery voltage
        
        Dim variable As Json = New Json
        variable.Add("variable", "BatteryVoltage")
        variable.Add("unit", "mV")
        variable.Add("value", BattVolt)
        
        
        
        // Publish to Tago MQTT
        Lplan.Publish(TagoTopic, variable.ToListOfByte)
        
    End Event
End Class

mcModule120 temp sensor library

mcScript
erties of the I2C peripheral and device address
        Dim sensor As I2c
        sensor = I2c.Create(250000, Pin.SCL, Pin.SDA, 0x48)
        
        // Power up the sensor and give it some time to settle
        Device.EnableTempSensor()
        Thread.Sleep(40000) // See page 13 of the datasheet
        
        // Read the sensor (only 2 bytes to read
        Dim res As ListOfByte = sensor.Read(2)
        
        // See Tmp102 documentation how to interpret the data (page 8)
        Dim temp As Float = Float.NaN 
        If res <> Nothing Then
            // Shift the partial part to the right nibble
            Dim part As Float = res(1) >> 4
            // Temperature partial is 1/16*n where n is between 0 and 15            
            part = part / 16
            // Sign extend the byte to an integer
            temp = res(0).SignExtend() + part
        End If
        
        // power off
        Device.DisableTempSensor()
        Return temp
    End Function
    
    Shared Function GetDieTemp() As Float
        // Just get the temperature and return
        Return Device.TempDie 
    End Function
    
    Shared Function ToFarenheit(celcius As Float) As Float
        Return (celcius * 9) / 5 + 32
    End Function
    
    Shared Function ToCelcius(farenheit As Float) As Float
        Return (farenheit - 32) * 5 / 9
    End Function
    
End Class

Credits

mcThings

mcThings

17 projects • 48 followers
Use mcThings to quickly & easily create, test and deploy IoT solutions for industrial, business/commercial and individual needs!
Tago.io

Tago.io

0 projects • 2 followers
Tago offers an end-to-end cloud platform that transforms the way businesses create value from connected products and user interactions.

Comments

Add projectSign up / Login