Raspberry PI + Moisture Sensor with Python (wiring, code, step-by-step walk-through)

  Переглядів 23,311

Data36 - Online Data Science Courses

Data36 - Online Data Science Courses

День тому

Growing Strawberries with a Raspberry Pi, on autopilot, EP#2
In this episode, I'll start to add the specific hardware that my automated gardener needs. And the first piece will be the moisture sensor.
00:00 Intro
01:15 What’s the best moisture sensor?
02:13 Wiring
03:53 Rasperry PI via command line
05:17 Installing prerequisites (apt-get update, etc.)
06:45 Installing text editors for coding
08:47 Installing moisture sensor packages and libraries
14:39 Testing the moisture sensor code!
15:36 ERROR!!! (No I2C device at address: 0x26)
16:40 It works!
18:14 Let’s try to understand and modify the code!
22:28 Prototyping the water pump logic with a simple if statement
24:37 Conclusion
THE TOOLS I USE IN THIS VIDEO:
- Raspberry Pi 4 (Model B)
- Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor: www.adafruit.com/product/4026
LINKS AND CODE BASE FOR EACH STEP:
STEP #1 - wiring: learn.adafruit.com/adafruit-s...
STEP #2: Prerequisites:
learn.adafruit.com/circuitpyt...
STEP #3: Installing mcedit and Sublime Text:
sudo apt-get update mc
OR
data36.com/sublime-text-data-...
STEP #4 - Python Installation of seesaw Library:
learn.adafruit.com/adafruit-s...
STEP #5 - Enabling I2C, SPI and installing RPI.GPIO + adafruit-blinka:
IMPORTANT! After I’ve recorded this video, Adafruit changed their tutorial, so you EITHER follow their new stuff, here:
learn.adafruit.com/circuitpyt...
OR you follow the stuff in the video by running these lines:
* sudo apt-get install -y python-smbus
* sudo apt-get install -y i2c-tools
* sudi raspi-config
* sudo reboot
* sudo i2cdetect -y 1
* sudi raspi-config
* sudo reboot
* ls /dev/i2c* /dev/spi*
* pip3 install RPI.GPIO
* pip3 install adafruit-blinka
STEP #6 - Testing Blinka:
learn.adafruit.com/circuitpyt...
STEP #7 - Actually installating the seesaw Library:
learn.adafruit.com/adafruit-s...
STEP #8 - Using the moisture sensor code:
learn.adafruit.com/adafruit-s...
STEP #9 - The modified version of the script that I used at the end of the video:
github.com/tomimester/automat...
OTHER LINKS MENTIONED IN THE EPISODE:
- Newsletter: data36.com/newsletter
- Free mini-course: data36.com/how-to-become-a-da...
ALL EPISODES:
• Building an Automated ...
NEXT EPISODE:
• Moisture Sensor Automa...
IMAGE SOURCES:
- COVER: Photo by Isaac Quesada on Unsplash
-------
Check my website: data36.com
Get access to more data science tutorials, join the inner circle: data36.com/inner-circle
Find me on Twitter: / data36_com

КОМЕНТАРІ: 32
@kong_7692
@kong_7692 3 роки тому
Awesome project! I have a similar project but it deals with farming and other stuff but really similar! Very informative!
@datatomi
@datatomi 3 роки тому
Thanks and good luck with your project! What's your stack?
@ComputerScienceSimplified
@ComputerScienceSimplified 3 роки тому
Awesome video, keep up the amazing work! :)
@datatomi
@datatomi 3 роки тому
Thanks a lot!
@ecocarlisle
@ecocarlisle Рік тому
This video was exactly what I was looking for. I have a Raspberry PI PICO...will that work too?
@aminedahane5874
@aminedahane5874 2 місяці тому
Good job
@Retr0Plus
@Retr0Plus 2 роки тому
The adafruit sensor seems to be the worst one compared to other capacitive sensors Seems to give out random numbers no matter the moisture level. They have mentioned on their website that the value range is between 200 to 2000 but I get 1016 at max while touching the sensor and 320 minimum when it's in the air. They have mentioned on their shop that they have updated the firmware and am guessing they mean the firmware of the chip and not the seesaw library. Any ideas on how to fix without reprogramming the chip? Just bringing my hand closer to the sensor seems to raise the output value.
@aureliomesquita4154
@aureliomesquita4154 21 день тому
Is there a way to convert the moisture level to percentage?
@ireleezi3887
@ireleezi3887 Рік тому
I had the wiring identical to the video but when testing the code at the end I got an error saying it was incorrect and the addresses weren't right. Is there something I forgot to do?
@ThirstyThursten
@ThirstyThursten 3 роки тому
Awesome I was actually looking for such a project for my backyard! Combine it with a raincollector bin and more sensors, let the garden be watered automaticly and the pump in the collector bin stop before it runs dry (or when a certain soil moisture level is reached!) However this will be a great start point to learn the basics andtest on a smaller scale! When can we expect the next part and the actual connection of an electrical RasPi powered and controlled pump? 😁
@datatomi
@datatomi 3 роки тому
Awesome!! And the waterpump just arrived so I'll test it out and the video about it comes in the next few weeks. (I'll create one in the meantime about the automation and logging process on the PI.)
@ThirstyThursten
@ThirstyThursten 3 роки тому
@@datatomi Awesome man! Can't wait! :D Darnit I was just looking into getting the Adafruit Soil Senser you have, but in The Netherlands it's rather hard to get one.. Are you in the US? Or somewhere closer to Europe? If so do you have a tip for an online store? :D
@datatomi
@datatomi 3 роки тому
@@ThirstyThursten I'm in Hungary right now, and I've actually ordered this from a local partner of Adafruit. If there's no local partner in The Netherlands that means that YOU can become the local partner. ;-) #niche
@opiritetariah
@opiritetariah 2 роки тому
Pls what about for capacitive moisture sensors with 3 pins (not 4 pins like yours)
@ApolloLax
@ApolloLax 11 місяців тому
I may have missed something, which raspberry pi model are you using?
@erickreyes9820
@erickreyes9820 3 роки тому
Hello Tomi, Nice video!! I'm currently looking at different sensors and I saw that for some capacitive sensors I needed an analog to current converter. I see that you just plugged in this Adafruit sensor and it seems to work without any extra components (like the adc), let me know if I am correct or missing something, thank you!
@datatomi
@datatomi 3 роки тому
yes, exactly, I just plugged it in and it worked without any additional hardware needed (Note: I'm testing another sensor this week, I'll let you know if it's any better or worse -- but so far I'm very happy with the Adafruit one.)
@brunosandres
@brunosandres 3 роки тому
Nice job! Do you know if this would work on a Raspberry Pi 3? I would like to use it and also a wather pump, light sensor and a light bulb as a post-secondary school project. Keep running!
@datatomi
@datatomi 3 роки тому
Thanks, I don't know that for sure (as I haven't tested this with a PI3) but as far as I know, this should be pretty much the same on 3 as on 4. (Water pump, light bulb, etc vids are coming soon, too! ;-))
@brunosandres
@brunosandres 3 роки тому
@@datatomi Köszönöm!
@patrickpuentelml4958
@patrickpuentelml4958 2 роки тому
Could you make a video programming a resistive moisture sensor using Raspberry pi? I'm currently fighting with the sensor hw080 and i have a lot of problems. HElP ME PLEASE!
@Obzrve
@Obzrve 4 місяці тому
Can you save the data as a csv file
@thisissayansaha
@thisissayansaha 2 роки тому
Thanks
@datatomi
@datatomi 2 роки тому
cheers!
@imrevarga8968
@imrevarga8968 2 роки тому
Hi, I have a 200+ outside Japanese maple tree collection. I would like to monitor the moisture levels of these trees by having 8-10 moisture meters that are distributed evenly in the backyard.All of the trees are in pots and most of them are on plant shelves. Can I monitor 8-10 moisture meters with a Raspberry pi.
@datatomi
@datatomi 2 роки тому
I think you can, but unfortunately I have no experience with that. I guess it must be some series circuit solution... But again I haven't tried it. Also, my first instinct that it's an unconventional solution and might be better to go with a wifi/bluetooth-based microcontroller network. (e.g. md5) I have no experience with that either... But I hope that I gave some ideas what to Google for. : ))
@bryanannas
@bryanannas 2 роки тому
Cmon, VI is essential! On everything!
@mediacoregroupph
@mediacoregroupph 3 роки тому
Can you add multiple sensors on one pi¥?
@datatomi
@datatomi 3 роки тому
yes, I've just tested it -- I'll create a video about it.
@YodaWasSith
@YodaWasSith 3 роки тому
For anyone who needs this: The Arduino Seesaw library is bugged. Version 1.4 has messed up the capacitance reader library, and so it only reads temperature. The fix is to downgrade straight from within the IDE to 1.3.1, at least until this issue is resolved.
@datatomi
@datatomi 3 роки тому
Thanks for the update!
@StillDontGiveAFuck94
@StillDontGiveAFuck94 2 роки тому
I have the same problem on raspberry pi. Can you help me to downgrade the seesaw?
Moisture Sensor Automation and Accuracy Quick-Fix (Raspberry Pi autogardener project ep#3)
24:49
Data36 - Online Data Science Courses
Переглядів 2,5 тис.
Automatic Garden Watering System
15:28
Nikodem Bartnik
Переглядів 193 тис.
格斗裁判暴力执法!#fighting #shorts
00:15
武林之巅
Переглядів 7 млн
ШАХТАР - ДИНАМО. КОМЕНТУВАННЯ. УПЛ. 28 ТУР
4:04:31
Raspberry Pi Automation #1: Mains Relay HAT
15:03
ExplainingComputers
Переглядів 270 тис.
Raspberry Pi Plant Watering (& Time Lapse)
23:41
ExplainingComputers
Переглядів 323 тис.
I Can Save You Money! - Raspberry Pi Alternatives
15:04
Linus Tech Tips
Переглядів 3,2 млн
the Raspberry Pi 5
17:57
NetworkChuck
Переглядів 1 млн
Preventing Plant Death With Technology
14:00
Emilostuff
Переглядів 122 тис.
Kapazitiver Bodenfeuchtesensor, einfach erklärt! | #EdisTechlab
7:35
Edi's Techlab
Переглядів 19 тис.
Soil Moisture Sensor (Raspberry Pi)
7:01
PiddlerInTheRoot
Переглядів 95 тис.
📱 SAMSUNG, ЧТО С ЛИЦОМ? 🤡
0:46
Яблочный Маньяк
Переглядів 615 тис.
Вы поможете украсть ваш iPhone
0:56
Romancev768
Переглядів 385 тис.
How Neuralink Works 🧠
0:28
Zack D. Films
Переглядів 26 млн
Why spend $10.000 on a flashlight when these are $200🗿
0:12
NIGHTOPERATOR
Переглядів 17 млн
3D printed Nintendo Switch Game Carousel
0:14
Bambu Lab
Переглядів 812 тис.
iPhone 17 Slim - НЕ ОНОВЛЮЙ iPhone в 2024 | Новини Тижня
31:12
Канал Лучкова
Переглядів 35 тис.