DIY: WiFi Moisture Sensor AAA battery

Updated: Apr 24

The Cricket ® Wi-Fi module allows developers to build electronic devices and connect them to smartphones or other internet services literally in minutes. What's more you can do it without dedicated programmers and writing a single line of code.

In this blog we present how to build moisture/water sensor with a battery level monitor in less than 30 minutes. The device monitors a moisture level and sends data to a smartphone over the internet (MQTT) with a chosen time interval. Use any MQTT mobile app to receive and visualise the data. The device is powered on a 2xAAA batteries (or a single AAA), if configured properly can last for years. It connects to the internet over Wi-Fi network by using Things On Edge Cricket ® Wi-Fi module, so you do not require any extra IoT HUB.

Before you start, please make sure you have the following components:

  1. Cricket Wi-Fi module (

  2. Soil Moisture Sensor

  3. 6-Way Terminal Block

  4. 2xAAA batteries (either AAA or AA)

  5. AAA batteries pack (either AAA or AA)

  6. 3x Female/Female Jumper Wires

If you are ready let's get started!


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 port NOTE: The Cricket module can be powered either on AA or AAA batteries

  • Connect the sensor VCC / + (green cable) to Cricket's 3V3 port NOTE: 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 port NOTE: This port can be configured as an analogue signal. The data will be reported to your smartphone

  • Connect the sensor GND / (-) (blue cable) to Cricket's GND port

  • Connect the battery GND / (-) (black cable) to the same Cricket GND port

Well done you have successfully assembled the device!

Connect your device to Wi-Fi

In a few steps you will connect your device to the internet over your Wi-Fi network. All you need to do is to activate Cricket's private Wi-Fi hotspot 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 until the LED is constantly lit.

  • Once the LED is constantly lit Cricket opened a private Wi-Fi hot spot. Connect from either a laptop or smartphone to the hot spot with the following credentials:SSID: toe_deviceNo password is required

  • Once connected, open a private web page: NOTICE:make sure LED is still ON! If is OFF repeat the steps from the beginning

  • Now you can pass your Wi-Fi network credentials and click CONNECT. If you passed correct SSID and Password then after few seconds the device should report it is online and the LED will be OFF.

Configure your device

NOTE: new Cricket versions 1.0 (with metal cover) can be configured entirely locally or from the service. Also please note was replaced with with this new Cricket versions.

For the moisture sensor it is recommended to set the following configuration:

  • 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:

  • Connectivity type: MQTT_TOE

  • 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.

Using MQTT client on mobile

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. The Cricket module connects through low-latency Things On Edge MQTT broker ( You just need to do the following steps:

  1. Configure a server connection with the following details: Server / Broker IP address: Port number: 1883 Network protocol: TCP

  2. Add device e.g. "Moisture Sensor"

  3. Goto advanced options: Username: your_cricket_serial_number Password: your_cricket_serial_number Connect automatically: YES

  4. Press the Create button

  5. Press ADD PANEL

  6. Select: Line Graph

  7. Set the details for graph 1 to read data from sensor (from the Cricket IO2 port) Panel name: e.g. Moisture sensor Topic for graph 1: /your_cricket_serial_number/io2 Show area: YES Show points: YES

For more information please refer to the attached screenshots from IoT MQTT Panel below.


Your moisture sensor is already working and sending data over the internet to your smartphone.

The battery level can be monitored via MQTT using dedicated topic:


Optimise your device to run for years on batteries

You can make your device to run for years on these batteries. You just need to make the following changes:

  1. wake up every couple of hours e.g. 2 hours

  2. send data to the internet only when the sensor's value changes

Set the following 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

Monitor a battery level

In principle the less module communicates, the better power saving. Cricket requires energy for both sending an update to the cloud and evaluating values of attached sensors only. It is true 0A when is OFF.

In practice it can send 10k messages using 2xAAA alkaline batteries and more than 15k when used lithium batteries.

In this case the battery monitor configuration is also set to send update when the battery level value changes only. Additionally battery consumption can be reduced by lowering resolution of measuring an analog signal.

The battery value can be calculated as follow:

Vbatt = val * (3.5/256) * 2^Battery divider

where 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/256 * 8 = 1.42V

Minimum value for the Cricket is 1.1V.

IO2 analog input configuration

  • IO2: Analog In

  • IO2 Analog Divider: 3

These values reduce resolution of the analog signal and significantly reduce battery consumption, module will reduce time sending new updated values.

Likewise, the analog value can be calculated using the following formula:

IO2 (V) = io2_val*3.5/256 * 2^IO2 Analog Divider

Analog divider of 3 provides resolution approx. 0.1V

Receive even more data ...

There is much more you can play with your current device such as reading built-in temperature sensor, read the battery level, and more.

Please checkout more detailed information in the documentation:


Thank you for taking your time! If you enjoyed building this moisture sensor I would really appreciate if you could spread the word. If you have any feedback or suggestions how to improve it and make easier for other developers, we would be more than happy to do it. We are opened for your suggestions.

Many thanks & Enjoy!

4,227 views5 comments

Recent Posts

See All