Skip to content

Soil Moisture Sensor Wireling Tutorial

TinyCircuits Soil Moisture Sensor Wireling product photo

This tutorial will show you how to acquire moisture readings from the Soil Moisture Sensor Wireling.

Technical Details

This Wireling features the ATtiny25, a high performance, low-power AVR 8-bit controller. Moisture is detected using capacitance to measure dielectric permittivity of the surrounding medium.

Technical Details

ATtiny25 specs

  • High performance, low-power AVR 8-bit microcontroller
  • Advanced RISC Architecture
  • Non-volatile program and data memories

TinyDuino Power Requirements

  • Voltage: 3.0V - 5.5V 
  • Current:
    • 300µA (Active Mode)
    • 0.1µA  (Power-down Mode)

Pins Used

  • A5/SCL - I2C Serial Clock line
  • A4/SDA - I2C Serial Data line


  • 10mm x 10mm (.394 inches x .394 inches)
  • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 3.70mm (0.15 inches)
  • Weight: 1 gram (.04 ounces)


  • You can also use this board without the TinyDuino – modifying the connecting cable by removing the opposite connector and stripping/tinning the wires, you can solder the connector cable to any other microcontroller board of your choice!


To interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable

There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.

Processor Adapter
*TinyDuino and USB TinyShield Wireling Adapter TinyShield
*TinyZero Wireling Adapter TinyShield
*TinyScreen+ Wireling Adapter TinyShield
WirelingZero N/A
*RobotZero N/A
Arduino Wireling Arduino Shield
Raspberry Pi Wireling Pi Hat

* These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.

In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).

You will also need the Soil Moisture Sensor Wireling and the included example Arduino sketch.

Wireling Code
Port 0 Soil Moisture Sensor Example Sketch

Hardware Assembly

Depending on the development system you choose, you will need to put together a TinyDuino stack using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 0 using a Wireling Cable. (You can change this port in the included Arduino Sketch using the Wireling.selectPort() function)

NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.

Software Setup

For this Wireling, you need the example Arduino Sketch included below.

You will also need the ATtiny25 Arduino Library.

Open up the program in the Arduino IDE.

Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.

Upload Program

Upload the program to your development board of choice!

 * Soil Moisture Sensor Wireling Example Sketch
 * This program uses one of the Wirelings included with the Starter Kit:
 * Port 0: Soil Moisture Sensor Wireling
 * This program will display the temperature and moisture detected by the
 * soil moisture sensor Wireling on the serial monitor.
 * Hardware by: TinyCircuits
 * Written by: Ben Rose and Hunter Hykes for TinyCircuits
 * Initiated: 12/26/2019 
 * Updated: 01/05/2021

#include <Wire.h>
#include <SPI.h>
#include <Wireling.h>
#include <ATtiny25.h>      // For ATtiny25 sensor

// Make compatible with all TinyCircuits processors
#if defined(ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB

/* * * * * * MOISTURE SENSOR * * * * * * */
#define MOISTURE_PORT 0 
ATtiny25 moisture_sensor;

void setup() {

void loop() {
  SerialMonitorInterface.print("M: ");
  SerialMonitorInterface.print("\tT: ");

To get some varied readings from the sensor, you can hold your finger across the sensor to simulate moist soil.

Moisture and Temperature values displayed on Serial Monitor

If the values seem off to your application, you can edit the min and max raw sensor reading values in order to get the perfect scale for your project using these lines at the top of the program:

#define MIN_CAP_READ 710 /* Toggle this to raw minimum value */
#define MAX_CAP_READ 975 /* Toggle this to raw maximum value */

Contact Us

If you have any questions or feedback, feel free to email us at or make a post on the forum.

Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!

Thanks for making with us!


Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!