Skip to the content
PCBKitNew board
2 layers100 × 150 mmI2c moist sensor pannel, the printed circuit board in 3D

I2c moist sensor pannel

Miceuz/i2c-moisture-sensor258

I2C based soil moisture sensor

Size
100 × 150 mm
Copper layers
2
Thickness
1.6 mm
Parts
140
Nets
16
Pads
330
Tracks, vias
1,708, 804
Pours
25
Routed
Yes
KiCad
KiCad 5 (file 20170123)
Created
16 Jun 2015
Updated
25 Feb 2023

Overview

I2c moist sensor pannel is an open-source printed circuit board by Miceuz, from the Miceuz/i2c-moisture-sensor repository on GitHub, published under the Apache-2.0 licence. It is a 2-layer board of 100 × 150 mm with 140 parts on 16 nets, routed with 1,708 tracks and 804 vias.

It is built around the ATTINY441-SSU, BAT54 and NCP18XH103F03RB. Its parts include 40 resistors, 30 capacitors, 15 diodes, 5 ICs and 5 connectors. It belongs with the sensors and measurement boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

3

README

README.md

i2c-moisture-sensor

I2C based soil moisture sensor. A continuation of the Chirp - plant watering alarm project. There is also an RS485 and an analog version available.

I2C protocol

Available registers for reading and writing.

NameRegisterR/WData length
GET_CAPACITANCE0x00(r)2
SET_ADDRESS0x01(w)1
GET_ADDRESS0x02(r)1
MEASURE_LIGHT0x03(w)0
GET_LIGHT0x04(r)2
GET_TEMPERATURE0x05(r)2
RESET0x06(w)0
GET_VERSION0x07(r)1
SLEEP0x08(w)0
GET_BUSY0x09(r)1

GET_BUSY returns 1 if any measurement is in progress, 0 otherwise.

How to interpret the readings

16bit values are returned most significant byte first.

Both light and moisture sensors give relative values. Meaning, more moisture will give you higher reading, more light, lower reading. They are not calibrated to any particular si units - this is up to you.

Moisture is somewhat linear. I test all sensors before shipping and they give about 290 - 310 in free air at 5V supply.

Temperature is in Celsius, value is in tenths of degrees Celsius. I.e. value 252 would mean 25.2°C.

I didn't measure linearity of the light sensor, it gives 65535 in a dark room away form desk lamp. When it's dark, it takes longer to measure light, reading the light register while measurement is in progress will return the previous reading. Be aware, light sensor is pretty noisy.

Temperature is measured by the thermistor on the body of the sensor. Calculated absolute measurement accuracy is better than 2%.

Note Upon reading the moisture or temperature value, a value form the previous read command is returned and the new measurement is started. If you do rare measurements and want to act instantly, do two consecutive readings to get the most up to date data. Also you can read GET_BUSY register via i2c - it will indicate when the measurement is done. Basically the process goes like this: read from GET_CAPACITANCE, discard results, then read from GET_BUSY until you get '0' as an answer, then read form GET_CAPACITANCE again - the returned value is the soil moisture NOW.

Python library for Raspberry Pi

NOTE: if you experience problems on Raspberry Pi 3, slow down I2C bus speed by adding this line to /boot/config.txt: dtparam=i2c1_baudrate=30000

Göran Lundberg has released a Python library for Raspberry Pi: https://github.com/ageir/chirp-rpi It has a very comprehensive documentation and covers a lot of functionality.

Some features:

  • Uses a trigger function to trigger all enabled sensors. User selectable.
  • Get soil moisture in percent (requires calibration) or capacitance value.
  • Several temperature scales to choose from. Celcius, Fahrenheit and Kelvin.
  • Offset to calibrate the temperature sensor.
  • Measurement timestamps for all on board sensors.
  • Built in support for changing the I2C address of the sensor.
  • Deep sleep mode to conserve power.
  • Calibration tool for soil moisture.

Raspberry Pi examples

This is interface class provided by Daniel Tamm and Jasper Wallace

python
#!/usr/bin/python
# cannot use python3 because smbus not working there
# Modified script from https://github.com/JasperWallace/chirp-graphite/blob/master/chirp.py
# by DanielTamm

import smbus, time, sys

class Chirp:
	def __init__(self, bus=1, address=0x20):
		self.bus_num = bus
		self.bus = smbus.SMBus(bus)
		self.address = address
    
	def get_reg(self, reg):
		# read 2 bytes from register
		val = self.bus.read_word_data(self.address, reg)
		# return swapped bytes (they come in wrong order)
		return (val >> 8) + ((val & 0xFF) << 8)

	def reset(self):
		# To reset the sensor, write 6 to the device I2C address
		self.bus.write_byte(self.address, 6)

	def set_addr(self, new_addr):

This is another RasPi example provided by user krikk

python
#!/usr/bin/python

#https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/master/Adafruit_I2C
from Adafruit_I2C import Adafruit_I2C
from time import sleep, strftime
from datetime import datetime
deviceAddr = 0x20

i2c = Adafruit_I2C( deviceAddr, -1, False )

#to change adress
#i2c.write8( 1, 0x22 )

#reset sensor, we need this otherwise i get inconsistent light reading in the dark...
i2c.write8( deviceAddr, 0x06 )
sleep(5)

i2c.write8(deviceAddr, 3)
sleep(3)
light = i2c.readU16(4, False)
temp = i2c.readS16(5, False)/float(10)
moisture = i2c.readU16(0, False)
print "Temperature\tMoisture\tBrightness"
print str(temp) + ":" + str(moisture) + ":" + str(light)

Arduino library

Ingo Fischer has written an Arduino library for the sensor, it has a couple of ready made examples: https://github.com/Apollon77/I2CSoilMoistureSensor

Below are old examples for bare-bones Arduino illustrating a basic I2C use.

Arduino example

arduino
#include <Wire.h>

void writeI2CRegister8bit(int addr, int value) {
  Wire.beginTransmission(addr);
  Wire.write(value);
  Wire.endTransmission();
}

unsigned int readI2CRegister16bit(int addr, int reg) {
  Wire.beginTransmission(addr);
  Wire.write(reg);
  Wire.endTransmission();
  delay(20);
  Wire.requestFrom(addr, 2);
  unsigned int t = Wire.read() << 8;
  t = t | Wire.read();
  return t;
}

void setup() {
  Wire.begin();
  Serial.begin(9600);
  writeI2CRegister8bit(0x20, 6); //reset
}

Note for ESP8266 based systems

In some cases the default ESP8266 Arduino I2C library has the clock stretching timeout set too low. If you experience intermittent communication, add this to your code:

text
Wire.setClockStretchLimit(2500)

Micropython

Micropython library is available here: https://github.com/scopelemanuele/pyChirpLib

Address change example

By default the sensor comes with 0x20 set as an address, this is an example on how to change address for indivitual sensor:

arduino
#include <Wire.h>
 
void writeI2CRegister8bit(int addr, int reg, int value) {
  Wire.beginTransmission(addr);
  Wire.write(reg);
  Wire.write(value);
  Wire.endTransmission();
}
 
void writeI2CRegister8bit(int addr, int value) {
  Wire.beginTransmission(addr);
  Wire.write(value);
  Wire.endTransmission();
}
 
void setup() {
  Wire.begin();
  Serial.begin(9600);
                                       //talking to the default address 0x20
  writeI2CRegister8bit(0x20, 1, 0x21); //change address to 0x21
  writeI2CRegister8bit(0x20, 6);       //reset
  delay(1000);                         //give it some time to boot
}
 

Particle Photon

There is a great tutorial by Miriam Cox for Particle Photon boards. Also there is a library available by Mike.

Links and mentions

Parts

140
QtyValueFootprintReferences
201MResistors_SMD:R_0603R5, R5, R5, R5, R5, R6, R6, R6, R6, R6, R7, R7, R7, R7, R7, R8 +4
101nCapacitors_SMD:C_0603C4, C4, C4, C4, C4, C5, C5, C5, C5, C5
101uCapacitors_SMD:C_0603C3, C3, C3, C3, C3, C6, C6, C6, C6, C6
10330Resistors_SMD:R_0603R4, R4, R4, R4, R4, R9, R9, R9, R9, R9
10BAT54SMD_Packages:SOD-523D1, D1, D1, D1, D1, D2, D2, D2, D2, D2
818pCapacitors_SMD:C_0603C1, C1, C1, C1, C2, C2, C2, C2
510kResistors_SMD:R_0603R1, R1, R1, R1, R1
510k 0.1%Resistors_SMD:R_0603R2, R2, R2, R2, R2
516MHzCrystals:Crystal_HC49-SD_SMDX1, X1, X1, X1, X1
5ATTINY441-SSUHousings_SOIC:SOIC-14_3.9x8.7mm_Pitch1.27mmIC1, IC1, IC1, IC1, IC1
5CONN_02X03Pin_Headers:Pin_Header_Straight_2x03P1, P1, P1, P1, P1
5LEDLEDs:LED-0603D3, D3, D3, D3, D3
5LOGOw_logo:Logo_silk_OSHW_6x6mmG***, G***, G***, G***, G***
5LOGOchirp_logo:ziogasG***, G***, G***, G***, G***
5NCP18XH103F03RBResistors_SMD:R_0603TH1, TH1, TH1, TH1, TH1
5Val**w_pin_strip:pin_socket_4PIN_SOCKET_4, PIN_SOCKET_4, PIN_SOCKET_4, PIN_SOCKET_4, PIN_SOCKET_4
133pCapacitors_SMD:C_0603C1
133ppCapacitors_SMD:C_0603C2

The 120 most common of 140 parts.

Questions

How big is the I2c moist sensor pannel PCB?

It measures 100 × 150 mm and has 2 copper layers, 1.6 mm thick.

What parts does the I2c moist sensor pannel use?

140 parts, built around the ATTINY441-SSU, BAT54 and NCP18XH103F03RB. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the I2c moist sensor pannel KiCad files?

From the Miceuz/i2c-moisture-sensor repository on GitHub, at the commit this page was made from: the board is i2c-moist-sensor-pannel.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the I2c moist sensor pannel design in my own project?

Its repository publishes it under the Apache-2.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

Similar boards

  • 2 layers100 × 149.5 mmRs485-moist sensor pannel, the printed circuit board in 3D

    Rs485-moist sensor pannel

    Miceuz/rs485-moist-sensor

    Digital (RS485 - based) soil moisture and temperature sensor

    170 parts74Apache-2.0
  • 2 layers64.1 × 123.2 mmPokeball, the printed circuit board in 3D

    Pokeball

    Michael-Beutling/pokeball-autocatcher

    mod for poke ball to perform auto catch

    156 parts7MIT
  • 2 layers50.8 × 50.8 mmEsp switch, the printed circuit board in 3D

    Esp switch

    foxel/esp-dual-rf-switch

    LightFox Dual: esp8266 WiFi+RF dual channel switch

    29 parts6
  • 2 layers24.1 × 26.7 mmRf24 tiny44, the printed circuit board in 3D

    Rf24 tiny44

    roberthart56/projects

    rob's projects and log

    10 parts3
  • 2 layers25.2 × 60.5 mmRs485-breakout, the printed circuit board in 3D

    Rs485-breakout

    Miceuz/rs485-breakout

    A tiny development board to quickly prototype RS485/Modbus devices

    33 parts2Apache-2.0
  • 2 layers153 × 123 mmSolar lantern, the printed circuit board in 3D

    Solar lantern

    Miceuz/SolarCampingLentern

    Solar powered camping lantern

    65 parts1