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!
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!
We acquired some inexpensive soil moisture sensors and then connected them to a couple of mcModules (Note - The modules shown below are mcMod110, end of life now, but this project is the exact same using the new mcMod120).
We started by attaching and sealing the moisture sensor into an enclosure. We made sure to make it a tight fit for the sensor and then sealed it nicely as it would be exposed to the elements. After the sensor was in in place, we then connected two flexible and short female jumpers:
We then soldered a couple of pins into the mcModule along with a 100k resistor for the voltage divider. You could easily connect the sensor directly to the module using male to female jumpers as well. We added pins to the module so that you can 'unplug' and remove the module from the enclosure if need be.
Pins Used- Moisture Sensor: PIN 0 & GND
- Resistor: PIN 6 & PIN 0
We then connected the sensor to the mcModule, added a battery and closed it up!
We suggest putting the UID of the module on the back of the enclosure for easy identification
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
Viewing the incoming information on AndroidUsing 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!
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!
Comments
Please log in or sign up to comment.