Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino and ESP32 IoT Cat Feeder with Load Cell Monitoring

View and Edit Project In Cirkit DesignerImage of Arduino and ESP32 IoT Cat Feeder with Load Cell Monitoring

Circuit Documentation

Summary

This circuit is designed to control a cat feeder system based on IoT (Internet of Things) principles. The core of the system is an Arduino UNO microcontroller, which interfaces with an ESP32 module for IoT connectivity, a servo motor to dispense food, and a load cell connected through an HX711 bridge sensor interface to measure the amount of food dispensed. The Arduino UNO controls the servo based on the weight data from the load cell and communicates this data to the ESP32 for potential remote monitoring or control.

Component List

Arduino UNO

ESP32 (30 pin)

Resistor (200 Ohms)

Servo

Load Cell - Red/white/black/green

HX711 - Bridge Sensor Interface

Wiring Details

Arduino UNO

ESP32 (30 pin)

Resistor (200 Ohms)

Servo

Load Cell - Red/white/black/green

HX711 - Bridge Sensor Interface

Documented Code

/*
 * Cat Feeder based on IoT
 * This Arduino sketch controls a servo motor to dispense food for a cat.
 * It also reads data from a load cell via the HX711 interface to measure
 * the amount of food dispensed. The Arduino communicates with an ESP32
 * for IoT functionality.
 */

#include <Servo.h>
#include <HX711.h>

// Pin definitions
const int servoPin = 9;
const int hx711DataPin = 2;
const int hx711ClockPin = 3;
const int esp32TxPin = 0;
const int esp32RxPin = 1;

// Create servo and HX711 instances
Servo myServo;
HX711 scale;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  Serial1.begin(115200); // Serial1 for ESP32 communication

  // Initialize servo
  myServo.attach(servoPin);
  myServo.write(0); // Initial position

  // Initialize HX711
  scale.begin(hx711DataPin, hx711ClockPin);
  scale.set_scale(); // Set the scale (calibration factor)
  scale.tare(); // Reset the scale to 0

  // Wait for the scale to stabilize
  delay(2000);
}

void loop() {
  // Read weight from load cell
  float weight = scale.get_units(10);
  Serial.print("Weight: ");
  Serial.print(weight);
  Serial.println(" g");

  // Check if weight is below threshold, if so, dispense food
  if (weight < 50) { // Example threshold
    dispenseFood();
  }

  // Send weight data to ESP32
  Serial1.print("Weight: ");
  Serial1.print(weight);
  Serial1.println(" g");

  // Wait before next loop iteration
  delay(1000);
}

void dispenseFood() {
  // Rotate servo to dispense food
  myServo.write(90); // Rotate to 90 degrees
  delay(1000); // Wait for 1 second
  myServo.write(0); // Return to initial position
  delay(1000); // Wait for 1 second
}

This code is responsible for the operation of the cat feeder. It initializes the servo and the HX711 load cell interface, reads the weight of the food, and dispenses food if the weight is below a certain threshold. It also communicates the weight data to the ESP32 for IoT applications.