Soil Moisture Sensor Wireling Python Tutorial
This tutorial will show you how to acquire moisture readings from the Soil Moisture Sensor Wireling.
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.
- 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
- 300µA (Active Mode)
- 0.1µA (Power-down Mode)
- 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!
- Raspberry Pi and any other cables you'll need!
- Wireling Pi Hat
- (1) Wireling Cable
- Soil Moisture Wireling
- Python 3 (Python 2 is not supported!)
- All Python packages mentioned in the Pi Hat setup tutorial (tinycircuits-wireling, Adafruit-Blinka, adafruit-circuitpython-ads1x15, and adafruit-circuitpython-busdevice)
- ATtiny Python Package
- Soil Moisture Example Python
Plug your Wireling into the port you plan on using! The default in the included program is port 0.
If you want to use a different port, you just need to change the port value in the program mentioned later.
Install the necessary Python package:
pip3 install tinycircuits-attiny25
Then you can download (above under Software) the Soil Moisture Sensor Wireling example:
# Soil Moisture Sensor Wireling Example # This example will read the print out the moisture and temperature # Written by: Laverena Wienclaw for TinyCircuits import tinycircuits_wireling import time import tinycircuits_attiny25 wireling = tinycircuits_wireling.Wireling() wireling.selectPort(0) attiny25 = tinycircuits_attiny25.ATtiny25() while True: attiny25.readMoisture() attiny25.readTemp() print("Moisture: %.2f" % attiny25.moisture) print("Temp DegC: %.2f" % attiny25.temp) time.sleep(0.5)
Navigate in the terminal to the directory with the file parent to the examples folder and run:
The program will print the moisture levels on a scale of 0-100%, and the temperature in degrees Celsius:
Moisture: 87.92 Temp DegC: 28.00 Moisture: 92.83 Temp DegC: 29.32
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!