WiFi-enabled soil moisture sensor

Overview

w-parasite

Front Back

w-parasite is an open source, WiFi-enabled soil moisture sensor for house plants.

This repo contains all the hardware design files (schematic, printed circuit board layout) and code for customizing and making your own w-parasite.

How It Works

Diagram

w-parasite works by reading the soil moisture level and transmitting that information via MQTT messages via WiFi. To save battery, the board sleeps most of the time, and only wakes up every few minutes, at which point it takes a reading and ships it to the MQTT broker.

An ESP32 sits at the heart of the board, and is responsible for managing the sensors and connecting to WiFi.

The board can be powered with LiPo/Li-Ion batteries. There is a battery clip for rechargeable LIR2450 batteries, as well as a possibility for soldering a JST connector for beefier LiPo/Li-Ion batteries.

Moisture Sensor

To measure the soil moisture, two PCB traces act like a disguised capacitor. These are the two large copper traces on the bottom of the board, on the part that goes into the soil. The capacitance between these two traces vary according to the amount of water around them, and we exploit that phenomenom to infer the soil moisture.

A picture of the sensor in the ground

This great post on wemakethings goes into detail about the inner workings of capacitive soil moisture sensors. I also expanded a little bit on the topic it in here.

Repo Organization

Battery Life

To estimate the battery life and discuss our choices, we can agree on a few premisses:

  1. Soil moisture doesn't change abruptly (except when watered). It is okay to wait several minutes between readings.
  2. Most of the time, the sensor will be in a low power mode ("deep sleep"), in which its CPU is not active and it's not connected to WiFi. The current consumption in this state can be brought to around 15uA (10uA for the ESP32 and around 6uA for the voltage regulator - LDO);
  3. When the sensor is active, its current consumption is orders of magniture higher. WiFi and ESP32 are not usually a good choice for low power devices, but since we can get away with such long periods of deep sleep, we might just barely get away with it. When active, w-parasite can consume peaks of over 200mA. It is paramount that we keep the active time short - cutting it down from 2 seconds to 1 second essentially doubles the battery life.

I have experimented with two main types of battery:

  • LIR2450 Li-Ion coin cells. They are super compact (as in the photo above). With around 120mAh, they can only source short peaks of 200mA, which is below what the ESP32 expects. Using them poses a challenge on capacity and current, and that's why we like it so much;
  • LiPo/Li-Ion cells. They are generally a lot bigger but usually pack up to 3000mAh. They take a lot of space but comfortably powers w-parasite for well over a year;

Back with two w-parasites with different batteries

I put together this spreadsheet to estimate battery life. Here are some example scenarios:

  • LIR2450 cell (120mAh), transmitting every 30 minutes: around 80-90 days.
  • 1200mAh LiPo, transmitting every 10 minutes: over a year;
  • 18650 Li-Ion (e.g.: 2700mAh), transmitting every 5 minutes: over a year;

Possible Improvements

Ideas for improvements go in the direction of battery saving by shaving off precious milliseconds during the active cycle:

  • Use a static IP address, BSSID and static dns servers. This has the downside of being less plug-and-play, so we need to investigate if the savings in connection time are worth it;
  • Reduce boot time. We can configure esp-idf to suppress boot logging. This will probably require re-compiling the SDK ourselves, as Arduino/PlatformIO uses a prebuilt binary. See this Github doc. This Reddit thread also has valuable info. Major savings seem to come from:
    • Pulling GPIO15 down on reset. It disables UART output;
    • Set BOOTLOADER_LOG_LEVEL to NONE/ERRORS;
    • ESPTOOL_FLASHMODE: QIO if possible;
    • SPIRAM_MEMTEST: disable RAM test;
  • Experiment with a 3.0V LDO (such as the HT7330). The ESP32 should be able to run with 3.0V (instead of the nominal 3.3V we're using here, which has a 0.9V dropout voltage, so we can only power it with at least 3.39V). This would make better use of the LIR2450 cell. From the LIR2450 discharge curve, I don't think the gains are massive, but we could probably squeeze 10%-ish more out of the LIR2450;
  • Tigther MQTT messages. We currently send out multiple MQTT messages. This makes it easy to work with on the other end, but we can probably do better to bring the runtime down;

Why not Bluetooth Low Energy (BLE)?

Excellent question! With BLE, we can work with much lower currents, and we can power the board with even cheaper batteries like the ubiquitous CR2032. SoCs like the nRF5 family from Nordic are much better suited for ultra low power applications. They idle at less than 1uA and can transmit with ~5mA (compare with 100-200mA for the ESP32 + WiFi)! I believe they are a better fit for battery-powered, intermittent sensors like this one. Moreover, ESP32, specially with WiFi is notoriously power hungry. Even if we implement all the tricks in the book, we won't likely match the power efficiency of BLE-only chips.

With all that out of the way, if we power this with a beefier LiPo/Li-Ion battery, we can hopefuly already run for over a year on a single charge, with the added advantage of having a simpler architechure and more friendly - the sensor talks directly to your MQTT broker. Additionally, BLE devices usually have a much lower range and often require bridges for integrating with the rest of our system.

News & Updates

For the freshest w-parasite updates, follow @rbaron_.

License

The hardware and associated design files are released under the Creative Commons CC BY-SA 4.0 license. The code is released under the MIT license.

You might also like...
ESP8266 WiFi Connection manager with fallback web configuration portal
ESP8266 WiFi Connection manager with fallback web configuration portal

ESP8266 WiFi Connection manager with fallback web configuration portal

owfuzz: a WiFi protocol fuzzing tool using openwifi.
owfuzz: a WiFi protocol fuzzing tool using openwifi.

Openwifi is an open-source WiFi protocol stack based on SDR that is fully compatible with Linux mac80211. It's driver takes advantage of the Linux kernel's supports (mac80211, cfg80211) for WiFi high MAC, so it can provide an interface to the application layer like a common WiFi USB dongle.

ESP8266 powered Xilinx Virtual Cable - Xilinx WiFi JTAG!
ESP8266 powered Xilinx Virtual Cable - Xilinx WiFi JTAG!

Xilinx Virtual Cable Server for ESP8266 Overview ESP8266 implementation of XVC (Xilinx Virtual Cable) protocol based on xvcd

OtterCastAmp is an open-source WiFi Speaker amplifier, based on a Sochip S3 SoC. Powered by any USB PD adapter for up to 100W of music.
OtterCastAmp is an open-source WiFi Speaker amplifier, based on a Sochip S3 SoC. Powered by any USB PD adapter for up to 100W of music.

OtterCastAmp is an open-source WiFi Speaker amplifier, based on a Sochip S3 SoC. Powered by any USB PD adapter for up to 100W of music.

ESP 32 webserver to serve a static page for wifi settings

ESP32 Settings WebServer This is a ESP32 Firmware developed in PlatformIO which consists in a HTTP server for serve static files and provides an API f

Update ESP32 firmware over WiFi from a web server

esp32-firmware-update Update ESP32 firmware over WiFi from Github This includes a python script which generates the update json file based on the firm

RPI Pico WIFI via ESP-01S, LWESP, FreeRTOS, and MQTT example

RPIPicoRTOSMQTT RPI Pico WIFI via ESP-01S, LWESP, FreeRTOS, and MQTT example Demo code for RPI Pico using ESP-01S for wifi connection over uart. With

Stream server (serial-to-wifi bridge) for ESPHome

Stream server for ESPHome Custom component for ESPHome to expose a UART stream over WiFi or Ethernet. Can be used as a serial-to-wifi bridge as known

WiFi scanner with visual persistence, intended to find the idlest channel e.g. to assign to a ZigBee device
WiFi scanner with visual persistence, intended to find the idlest channel e.g. to assign to a ZigBee device

WiFiChanViz Motivation This tool was initially coded to help find the idlest 2.4GHz channel in order to connect a ZigBee device to HomeAssistant in id

Comments
  •  Brownout detector was triggered when powering of CR2450

    Brownout detector was triggered when powering of CR2450

    When powering the circuit from a CR2450 battery, I only get brownout's and the code never starts...

    ets Jun  8 2016 00:22:57
    
    rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:2
    load:0x3fff0018,len:4
    load:0x3fff001c,len:1044
    load:0x40078000,len:10124
    load:0x40080400,len:5828
    entry 0x400806a8
    
    Brownout detector was triggered
    

    I would have expected this behaviour as the ESP requires a large current at startup and wifi communication. How did you solve this problem? I see pictures from you using an CR2450 battery.

    opened by sillevl 2
  • Add kitspace.yaml and BOM

    Add kitspace.yaml and BOM

    Hi, I thought this would be a neat project to add a kitspace.org page for. Kitspace tries to make it easier for people to re-build OSHW electronics projects.

    I've added the necessary files. I generated a BOM from the kicad_pcb and used the bom-builder to make it "purchaseable". Here is a preview of what the page would look like.

    If you are happy to add the page just merge this. The page will keep updating with your repo in the future (every 3 hours or so).

    opened by kasbah 1
Owner
null
A simple and easy WiFi-enabled ESP8266-powered WSPR and FT8 beacon which uses NTP + DS3231 RTC for timing.

Easy-Digital-Beacons-v1 A simple and easy WiFi-enabled ESP8266-powered WSPR and FT8 beacon which uses NTP + DS3231 RTC for timing. The whole design is

Dhiru Kholia 36 Nov 20, 2022
A WiFi-enabled microcontroller capable of communicating with web-based service APIs for fast prototyping applications.

A WiFi-enabled microcontroller capable of communicating with web-based service APIs for fast prototyping applications.

Mark Hofmeister 2 Mar 9, 2022
WiFi Attack + Recon Suite for the ESP8266 WiFi Nugget

Nugget-Invader Welcome to the Nugget Invader repository! The Invader is a WiFi attack suite developed for the WiFi Nugget, an ESP8266 based platform d

HakCat 40 Nov 28, 2022
Wifi MQTT Data Logging via an esp8266 for the Ikea VINDRIKTNING PM2.5 air quality sensor

MQTT connectivity for the Ikea VINDRIKTNING This repository contains an ESP8266 firmware, which adds MQTT to the Ikea VINDRIKTNING PM2.5 air quality s

Sören Beye 943 Dec 31, 2022
This is a MQTT-enabled, compact weather station powered by a Wemos D1 minicontroller and built with 3D-printed parts

This is a MQTT-enabled, compact weather station powered by a Wemos D1 minicontroller and built with 3D-printed parts. It supports OTA updates.

65397 1 Feb 10, 2022
A WiFi mapping companion app for Valetudo

Valeronoi (Valetudo + Voronoi) is a companion for Valetudo for generating WiFi signal strength maps. It visualizes them using a Voronoi diag

Christian F. Coors 203 Jan 8, 2023
Tuya IoTOS Embeded SDK WiFi & BLE for BK7231T

Tuya IoTOS Embedded Wi-Fi and BLE SDK for BK7231T 中文版 | English Overview Developed independently by Tuya Smart, Tuya IoTOS is the world's only IoT ope

Tuya 35 Dec 5, 2022
T-Watch 2020 v1 compatible firmware providing WiFi and BLE testing tools (and also, a watch :D)

ESP-IDF template app This is a template application to be used with Espressif IoT Development Framework. Please check ESP-IDF docs for getting started

Damien Cauquil 49 Dec 23, 2022
Netstick client for Nintendo 3DS -- turn your portable console into a Linux compatible WiFi gamepad!

Netstick turns your 3DS into a wifi enabled gamepad! Control any linux-based device (such as a Raspberry Pi running Retropie) using your 3DS!

null 33 Oct 6, 2022
WiFi/MQTT Code For the ThingPulse ESPGateway

ESP32-Paxcounter with ThingPulse ESPGateway This project lets you run the ESP32-Paxcounter project on the ThingPulse ESPGateway. The ESPGateway has tw

Daniel Eichhorn 6 Aug 13, 2022