Author Topic: IoT Connected Christmas Tree - Wireless Water Level Sensor  (Read 188 times)

mcThings

  • We Connect Things To The Internet... That Can't Be Plugged In.
  • Administrator
  • Jr. Member
  • *****
  • Posts: 68
    • View Profile
    • www.mcthings.com
IoT Connected Christmas Tree - Wireless Water Level Sensor
« on: December 08, 2016, 04:35:40 pm »
In this video, Tom Edworthy sets up a wireless water level sensor for his Christmas tree to ensure that it's always watered. Using an MQTT app, Tom is able to monitor if the tree has a sufficient amount of water or if it needs to be watered.

https://youtu.be/GQahMGvYinw

Links to both the rain sensor and MQTT Iot app below:

Code:
Code: [Select]
Define PinMode Pin0 As AnalogInput Alias MoistureLevel
Define PinMode Pin6 As DigitalOutput Alias enableMoistureLevel

Class XmasTree
   
   
    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

Share on Facebook Share on Twitter Share on Google+