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.
3.3V
connected to ESP32 3V3
pin.5V
connected to HX711 3.3/3.5V Supply
pin and Servo vcc
pin.GND
connected to ESP32 GND
, HX711 GND - GROUND
, and Servo gnd
.D9
connected to Servo pulse
.D3
connected to HX711 SCK - CLOCK (IN)
.D2
connected to HX711 DATA (OUT)
.D1
connected to one side of the Resistor.D0
connected to ESP32 TX0
.3V3
connected to Arduino UNO 3.3V
.GND
connected to Arduino UNO GND
.TX0
connected to Arduino UNO D0
.RX0
connected to the other side of the Resistor.D1
.RX0
.gnd
connected to Arduino UNO GND
.vcc
connected to Arduino UNO 5V
.pulse
connected to Arduino UNO D9
.E+
connected to HX711 E+
.A-
connected to HX711 A-
.E-
connected to HX711 E-
.A+
connected to HX711 A+
.3.3/3.5V Supply
connected to Arduino UNO 5V
.GND - GROUND
connected to Arduino UNO GND
.SCK - CLOCK (IN)
connected to Arduino UNO D3
.DATA (OUT)
connected to Arduino UNO D2
.E+
, A-
, E-
, A+
connected to corresponding pins on the Load Cell./*
* 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.