mcThings
Published © GPL3+

Wireless IoT Christmas Tree Water Sensor

Measuring the water levels in our Christmas tree to make sure it stays watered!

EasyFull instructions provided1 hour1,226
Wireless IoT Christmas Tree Water Sensor

Things used in this project

Hardware components

mcMod120 Module
mcThings mcMod120 Module
×1
mcGateway110
mcThings mcGateway110
×1
Android device
Android device
×1
soil moisture sensor (re-purposed for water measurement)
×1

Software apps and online services

mcStudio
mcThings mcStudio
Maker service
IFTTT Maker service
MQTT
MQTT

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

mcModule120 Product brief

Code

mcModule120 Programming

mcScript
Define PinMode Pin0 As AnalogInput Alias MoistureLevel
Define PinMode Pin6 As DigitalOutput Alias enableMoistureLevel

Class XmasTree
    
    Class MoistureNOTEMP
        Shared Event measureMoisture() RaiseEvent Every 120 Seconds
            
            enableMoistureLevel = True 'turn on voltage divider
            Thread.Sleep(40000) 'sleep 40ms for voltage to stabilize
            Dim voltage As Short = MoistureLevel
            Dim payload As ListOfByte = New ListOfByte
            Dim payString As String = ""
            If voltage > 1500 Then
                payString = "Dry - I NEED WATER!!"
            ElseIf voltage <= 1499 And voltage >= 800 Then
                payString = "Getting Low"             
            ElseIf voltage <= 799 And voltage >= 1 Then
                payString = "Watered!"                
                
            Else
            End If
            
            enableMoistureLevel = False 'turn off voltage divider
            payload.Add(payString)
            Lplan.Publish("mcThings/XmasTreeLevel", payload)
    End Event
        Shared Event sendMQTT() RaiseEvent Every 1 Minutes
            LedRed = True
            
            Dim payload As ListOfByte = New ListOfByte()
            Dim TempC As Float = TempSensor.GetTemp
            Dim TempString As String = TempC.ToString()
            
            payload.Add(TempString)
            
            Lplan.Publish("mcThings/XmasTreeTemp", payload)
            
            LedRed = False
    End Event
        Shared Event measureVoltage() RaiseEvent Every 2 Hours
            
            Dim BattVolt As Short = Device.BatteryVoltage
            
            If BattVolt < 2200 Then
                Lplan.IFTTT("YOURIFTTTKEYHERE", "XmasTreeBatt")
            Else
                
            End If
            
    End Event
    End Class 
    
    
    
End Class 

Credits

mcThings

mcThings

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

Comments

Add projectSign up / Login