I'm trying to setup a set of sensors on my Arduino board to monitor soil and light conditions for a garden. I'm using Firmata to control the Arduino from Ruby, so on the Arduino UNO board itself, I just have the Standard Firmata sketch uploaded.
Both my sensors seem to read 0 for some amount of time before they'll read settings that make sense. The time varies; sometimes they'll read 0 for a few seconds, sometimes a minute and sometimes they'll never read anything but 0.
The Ruby code is:
require 'arduino_firmata'
arduino = ArduinoFirmata.connect '/dev/ttyACM0'
puts "Arduino Version: #{arduino.version}
while true do
puts "Moisture: #{arduino.analog_read 0}"
puts "Light: #{arduino.analog_read 1}"
sleep 1
end
The wiring is setup as follows:
Photocell:
|------------------A1
| \----10k------Ground
Photocell |
|
|------------------5v
Moisture:
Galvanized Nail |---------------------A1
\-----10K------Ground
Galvanized Nail |-----------------------5v
Edit
Not sure if this would have any effect, but the Arduino is plugged into a Raspberry Pi which is running the Ruby code. I've also plugged the Arduino into my Macbook Pro to try the readings as well with the same result.