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

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 พ.ค. 2024
  • 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

  • @ComputerScienceSimplified
    @ComputerScienceSimplified 3 ปีที่แล้ว +1

    Awesome video, keep up the amazing work! :)

    • @datatomi
      @datatomi  3 ปีที่แล้ว

      Thanks a lot!

  • @kong_7692
    @kong_7692 3 ปีที่แล้ว +2

    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?

  • @ecocarlisle
    @ecocarlisle ปีที่แล้ว +1

    This video was exactly what I was looking for. I have a Raspberry PI PICO...will that work too?

  • @aminedahane5874
    @aminedahane5874 2 หลายเดือนก่อน

    Good job

  • @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?

  • @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 หลายเดือนก่อน

    Is there a way to convert the moisture level to percentage?

  • @thisissayansaha
    @thisissayansaha 2 ปีที่แล้ว +1

    Thanks

  • @opiritetariah
    @opiritetariah 2 ปีที่แล้ว

    Pls what about for capacitive moisture sensors with 3 pins (not 4 pins like yours)

  • @ThirstyThursten
    @ThirstyThursten 3 ปีที่แล้ว +2

    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

  • @ApolloLax
    @ApolloLax ปีที่แล้ว

    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.)

  • @bryanannas
    @bryanannas 3 ปีที่แล้ว +1

    Cmon, VI is essential! On everything!

  • @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!

  • @imrevarga8968
    @imrevarga8968 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      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. : ))

  • @Obzrve
    @Obzrve 5 หลายเดือนก่อน

    Can you save the data as a csv file

  • @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 ปีที่แล้ว +1

      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!

  • @YodaWasSith
    @YodaWasSith 3 ปีที่แล้ว +1

    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 3 ปีที่แล้ว

      I have the same problem on raspberry pi. Can you help me to downgrade the seesaw?

  • @mediacoregroupph
    @mediacoregroupph 3 ปีที่แล้ว +1

    Can you add multiple sensors on one pi¥?

    • @datatomi
      @datatomi  3 ปีที่แล้ว

      yes, I've just tested it -- I'll create a video about it.