lördag 21 maj 2016

Analog reading of the soil moisture sensor






The other day I bought a Soil moisture sensor from a local shop while waiting for the online store to send me the stuff I recently ordered. Buying it from the physical local store was of course nearly ten times as expensive, but it allowed me to get a little one-on-one time with the thing before I get stared for real with the plant-watering project.
As I want to have analog readings from the plant-pots and flowerbeds,  I am going to let my AdaFruit Feather M0 Adalogger be responsible for communicating with the sensors. This little beauty has six analog ports which should hopefully be enough for my needs. If not, I can always add more boards (or shields with analog ports).


Using my breadboard, I simply connected the analog pin of the Soil moisture sensor's analog-pin to analog port A1 (port 15) on the board. I then connected the ground-pin of the Soil moisture sensor to the ground-port on the board and finally connected the VCC-pin of the Soil moisture sensor to the 3.3V-port on the board.

The sensor is supposed to return a value between 0 and 1024, where the higest value is telling us that no power can be transmitted between the

In the Arduino IDE, I added a small sketch to allow me to read the values of the sensors at given intervals and print these to the serial port. (You can grab the sketch from here).

The value read from the sensor is supposed to be an integer between 0 and 1024.

I made a small sketch that just reads the value from the sensor so that I can validate that I receive 1024 when having the sensor in the air, and 0 when dipping it into water.

Running the sketch while having the sensor in the air gives me the following reading:
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Please note that "15" is the actual pin number that I reference as "A1" in my Sketch. For more pin information for this board, visit this page.   

So, for my sensor, 1018 is extreme dry.

Submerging the sensor into water gives me the following reading:
Pin 15 = 115
Pin 15 = 115
Pin 15 = 114
Pin 15 = 113
Pin 15 = 114
Pin 15 = 114
Pin 15 = 114
Pin 15 = 114
Which tells me that for my sensor, 113 is extreme wet.

So, I updated my Sketch to take this into account by changing the max value to be 1018-113 and to remove 113 from the sampled value when calculating the percentage.

Okay, so with this hopefully correctly done, it was high time  for a real-world test. So I inserted the sensor into the soil of a newly watered tomato-plant of about 50 cm of height in a 15 liters flowerpot.  It gave me the following reading:

Pin 15 = 93.37 %
Pin 15 = 93.70 %
Pin 15 = 93.81 %
Pin 15 = 93.70 %
Pin 15 = 93.92 %
Pin 15 = 93.25 %
Pin 15 = 93.36 %
  After a while it stabilized and reported a reading like
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
So, I think this will be fine for me in my plant-watering project. I was a little annoyed that I could not calibrate the analog reading on the moisture sensors board (it only seem to affect the digital LOW/HIGH setting), but other than that it worked fine. The sensors are a bit on the expensive side, especially as I've read multiple reports warning about that they deteriorate quickly... But building my own sensors seems like such a time sink so I think I will happily pay for them.





onsdag 18 maj 2016

Ardunio 433 Receiver

Yesterday I received my Adafruit Feather M0 logger that I aim to use as sampler of soil moisture in my ongoing plant-watering project.


As I had an extra 433 receiver lying about I decided to try and see if I could read my Nexa doorbell from it.

I quickly put the Arduino board on a breadbox and connected the three jumperwires (ground, 3.3v and data) between the receiver and the board so that data went to the boards port 12.

In order to get the the Ardunio IDE to recognize my Adafruit board I had to follow the steps oulined here, which were quick and easy to go through.

I then uploaded the receiver script written by Peter Mead and Barnaby Gray found on the Arduino playground to my Arduino.

The board happily accepted the program and I fired up the serial monitor of the Arduino IDE to see if I my setup would pickup the signals sent by the doorbell.

With a big smile I saw how the output from the program filled the monitor as I pressed away on the doorbell. The smile fainted however when I moved more than a few centimeters away from the antenna of the receiver and noticed how it stopped picking up signals.

This was however no big surprise as I had the same experience using the Raspberry PI earlier on. In short, the 3.3V that I can use on this board (and earlier on with the Raspberry) was just not enough to get any range with this 433 receiver.

But other than that, my first adventure with an Arduino was a success.

I really enjoyed the simplicity of working with the Arduino and how fast I could go from thought to working prototype without any hassle.

I also enjoyed the slick design of the board I used. I wish there was a 5V version of it so I could go all-in on making a Arduino-based 433-bridge for my otherwise Razberry based home automation system.


I think this board will be perfect for the soil moisture project!

Welcome fellow tinkerer!

Welcome to this litte blog where I will try to keep notes of my tinkering with various gizmos such as Raspberry PI, Arduino and other toys that allows me to participate in the Internet of Things.
Hopefully some of my notes might come in handy for some other lost wanderer in this amazing land of endless possibilities!