Wifi Moisture Sensor Powered On Aaa Battery
About the project
Build a WiFi 2xAAA battery powered flower moisture/water sensor in minutes and monitor on a smartphone. Without coding and programming.
Project info
Difficulty: Easy
Platforms: Things On Edge
Estimated time: 1 hour
License: GNU General Public License, version 3 or later (GPL3+)
Items used in this project
Hardware components
Story
This project demonstrates how to build moisture sensor with a battery monitor in less than 30 minutes. The device monitors a moisture level and sends data to your phone over the internet (MQTT) with a chosen time interval. We picked up one of MQTT mobile apps to receive and visualise data. The device is going to be powered on a 2xAAA batteries (it can also be on a single AAA). if configured correctly can last for years. It connects to the internet over Wi-Fi network by using IOT Cricket Wi-Fi module.
Before you start, please make sure you have the following components:
- Cricket Wi-Fi module (https://www.thingsonedge.com/)
- Soil Moisture Sensor
- 6 way terminal block (optional)
- 2xAAA batteries (either AAA or AA)
- AAA batteries pack (either AAA or AA)
- 3x jumper wires
If you are ready let's get started!
Assembly
Solder the 6-way terminal block to the Cricket module. The terminal block makes it easier to play around with cables.
1 / 2 • Left: 6-way terminal block; Right: Cricket Wi-Fi module
Left: 6-way terminal block; Right: Cricket Wi-Fi module
Soldering 6-way terminal block
Now you need to connect batteries and the moisture sensor to the Cricket module with the following steps:
- Connect battery VCC / + (red cable) to Cricket's BATT portNOTE: The Cricket module can be powered either onAA or AAA batteries
- Connect the sensor VCC / + (green cable) to Cricket's 3V3 portNOTE: 3.3V port supplies stable 3.3V regardless of a battery voltage level
- Connect the sensor AOUT analog signal (yellow cable) to Cricket's IO2 portNOTE: This port can be configured as an analogue signal. The data will be reported to yoursmartphone
- Connect the sensor GND / - (blue cable) to Cricket's GND port
- Connect the battery GND / - (black cable) to the same Cricket GND port
An assembleded device
Before you start using the device it needs to be connected to WiFi and configured.
Connect to Wi-Fi
All you need to do is to activate Cricket's private Wi-Fi hotspot (toe_device) and then open a private web page to pass your Wi-Fi network credentials. Please follow the steps below:
- Press and hold a button on the module for ~5 seconds
Press the button for 5 seconds until LED is on and is not blinking
Press the button for 5 seconds until LED is on and is not blinking
- Cricket opens a private toe_device Wi-Fi hotspot. Connect from either a laptop or smartphone to this hotspot. No password is required
Select: "toe_device" network
Select: "toe_device" network
- Once connected, a private web page should be opened automatically. If not, open it manually from a browser: http://192.168.4.1/index.html
Type your Wi-Fi network credentials
Type your Wi-Fi network credentials
- Now you can pass your Wi-Fi credentials and click CONNECT
Configure your device
Open Cricket's configuration panel and set the following:
- Set IO2 as an analog input
- Report moisture level every 2 hours - it will make your device running on 2xAAA alkaline batteries for more than 2 years.
Set the following configuration:
- RTC: ON
- RTC Units: Seconds(to be changed later)
- RTC Units Value: 30(to be changed later)
- IO2: Analog In
- IO3: Off
- Battery monitor: On
- Battery divider: 0
- Temperature sensor: Off
- Force updates on - IO1 Wake Up: On(to be changed later)
- Force updates on - RTC Wake Up: On(to be changed later)
- Post Events: leave all empty
More information on how to configure Cricket can be found in the documentation here.
Let's now go and configure your phone to receive data from Cricket.
Receive data on you phone using MQTT client
You can use any preferred MQTT client. However for the completeness for this project let's use IoT MQTT Panel application to receive and visualise data. We configure Cricket to use TOE_MQTT broker but you can use any other MQTT broker. So in the app you just need to do the following steps when using TOE_MQTT:
- Configure a server connection with the following details:Server / Broker IP address: mqtt.thingsonedge.comPort number: 1883Network protocol: TCP
- Add device e.g. "Moisture Sensor"
- Goto advanced options:Username: your_cricket_serial_numberPassword: your_cricket_serial_numberConnect automatically: YES
- Press the Create button
- Press ADD PANEL
- Select: Line Graph
- Set the details for graph 1 to read data from sensor (from the Cricket IO2 port)Panel name: e.g. Moisture sensorTopic for graph 1: /your_cricket_serial_number/io2Show area: YESShow points: YES
Please see the screenshots from IoT MQTT Panel below how you can configure the app to receive and visualise the data.
Type the same unique serial number for both username & password
Add a new panel
Select Line Graph to visualise the data from the moisture sensor
The graph visualises the data coming from the sensor
Congratulations!
Your moisture sensor is already working and sending data over the internet to your phone.
The battery level can be monitored via MQTT using dedicated topic /your_cricket_serial_number/batt
Optimise the battery usage of your device
You can optimise your device to run for years on batteries. You just need to change the following:
- send data to the internet only when the sensor's value changes
- wake up every couple of hours e.g. 2 hours
Set the following Cricket's configuration:
- RTC: ON
- RTC Units: Hours (send data only when changed)
- RTC Units Value: 2
- IO2: Analog In
- IO2 Analog Divider: 3
- IO3: Off
- Battery monitor: On
- Battery divider: 3
- Temperature sensor: Off
- Force updates on - IO1 Wake Up: Off (send data only when changed)
- Force updates on - RTC Wake Up: Off (send data only when changed)
- Post Events: leave all empty
Battery monitor configuration
In this case the battery monitor configuration is also set to send update only when the battery level changes. Additionally battery consumption can be reduced by lowering resolution of measuring an analog signal.
The battery voltage can be calculated as follow:Vbatt = val * (3.5/255) * 2^Battery dividerwhere val is reported battery level from MQTT service.
In this case 1.4V indicates low level of the alkaline battery and suggests replacing it, the value reported via MQTT is 13
Vbatt (V) = 13*3.5/255 * 8 = 1.42V
Minimum value for the Cricket is 1.1V.
Receive and visualise even more data
There is a lot more you can play with your current device such as reading built-in temperature sensor add extra peripherals etc.
Please checkout more detailed information in the documentation: https://www.thingsonedge.com/documentation
Feedback
Thank you for taking your time! If you enjoyed building this moisture sensor we would really appreciate if you could spread the word. If you have any feedback or suggestions how to improve, we are happy to hear them.
Many thanks & Enjoy!
Credits
THINGS ON EDGE
Things On Edge provides plug and play, ultra-low power Wi-Fi modules, which can run directly on AAA batteries for years. Designed for makers at all skill levels from advanced to those who just start building IoT devices.
Leave your feedback...