In this quick project, we'll show you how you can use a simple sensor connected to the mcModule120 to measure the water levels in your Christmas tree this holiday season!
We'll send the information to the cloud, using MQTT, to an Android phone application AND, send alerts via IFTTT.
Keep in mind, you can send the data from mcThings devices to multiple different cloud platform applications as well!
The mcThings platform includes 2 main components: mcModules and mcGateways. A powered and connected mcGateway creates the mcAir network (up to 200m range under optimal conditions) and bridges the information between the mcModules (within range) to and from the Internet. Using the IDE (mcStudio) and mcScript (ultra-low power programming language - a subset of VB.NET) allows you to wirelessly connect, debug and program modules with your customized scripts.
Note: - You also require an mcDongle to complete firmware updates on the modules/devices and gateways! We recommend looking at the mcModule120 Dev kit which includes everything you need to get going!
We acquired some inexpensive soil moisture sensors (but are using them here as water sensing sensors) and then connected them to a mcModule (Note - The modules shown below are mcMod110, end of life now, but this project is the exact same using the new mcMod120).
The concept for connection is the same as our Soil Moisture Sensor Project here on Hackster - Check it out for full details on connecting the sensor to the mcModules.
- Moisture Sensor: PIN 0 & GND
- Resistor: PIN 6 & PIN 0
We are sending the soil moisture data as well as the temperature to the Android application and the battery voltage alerts to IFTTT. All of the below is customizable to send to different cloud applications that can receive MQTT.
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
Using MQTT and IFTTT, you can send information to tons of different applications! (Check out a LIVE real-time dashboard with mcModules using Losant - We show you how to do setup this dashboard in one of our other Hackster projects)
There are examples on our YouTube channel and also from other users within our forum. Watch for upcoming projects where we'll send data to some of our partners such as Losant and thethings.io!
Please join our Hub here on Hackster as a member so you can keep up with the many projects we are posting shortly!
Thanks for reading!