Close
0%
0%

Wireless IoT Soil Moisture Sensor Using mcThings!

Coin-cell operated, wireless IoT soil moisture sensor using mcThings! Alerts, status levels, temperature!

Similar projects worth following
Coin-cell powered, Wireless IoT Soil Moisture Sensor
To showcase an easy example of some of the impressive things that you can do with the mcThings IoT Platform, we created a little wireless low-power soil moisture sensor! In this project we'll show you an example of sending soil moisture status, battery voltage and temperature (using the built-in temperature sensor) to an MQTT client on Android. Feel free to use the below and send the information to other applications or services as you can send information to the cloud with using IFTTT and MQTT!

This is an example of using the mcThings platform to create an low-power, wireless, coin cell powered IoT soil moisture sensor!

There are some many different use-cases for an IoT solution like this:

- Agriculture (duh!): soil moisture levels for produce/farmer fields is immensely valuable as you can save resources and, potentially, increase yields by supply exactly the right amount of water

- Smart Cities: measuring and monitoring the moisture levels in green spaces could save cities tons of money by being efficient with water and people resources

- Etc!

How the platform works:

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!


Check out the walk-through below on how to do this yourself! 

mcmod120_product_brief.pdf

mcModule120 Product brief

Adobe Portable Document Format - 474.85 kB - 12/02/2017 at 18:24

Preview
Download

  • 1 × mcModule120
  • 1 × mcGateway
  • 1 × Resistor 100k ohm
  • 1 × Female/Female Jumper Wires
  • 1 × Soil Moisture Sensor

View all 7 components

  • 1
    Programming the mcModule to check soil moisture

    After working out the soil moisture variables (see YouTube video at the bottom) using the wireless debugging feature in mcStudio, we loaded the code onto the module and put into a planter. We programmed the module to check the soil moisture every 30 seconds as well as the temperature every minute and then send that information via MQTT to our broker, CloudMQTT.

    The module is also programmed to check the temperature every minute and also relay that information via MQTT to our broker.

    We also programmed the module to check its battery level every 2 hours and send a notification to a smartphone using IFTTT by setting up an applet to receive the information from the module and then alert on Android (using the IFTTT Android app) if the low-battery message was received.

    *Note - we programmed to check the soil every 30 seconds, the battery voltage every 2 hours and temperature every 60 seconds for the purposes of this example but in real-life and for a long battery life, you could easily set the intervals to only a couple of times per day or mix and match your intervals with the different variables you are measuring to tailor the information to your needs

    Define PinMode Pin0 As AnalogInput Alias MoistureLevel 
    Define PinMode Pin6 As DigitalOutput Alias enableMoistureLevel 
        
        Class RainSensor         
            Shared Event measureMoisture() RaiseEvent Every 30 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 >= 600 Then
                    payString = "Fairly Moist" 
                ElseIf voltage <= 599 And voltage >= 335 Then
                    payString = "Moist" 
                ElseIf voltage < 355 Then 
                    payString = "OVERWATERED"
                Else 
                End If 
                enableMoistureLevel = False 'turn off voltage divider
                payload.Add(payString)
                Lplan.Publish("mcThings/MoistureLevel", payload)
            End Event
            Shared Event sendMQTT() RaiseEvent Every 1 Minutes 
                Dim payload As ListOfByte = New ListOfByte() 
                Dim TempC As Float = TempSensor.GetTemp
                Dim TempString As String = TempC.ToString() 
                payload.Add(TempString) 
                Lplan.Publish("mcThings/GardenTemp", payload) 
            End Event
            Shared Event measureVoltage() RaiseEvent Every 2 Hours
                Dim BattVolt As Short = Device.BatteryVoltage
                If BattVolt < 2200 Then 
                Lplan.IFTTT("YOURIFTTTKEYHERE", "MoistureSensorBatt")
                Else
      
                End If
            End Event
        End Class
  • 2
    Viewing the incoming information on Android

    Using an Android MQTT App called IoT MQTT Dashboard we are able to see the incoming information from this device. There are many other great MQTT apps in the Google Play store that you should check out!

    Note - We had other mcModules reporting variables into the app including a rain sensor device!

  • 3
    YouTube Video

View all 5 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates