Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. How can I control a servo with Mysensors? Automatic cat feeder
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

How can I control a servo with Mysensors? Automatic cat feeder

Scheduled Pinned Locked Moved General Discussion
13 Posts 7 Posters 5.4k Views 7 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chuckconnors
    wrote on last edited by
    #1

    Hey guys. Our cat is our alarm clock and I'm trying to solve that. Every morning she demands to be fed around 6am weekends included. My goal is to fix that problem with an automatic cat feeder.

    I'm trying to figure out a way to control a little microservo that I want to use to trigger a springloaded hinged door. The servo gets power and moves 90 degrees. When this happens the door springs open and the cat can get the food.

    I've written the bit that moves the servo to open and also back to closed position. I need to trigger these actions using MySensors. I'm guessing the best way is to use the relay sketch, but I'm at a loss as to how to modify it. I'm not a programmer so the coding for this sketch is a little foreign to me.

    Can someone explain how the relay sketch can be modified? I would like it to run the 'open door with servo' portion when the relay would be energized, and the 'close door with servo' portion when the relay would be idle.

    Any help is greatly appreciated. In fact, our whole household thanks you for helping us sleep in!!

    1 Reply Last reply
    3
    • mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      It should just be a matter of changing

      digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
      

      in the relay sketch to

      if (message.getBool()){
          open_door_with_servo();
      } else {
          close_door_with_servo();
      }
      

      assuming the code you have written are inside the open/close_door_with_servo functions.

      1 Reply Last reply
      0
      • hekH Online
        hekH Online
        hek
        Admin
        wrote on last edited by
        #3

        Haha, a youtube clip is mandatory when you finish this project.

        1 Reply Last reply
        2
        • m26872M Offline
          m26872M Offline
          m26872
          Hardware Contributor
          wrote on last edited by m26872
          #4

          This reminds me of my very first arduino project 8 years ago. A vandal(cat)- and smell-proof steel box able to serve 8 individual meals for two cats simultaneously at separate places. I had two cats, one small, sick and in need special food. The other one fat, mean and always stealing the other ones food. She could also break in to everything once she felt the smell of food.

          The cats are not around any more, but the machine is still kept and working I suppose. I should probably MySensorize it...

          Edit, On topic: I've never used servos, so can't help there. Sorry.

          1 Reply Last reply
          1
          • BartEB Offline
            BartEB Offline
            BartE
            Contest Winner
            wrote on last edited by BartE
            #5

            @chuckconnors funny project!

            Arduino has a servo library take a look here

            Your sketch can be the relay sketch like mfalkvidd says (use pin 6 i.s.o. 9 because 9 is used by the radio)

            Servo myservo;  // create servo object to control a servo
            
            void setup()  {
               ...
               myservo.attach(6);  // attaches the servo on pin 6 to the servo object
               ...
            }
            

            And in the message handler

            if (message.getBool()){
                // Open door 90 degrees
                myservo.write(90);
            } else {
                // Close door 0 degrees
                myservo.write(0);
            }
            
            1 Reply Last reply
            2
            • sundberg84S Offline
              sundberg84S Offline
              sundberg84
              Hardware Contributor
              wrote on last edited by
              #6

              I saw this on youtube some years ago: https://www.youtube.com/watch?v=8uTz10jGBFk
              Its based on rfid cat necklases... nice links in the videos as well.

              Controller: Proxmox VM - Home Assistant
              MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
              MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
              RFLink GW - Arduino Mega + RFLink Shield, 433mhz

              1 Reply Last reply
              0
              • C Offline
                C Offline
                chuckconnors
                wrote on last edited by
                #7

                @mfalkvidd thanks for the help. That's definitely what I needed to know!

                I've gotten the 1.0 version working but my range from the gateway is an issue I'm trying to resolve. For now it's basically a spring loaded (rubber band actually) cardboard box but it does work. I'm planning on building a version out of wood once I get some some time.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  chuckconnors
                  wrote on last edited by
                  #8

                  Here's the cardboard prototype proof-of-concept video:

                  Youtube video

                  1 Reply Last reply
                  2
                  • sundberg84S Offline
                    sundberg84S Offline
                    sundberg84
                    Hardware Contributor
                    wrote on last edited by
                    #9

                    If you are going to make the solid version that fast - have a sensor to make sure the cat doesnt stand on the lid. I pictured myself a cat going through the room when the lid was opened that fast :grinning:

                    Nice work!

                    Controller: Proxmox VM - Home Assistant
                    MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                    MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                    RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      chuckconnors
                      wrote on last edited by
                      #10

                      Good point. I've got a feeling that the rubber bands won't last. I also had to add a weight to keep the box from tipping over.

                      I may just go with something similar to what @sundberg84 posted. This should buy me a few weekends of rest before it starts failing but now I know I can come up with something to solve the problem.

                      1 Reply Last reply
                      0
                      • m26872M Offline
                        m26872M Offline
                        m26872
                        Hardware Contributor
                        wrote on last edited by
                        #11

                        Cats are smart. It will hear when the servo starts miles away and stand right next to the bowl before its open, know exactly what to expect and where to stand (and not). The only chance to scare it or make it fly is the very first time.

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          chuckconnors
                          wrote on last edited by
                          #12

                          I'm thinking of building the final device using a spring loaded hinge that is normally used to keep doors closed. I see that some can be adjusted to slow the opening speed. This would be helpful in keeping the box from opening too fast.

                          I think a solenoid would be a better fit for this project than the servo but I know nothing about them. The idea would be that the solenoid would hold the lid closed but retract when power is supplied and the pin would allow the box to open using the power of the hinges. Can anyone make a suggestion for a low cost DC server? All the ones I'm seeing have very little movement (1mm - 5mm). I'd think I'd want something closer to 0.5" .

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            Club Finland
                            wrote on last edited by sundberg84
                            #13

                            Wow, the comments are so old. Hope I didn't bother you guys. Now, I think it would be much better for us to get ourselves an automatic feeder. It would be much more convenient for us to feed our cats this way. Not to mention, you can control the diet and amount of food intake. If your cats have diabetes or similar conditions, getting an automatic feeder will help to improve their health a lot. You check all the important -Removed by moderator- before buying it too. Cheers.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            14

                            Online

                            11.7k

                            Users

                            11.2k

                            Topics

                            113.0k

                            Posts


                            Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • OpenHardware.io
                            • Categories
                            • Recent
                            • Tags
                            • Popular