Introduction: Beginner : Learn IOT With a Cool Fish Feeder

This project is more about a guide to starting with a small low budget IOT device and what all u can do with it.

  • What is IOT?
    • Got from Google: IoT is short for Internet of Things. The Internet of Things refers to the ever-growing network of physical objects that feature an IP address for internet connectivity, and the communication that occurs between these objects and other Internet-enabled devices and systems.
    • Got after working with it: To do crazy stuff because you can monitor/control the stuff over the internet.
  • How are IoT devices connected?
    • Got from Google: The connection to your ISP could by via ADSL or Ethernet using a fibre service for example. When the home router connects to the ISP it will be assigned an IP address which is what is used to communicate with servers or other services on the Internet. This is a public IP address and is addressable by the internet.
    • Got after working with it: JUST CONNECT TO MY WIFI AND YOUR DEVICE IS UP.
  • Future of IOT?
    • The Internet of Things (IoT) is the use of network sensors in physical devices to allow for remote monitoring and control. This technology has gained massive traction in various spheres like healthcare, banking, retail, manufacturing, consumer goods, etc.

Simply endless.

So let get started.

Step 1: Why Fish Feeder

I started my journey of writing Instructables 1 year back, because of the need of making a fish feeder.

I had to go on a vacation and I need to make sure that my fish won't die during my absence.

So with whatever trash stuff, I have made a simple fish feeder which drops food at a set interval using a servo motor. Believe me, my fish survived a (half month) of my vacation.

But what I felt is I lost that human touch of feeding my pet. I really started missing it. So I came with this idea to feed them by controlling the device over some means where I need human(my) interaction. So IOT looked promising and being over the internet you can able to control it like a cham. That's all about this project and why I did it.

Step 2: Prerequisite

  • Basic ESP-01 code uploading knowledge.
  • Basic Arduino IDE knowledge.
  • Basic of pin-out knowledge for ESP-01 and Arduino mini pro.
  • Basic knowledge of using thingspeak

If you don't have prior knowledge, please search these stuff in Inscrutable you will get plenty of link to get started.
There are plenty of ESP8266 example are there by default please go though them.Upload into the chip play around with it, that is how we will learn and achieve knowledge.

Step 3: What We Are Going to Learn

  • We will be using ESP-01 as our IOT device
  • It gives us two IO pins.
  • We are going to do 2 small projects here
    • One how you can interact with other devices. (Like Arduino)
    • Other one with only ESP-01 as the core .
  • ESP wifimanager how to configure.
  • Apart from that bonus understanding of Servo Motor working principle.
  • PWM using ESP-01.

Step 4: Stuff Needed for the Project

Step 5: Assemble the Fish Feeder

  • I know..i know 3d printer to print don't have 3d printer..and bla..bla..bla..
  • You can order it online. There is a lot of online stores.
  • If you do the project with 3d printer parts it will stay for a long time and more durable.
  • Follow the steps and it will be assembled in one go.
  • Check the length of movable parts, use sand paper smooth out the surface for reducing friction.
  • Once done ✅ we are so good for actual circuit stuff.

Step 6: Circuit 1 : ESP-01 and Arduino Pro Mini

  • For circuit follow the image it is very simple.
  • Move your mouse to find pin points.
  • All are tagged.

Working principle :

  • ESP-01 will able to configure will your ISP using espwifimanger service. (Search in instrutable for wifi manger you will find more than 10 solution)
  • Once done it will continuously monitor your API point.
  • If it goes high it will update GPIO-01 high.
  • Now GPIO-00 will act as a sensor input pin for Arduino at Pint D8.
  • D8 if goes high, it will trigger the servo function.
  • Once Done it will update D7 High which will act as sensor pin for ESP GPIO-02.
  • And GPIO-02 goes high it will update the API to low.
  • And makes GPIO-00 low.
  • And again the loop continues.

Step 7: Circuit 2 : ESP-01 Only

  • For circuit follow the image it is very simple.

Working principle :

  • So as u know from our previous circuit we can use two pins for I/O.
  • So here one we are going to use for indication and one for for servo control.
  • GPIO-00 for servo control.
  • GPIO-02 for indication.
  • To control servo we have to create PWM signal from GPIO-00 pin.
    • So a servo check's a PWM for a signal of 20ms cycle.
    • If you give a 1ms PWM of Cycle 20ms it will stay at 0 degree. (for me it work on .7ms)
    • If you give a 2ms PWM of Cycle 20ms it will stay at 180 degree.
    • If you give a 1.5ms PWM of Cycle 20ms it will stay at 90 degree.
    • See the code the runServo function code it will give you a good idea.
  • So below is the logic
    • Keep looking the API end point for a value.
    • If you get that, Send PWM signal in GPIO-00.
    • Than do a API end point call to reset the value.
    • Then loop the same.
  • Logic is too easy.

Step 8: Code Walk Through

So as you may know a little knowledge is dangerous, same goes for code uploading.
Code without know what it does is like the we will discuss about the each function and how it works.

Project 2: OnlyESP8826

  • fastblink(int count,String msg)
    • It make the inbuilt led to blink for the number of count provided by the int count.
    • It will print the message on the serial.
  • getResult()
    • This function return the last record result for the specified field in the url.
    • Using ArduinoJson library of 5.1 we are working on the obtained json value.
  • updateStatus()
    • We are making a update call on field to set the field value to 0.
  • runServo(int servoPin, int degree)
    • It is the PWM routine for servo.
    • It help the servo to rate with the specified degree.
  • Setup
    • We are setting up the wifimanager.
    • So with that we will able to connect our device to a specific ISP using wifi.
    • Once it save it will be available for every time, no need to configure it again.
    • Once it is connected we are flashing the inbuilt led for 10 times.
    • Then setting up the Field value in thingspeak to zero using updateStatus().
    • Than a 5 sec delay so that next API call work smoothly.
  • Loop
    • If the device is connected than we are making our API call to get the latest or last Field value.
    • If the field value in 1 than only we are setting the built in LED Pin to glow.
    • Call the servo to move to 0 degree → 2sec delay → 180 degree → 2sec delay → 0 degree
    • Than a delay to do next api call.
    • Than we are setting up the field value again 0.

Project 1: esp8826Feeder and Feeder

  • How the other project work find out yourself
  • If you do it yourself you will face challenges and it will help you to learn.
  • Mostly all function are same only it had a communication over pins by setting pin high or low.
  • It is already explained in circuit step.
  • Worst case I'm still here to guide you and message me if you need help.

Curl for postman.

To update field values

GET /update.json?api_key=8FC9LUB2AXVCZJ6L&field2=1 HTTP/1.1

Host: Content-Type: application/x-www-form-urlencoded Cache-Control: no-cache Postman-Token: 688a86e0-7798-d4e1-b266-b5c666fefba7

To get last field values result :

GET /channels/665683/fields/2.json?api_key=QOIEGTM7XT0EKI0V&results=1 HTTP/1.1
Host: Cache-Control: no-cache Postman-Token: b939c04d-7c72-4d82-aea9-b37e668a5200

Change the .txt to html, page is attached for browser action.

Update the read write call appropriately for your fish feeder.

Step 9: Demo

  • First video is with postman.
  • Second with HTML Page.
  • Third video system in action.
  • Forth video how the mechanical moment is happening.

Few modification I made :

  • My 3d funnel got damaged during the process i replaced it with a small bottle.
  • Created a small holder and glue it with machine for clamp

If with me till the end thanks for your interest.
And if you made it than please share you challenges .
I'm sure I won't able to cover all the stuff with my first edit,please provide your valuable input so that I can update it with missing details.

Lastly thanks, and please feel free to give your valuable input, so that I can learn and able to wirte more awesome instructables.

IoT Challenge

Participated in the
IoT Challenge