いよいよ水分センサ。
コードはそのまま使います。(まずは準備)
————————-
Python sample code getting from Web
$ git clone git://gist.github.com/3151375.git
you find new directory “3151375”
In i tyou find python sample code “adafruit_mcp3008.py”
I will use this code itself.
before that, I need set up other package and so on.
Necessary Packages
$ sudo apt-get update
$ sudo apt-get install python-dev
Next, Install the latest RPi.GPIO module. We will use easy_install to manage the python packages.
$ sudo apt-get install python-setuptools
$ sudo easy_install rpi.gpio
Connect between RaspberryPi and this mousture curcuit.
Let’s get started!
$ cd 3151375
$ sudo python adafruit_mcp3008.py
————————-
結果は、
(1)taniku-pot-mad 355
(2)ko-cyou-ran case 422
(3)water case 501
(4)dry case 0
(5)shida-tree case 152
測定周期やMySQL保存はこの次に。
はたして・・・
まずは、配線完了!!
(1)まずは、多肉植物、から。。
=============
taniku-pot-mad case
————-
pi@raspberrypi20170226:~/3151375 $ sudo python adafruit_mcp3008.py
adafruit_mcp3008.py:56: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPIMOSI, GPIO.OUT)
adafruit_mcp3008.py:58: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICLK, GPIO.OUT)
adafruit_mcp3008.py:59: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICS, GPIO.OUT)
trim_pot: 349
pot_adjust: 349
last_read 0
trim_pot_changed True
Volume = 34%
set_volume 34
tri_pot_changed 34
trim_pot: 356
pot_adjust: 7
last_read 349
trim_pot_changed True
Volume = 35%
set_volume 35
tri_pot_changed 35
trim_pot: 354
pot_adjust: 2
last_read 356
trim_pot_changed False
trim_pot: 355
pot_adjust: 1
last_read 356
trim_pot_changed False
trim_pot: 356
pot_adjust: 0
last_read 356
trim_pot_changed False
trim_pot: 356
pot_adjust: 0
last_read 356
trim_pot_changed False
trim_pot: 356
pot_adjust: 0
last_read 356
trim_pot_changed False
trim_pot: 354
pot_adjust: 2
last_read 356
trim_pot_changed False
^CTraceback (most recent call last):
File “adafruit_mcp3008.py”, line 105, in <module>
time.sleep(0.5)
KeyboardInterrupt
(2)次は、胡蝶蘭
=============
ko-cyou-ran case
————-
pi@raspberrypi20170226:~/3151375 $ sudo python adafruit_mcp3008.py
adafruit_mcp3008.py:56: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPIMOSI, GPIO.OUT)
adafruit_mcp3008.py:58: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICLK, GPIO.OUT)
adafruit_mcp3008.py:59: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICS, GPIO.OUT)
trim_pot: 422
pot_adjust: 422
last_read 0
trim_pot_changed True
Volume = 41%
set_volume 41
tri_pot_changed 41
trim_pot: 427
pot_adjust: 5
last_read 422
trim_pot_changed False
trim_pot: 425
pot_adjust: 3
last_read 422
trim_pot_changed False
trim_pot: 424
pot_adjust: 2
last_read 422
trim_pot_changed False
trim_pot: 424
pot_adjust: 2
last_read 422
trim_pot_changed False
trim_pot: 424
pot_adjust: 2
last_read 422
trim_pot_changed False
trim_pot: 425
pot_adjust: 3
last_read 422
trim_pot_changed False
trim_pot: 426
pot_adjust: 4
last_read 422
trim_pot_changed False
^CTraceback (most recent call last):
File “adafruit_mcp3008.py”, line 105, in <module>
time.sleep(0.5)
KeyboardInterrupt
(3)次は、水だけ(水100%)
=============
water case
————-
pi@raspberrypi20170226:~/3151375 $ sudo python adafruit_mcp3008.py
adafruit_mcp3008.py:56: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPIMOSI, GPIO.OUT)
adafruit_mcp3008.py:58: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICLK, GPIO.OUT)
adafruit_mcp3008.py:59: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICS, GPIO.OUT)
trim_pot: 501
pot_adjust: 501
last_read 0
trim_pot_changed True
Volume = 49%
set_volume 49
tri_pot_changed 49
trim_pot: 501
pot_adjust: 0
last_read 501
trim_pot_changed False
trim_pot: 503
pot_adjust: 2
last_read 501
trim_pot_changed False
trim_pot: 503
pot_adjust: 2
last_read 501
trim_pot_changed False
trim_pot: 503
pot_adjust: 2
last_read 501
trim_pot_changed False
trim_pot: 504
pot_adjust: 3
last_read 501
trim_pot_changed False
trim_pot: 501
pot_adjust: 0
last_read 501
trim_pot_changed False
^CTraceback (most recent call last):
File “adafruit_mcp3008.py”, line 105, in <module>
time.sleep(0.5)
KeyboardInterrupt
(4)まったく挿さないのは。。。
=============
dry case
————-
pi@raspberrypi20170226:~/3151375 $ sudo python adafruit_mcp3008.py
adafruit_mcp3008.py:56: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPIMOSI, GPIO.OUT)
adafruit_mcp3008.py:58: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICLK, GPIO.OUT)
adafruit_mcp3008.py:59: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICS, GPIO.OUT)
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
trim_pot: 0
pot_adjust: 0
last_read 0
trim_pot_changed False
^CTraceback (most recent call last):
File “adafruit_mcp3008.py”, line 105, in <module>
time.sleep(0.5)
KeyboardInterrupt
(5)シダ植物は・・・
=============
shida-tree case
————-
pi@raspberrypi20170226:~/3151375 $ sudo python adafruit_mcp3008.py
adafruit_mcp3008.py:56: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPIMOSI, GPIO.OUT)
adafruit_mcp3008.py:58: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICLK, GPIO.OUT)
adafruit_mcp3008.py:59: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICS, GPIO.OUT)
trim_pot: 150
pot_adjust: 150
last_read 0
trim_pot_changed True
Volume = 15%
set_volume 15
tri_pot_changed 15
trim_pot: 151
pot_adjust: 1
last_read 150
trim_pot_changed False
trim_pot: 156
pot_adjust: 6
last_read 150
trim_pot_changed True
Volume = 15%
set_volume 15
tri_pot_changed 15
trim_pot: 154
pot_adjust: 2
last_read 156
trim_pot_changed False
trim_pot: 151
pot_adjust: 5
last_read 156
trim_pot_changed False
trim_pot: 154
pot_adjust: 2
last_read 156
trim_pot_changed False
trim_pot: 152
pot_adjust: 4
last_read 156
trim_pot_changed False
^CTraceback (most recent call last):
File “adafruit_mcp3008.py”, line 105, in <module>
time.sleep(0.5)
KeyboardInterrupt
以上、 さあ、次はカスタマイズ・・・・・・