Skip to content

qppd/Smart-Mixer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Microcontroller-Regulated Eggshell Grinder and Reactor for Efficient Calcium Acetate Fertilizer Synthesis πŸŒ±βš—οΈ

License: MIT Arduino

An automated Arduino-based system that grinds eggshells to precise weights and reacts them with vinegar to produce calcium acetate fertilizer, with intelligent monitoring and control throughout the entire synthesis process.

Table of Contents

About

This project implements a complete automated synthesis system for calcium acetate fertilizer production. The microcontroller regulates an eggshell grinding process to achieve precise weight measurements, followed by automated vinegar addition in optimal ratios, and continuous monitoring of the exothermic reaction until completion.

Chemical Reaction: CaCO₃ (egg shells) + 2CH₃COOH (vinegar) β†’ Ca(CH₃COO)β‚‚ (calcium acetate) + Hβ‚‚O + COβ‚‚

Key Features:

  • Precision grinding with real-time weight feedback
  • Automated 1:12 ratio vinegar addition
  • Reaction monitoring until bubbling cessation
  • Temperature stabilization at ~39Β°C
  • Complete process automation with LCD user interface

Features

Automated Fertilizer Synthesis

  • Precision Grinding: Automated eggshell grinding to exact weight specifications
  • Intelligent Ratio Control: Automated 1:12 eggshell-to-vinegar ratio addition
  • Reaction Monitoring: Continuous tracking until bubbling stops and temperature stabilizes
  • Complete Process Automation: From grinding to final product with minimal user intervention

Real-time Monitoring

  • Temperature Sensing: DS18B20 sensor tracking reaction temperature (target: ~39Β°C)
  • Weight Measurement: HX711 load cell for precise grinding and ratio control
  • pH Level Detection: Analog pH sensor monitoring reaction progress
  • Serial Output: Real-time data logging and display

Control Systems

  • Grinding Motor Control: SSR-controlled motor for eggshell grinding
  • Automated Pumping: Relay-controlled pump for precise vinegar addition
  • LCD User Interface: I2C LCD for process status and user input
  • Button Input System: User controls for process initiation and parameter input
  • Dual Relay Control: SSR and regular relays for mixing operations
  • LCD Display: I2C LCD for local status visualization (configurable)
  • Power Management: Sleep/wake functionality for energy efficiency

Software Architecture

  • Modular Design: Separate configuration files for each component
  • Centralized Pin Management: All hardware pins defined in one location
  • Extensible Codebase: Easy to add new sensors or actuators

How It Works

Complete Synthesis Process Flowchart

START
  ↓
Put Eggshell β†’ Press Start Button β†’ LCD Shows Message
  ↓
Input Desired Grams (g) to Grind β†’ Loadcell Ready
  ↓
Motor ON (Grinding Starts)
  ↓
β”Œβ”€ Decision: Loadcell = Desired Weight?
β”‚   NO β†’ Continue Grinding (Motor ON)
└─ YES β†’ Motor OFF β†’ Pump ON
      ↓
Pump Runs Until 1:12 Ratio Achieved
      ↓
Monitor Solution (Temperature & pH)
      ↓
Store Data & Continue Monitoring
      ↓
Until Bubbling Stops & Temp β‰ˆ 39Β°C
      ↓
END (Fertilizer Ready)

Detailed Process Steps

  1. System Initialization: Arduino boots up, initializes sensors and LCD
  2. Eggshell Loading: User places eggshells in grinding chamber
  3. Process Start: User presses button to begin synthesis
  4. Parameter Input: LCD prompts for desired eggshell weight in grams
  5. Grinding Phase: Motor activates, load cell monitors weight in real-time
  6. Weight Verification: System checks if target weight is achieved
  7. Grinding Completion: Motor stops when desired weight is reached
  8. Vinegar Addition: Pump activates to add vinegar in 1:2 ratio
  9. Reaction Monitoring: Continuous temperature and pH monitoring begins
  10. Data Logging: All sensor readings stored and displayed
  11. Completion Detection: Process continues until bubbling stops and temperature stabilizes at ~39Β°C
  12. System Shutdown: Automatic completion when reaction is finished

Control Logic

  • Grinding Control: SSR Relay (Pin 23) controls grinding motor with weight feedback
  • Pumping Control: Regular Relay (Pin 22) controls vinegar pump with ratio feedback
  • Reaction Endpoints: Process completes when COβ‚‚ evolution ceases and temperature peaks
  • Safety Monitoring: Continuous parameter checking prevents unsafe conditions

Hardware Requirements

Core Components

  • Arduino Board (Uno, Mega, or compatible)
  • DS18B20 Temperature Sensor
  • HX711 Load Cell Amplifier + Load Cell (for weight measurement)
  • Analog pH Sensor Module
  • I2C LCD Display (16x2 or 20x4)
  • Momentary Push Button (for process initiation)
  • DC Motor (for eggshell grinding)
  • Peristaltic Pump (for vinegar addition)
  • 2-Channel Relay Module (Regular + SSR for motor/pump control)

Mechanical Components

  • Grinding Chamber: Container for eggshell grinding
  • Reaction Vessel: Container for fertilizer synthesis
  • Load Cell Mounting: Proper setup for weight measurement
  • Tubing System: For vinegar transfer from pump to reaction vessel

Pin Configuration

DS18B20 Sensor    -> Pin 2 (DATA; VCC -> 3.3V; GND -> GND; 4.7kΞ© pull-up resistor between DATA and VCC)
HX711 DT          -> Pin 4
HX711 SCK         -> Pin 3
pH Sensor         -> A0
LCD I2C           -> I2C pins (SDA, SCL)
Buttons           -> Pins 24 (Start), 5 (Stop), 6 (Calibrate)
Grinding Motor    -> Pin 23 (via SSR Relay)
Vinegar Pump      -> Pin 22 (via Regular Relay)
SD Card CS        -> Pin 53 (Arduino Mega)

Wiring Diagram

Wiring Diagram

The Fritzing file is available at wiring/SmartMixer.fzz

3D Model

Board Case 3D Model

Board Case Cover

Board Case Full

Software Requirements

Arduino IDE

  • Version: 1.8.19 or higher
  • Board: Arduino Uno/Mega (or compatible)

Required Libraries

Install via Arduino Library Manager:

  • OneWire by Paul Stoffregen
  • DallasTemperature by Miles Burton
  • LiquidCrystal_I2C by Marco Schwartz
  • HX711 by Bogdan Necula

Installation

  1. Clone the Repository

    git clone https://github.com/qppd/Smart-Mixer.git
    cd Smart-Mixer
  2. Open Arduino IDE

    • Navigate to src/arduino/SmartMixer/SmartMixer.ino
    • Open the file in Arduino IDE
  3. Install Required Libraries

    • Go to Sketch > Include Library > Manage Libraries
    • Search and install:
      • OneWire
      • DallasTemperature
      • LiquidCrystal_I2C
      • HX711
  4. Configure Hardware

    • Connect sensors according to pin configuration
    • Verify power supplies for all components
  5. Upload Code

    • Select correct board and port
    • Click Upload button

Usage

Fertilizer Synthesis Process

  1. System Setup: Power on Arduino, ensure all sensors are connected
  2. Load Eggshells: Place eggshells in the grinding chamber on the load cell
  3. Start Process: Press the start button to initiate synthesis
  4. Parameter Input: LCD displays "Enter weight (g):", use buttons to input desired grams
  5. Grinding Phase: Motor activates, grinding continues until target weight is reached
  6. Weight Verification: System automatically stops grinding when load cell measures desired weight
  7. Vinegar Addition: Pump activates to add vinegar in 1:12 ratio to eggshell weight
  8. Reaction Monitoring: System continuously monitors temperature and pH
  9. Data Logging: All readings displayed on Serial Monitor and optionally LCD
  10. Completion Detection: Process ends when bubbling stops and temperature stabilizes at ~39Β°C

Serial Output Format

Temperature: 39.20Β°C --- Weight: 150.00g --- pH: 4.80 --- Status: REACTING
Temperature: 39.50Β°C --- Weight: 450.00g --- pH: 5.20 --- Status: COMPLETE

Process Parameters

  • Grinding Weight: User-defined (typically 100-200g eggshells)
  • Vinegar Ratio: Automatic 1:12 eggshell-to-vinegar ratio
  • Reaction Temperature: Target ~39Β°C (normal temperature change)
  • Completion Criteria: Bubbling cessation + temperature stabilization
  • Monitoring Duration: Continuous until reaction completion

Control Examples

// Start grinding motor
operateSSR(RELAY_GRINDER, true);

// Check if target weight reached
if (getLOADCELLWeight() >= targetWeight) {
    operateSSR(RELAY_GRINDER, false); // Stop grinding
    operateRELAY(RELAY_PUMP, true);   // Start vinegar pump
}

// Monitor reaction completion
if (getPHValue() >= 4.5 && getDS18B20Temperature(false) >= 38.0) {
    // Reaction complete - stop all operations
    operateRELAY(RELAY_PUMP, false);
}

LCD Display

The LCD is always active from startup. It automatically shows the appropriate screen for each process state. See the LCD Integration section for full layout details.

Project Structure

Smart-Mixer/
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
└── src/
    └── arduino/
        └── SmartMixer/
            β”œβ”€β”€ SmartMixer.ino          # Main Arduino sketch
            β”œβ”€β”€ PINS_CONFIG.h           # Hardware pin definitions
            β”œβ”€β”€ DS18B20_CONFIG.h/.cpp   # Temperature sensor (DS18B20)
            β”œβ”€β”€ HX711_CONFIG.h/.cpp     # Load cell amplifier
            β”œβ”€β”€ PH_CONFIG.h/.cpp        # pH sensor
            β”œβ”€β”€ LCD_CONFIG.h/.cpp       # LCD display
            └── RELAY_CONFIG.h/.cpp     # Relay control
               β”œβ”€β”€ SD_CONFIG.h/.cpp        # SD card logging
               β”œβ”€β”€ BUTTON_CONFIG.h/.cpp    # 3-button input handling

File Descriptions

  • SD_CONFIG.*: SD card logging and storage
  • BUTTON_CONFIG.*: Three-button input handling with debounce

Configuration

Fertilizer Synthesis Parameters

  • Target Grinding Weight: User-defined (100-200g recommended)
  • Vinegar Ratio: 1:12 eggshell-to-vinegar (automatic calculation)
  • Reaction Temperature: ~39Β°C (normal temperature increase)
  • Completion Criteria: Bubbling cessation + temperature stabilization
  • Safety Limits: Max 45Β°C, Min pH 4.0, Max weight 500g

Calibration Values

  • HX711 Scale Factor: 22500.3f (adjust for your load cell)
  • pH Calibration: 21.34 (calibrate with pH 4.0 and 7.0 buffers)

Pin Customization

Edit PINS_CONFIG.h to modify hardware connections:

#define TEMP_SENSOR_PIN 2  // Temperature sensor
#define HX711_DT 4         // Load cell data
#define HX711_SCK 3        // Load cell clock
#define PH_PIN A0          // pH sensor analog input
#define BUTTON_START 24    // Start button
#define BUTTON_STOP 5      // Stop button
#define BUTTON_CALIBRATE 6 // Calibrate button
#define SD_CS 53           // SD card chip select (Arduino Mega)
#define RELAY_GRINDER 23   // Grinding motor relay (SSR)
#define RELAY_PUMP 22      // Vinegar pump relay (regular)

Sensor Parameters

  • DS18B20: Single-wire digital temperature sensor on Pin 2
  • pH Sampling: 10 readings with median filtering for noise reduction
  • Weight Averaging: 10-sample moving average for stability
  • Button Debouncing: 50ms debounce delay
  • LCD Refresh Rate: 500ms non-blocking update interval (LCD_UPDATE_INTERVAL)

LCD Integration

The Smart Mixer uses an I2C LCD (16 columns Γ— 4 rows) at address 0x27 as the primary user interface, showing real-time sensor data, process status, and menu prompts throughout every stage of operation. The LCD is always initialised in setup() and never requires a manual enable command.

Display Layout by Process State

Idle / Splash Screen

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚β—Ž Smart Mixer   β”‚  Row 0 – mixer icon + project title
β”‚Ca-Acetate Synthβ”‚  Row 1 – process description
β”‚β†’START  β†’CALIB  β”‚  Row 2 – button hints with arrow icons
β”‚  System Ready  β”‚  Row 3 – system status
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Calibration Mode

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚== CALIBRATE == β”‚  Row 0 – mode header
β”‚Remove weight!  β”‚  Row 1 – current step prompt (updates per step)
β”‚Factor:22500.3  β”‚  Row 2 – calibration factor (live)
β”‚Press to confirmβ”‚  Row 3 – action hint
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Steps cycle: Remove weight! β†’ Taring scale... β†’ Place 100g... β†’ Calibrating... β†’ Done!

Target Input

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚== SET TARGET ==β”‚  Row 0 – mode header
β”‚Egg: 50.0g      β”‚  Row 1 – confirmed eggshell target
β”‚Vin:600.0g      β”‚  Row 2 – auto-calculated vinegar (1:12 ratio)
β”‚ Waiting input..β”‚  Row 3 – status
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Grinding Stage

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚== GRINDING ==  β”‚  Row 0 – stage header
β”‚Cur:45.2g/50.0g β”‚  Row 1 – current weight / target weight
β”‚Progress:  90%  β”‚  Row 2 – completion percentage
β”‚GND:ON  [STOP]  β”‚  Row 3 – grinder state + stop hint
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Dispensing Stage

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚=  DISPENSING  =β”‚  Row 0 – stage header
β”‚D:45.2g/600.0g  β”‚  Row 1 – dispensed / target vinegar
β”‚PID Out:   85%  β”‚  Row 2 – PID controller output percentage
β”‚PMP:ON  [STOP]  β”‚  Row 3 – pump state + stop hint
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Reaction Monitoring Dashboard

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚T:25.4Β°C pH:7.20β”‚  Row 0 – temperature (Β°) + pH
β”‚W: 720g  D: 600gβ”‚  Row 1 – total weight + dispensed vinegar
β”‚GND:OFF PMP:OFF β”‚  Row 2 – actuator states
β”‚00:05:30 Active β”‚  Row 3 – elapsed time HH:MM:SS + phase
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The degree symbol Β° is rendered as a custom CGRAM character for crisp display.

Process Complete

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚βœ“ COMPLETE!     β”‚  Row 0 – check icon + completion
β”‚T:24.5Β°C pH:6.80β”‚  Row 1 – final temperature + pH
β”‚W: 720g  SD:OK  β”‚  Row 2 – final weight + SD card status
β”‚  Press START   β”‚  Row 3 – restart hint
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

SD:OK or SD:ERR reflects the result of the last CSV write.

Error Screen (blinking alert)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚β–² !! ERROR !!   β”‚  Row 0 – blinking alert (600 ms period)
β”‚Check sensors!  β”‚  Row 1 – error description
β”‚Actuators: OFF  β”‚  Row 2 – safety confirmation
β”‚Check & Restart β”‚  Row 3 – corrective hint
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Row 0 blinks on/off every 600 ms using a non-blocking millis() timer.

Emergency Stop

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚β–²EMERGENCY STOP!β”‚  Row 0 – alert icon + label
β”‚Grinder:OFF     β”‚  Row 1 – grinder state
β”‚Pump:   OFF     β”‚  Row 2 – pump state
β”‚  Press START   β”‚  Row 3 – restart hint
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Button Feedback Flash

When any button is pressed, row 3 instantly updates for ~500 ms:

  • START β†’ β†’START pressed!
  • STOP β†’ β†’STOP pressed!
  • CALIB β†’ β†’CALIB pressed!

The next scheduled display refresh overwrites this automatically, creating a brief visual acknowledgement without any blocking delay.

Custom CGRAM Characters

Index Symbol Usage
CHAR_DEGREE (0) Β° Temperature unit in monitoring/complete screens
CHAR_ALERT (1) β–² Error screen row 0 and emergency stop
CHAR_CHECK (2) βœ“ Complete screen row 0
CHAR_ARROW_R (3) β†’ Idle button hints and button feedback
CHAR_MIXER (4) β—Ž Idle splash screen title

Non-Blocking Refresh Strategy

All periodic LCD updates are gated by lcdShouldUpdate(), which returns true at most once per LCD_UPDATE_INTERVAL (500 ms). This ensures:

  • No flicker from redundant writes
  • Sensor reads and actuator control are never delayed by display logic
  • Button feedback bypasses the gate for immediate visual response

Adding New Display Content

To add readings from a future sensor:

  1. Add a new display function in LCD_CONFIG.cpp following the existing patterns.
  2. Declare the prototype in LCD_CONFIG.h.
  3. Call the function from the relevant state handler in SmartMixer.ino inside an if (lcdShouldUpdate()) block.

API Reference

Temperature Functions

void initDS18B20();                              // Initialize DS18B20 sensor
float getDS18B20Temperature(boolean fahrenheit); // Get temperature (-1 on error)

Weight Functions

void initLOADCELL();                      // Initialize HX711
float getLOADCELLWeight();                // Get weight reading
void operateHX711sleep();                 // Put HX711 to sleep
void operateHX711wake();                  // Wake HX711

pH Functions

float getPHValue();                       // Get filtered pH reading

LCD Functions

void initLCD();                                          // Init LCD, load custom chars
void clearLCD();                                         // Clear all rows
void setLCDText(String text,  int col, int row);         // Write text at position
void setLCDText(float  value, int col, int row);         // Write float at position
bool lcdShouldUpdate();                                  // Non-blocking 500 ms gate

// State-specific full-screen display functions
void lcdDisplayIdle();                                   // Splash / idle screen
void lcdDisplayCalibration(const char* step, float cf); // Calibration prompts
void lcdDisplayInputTarget(float eggG, float vinG);     // Target weight input
void lcdDisplayGrinding(float cur, float tgt, bool on); // Grinding progress
void lcdDisplayDispensing(float disp, float tgt,
                          bool on, int pidPct);          // Dispensing progress
void lcdDisplayMonitoring(float temp, float ph,
  float weight, float dispensed,
  bool gOn, bool pOn, unsigned long elapsedMs);          // Reaction dashboard
void lcdDisplayComplete(float wt, float t,
                        float ph, bool sdOk);            // Completion summary
void lcdDisplayError(const char* msg);                   // Blinking error screen
void lcdDisplayEmergencyStop();                          // E-stop overlay
void lcdDisplayButtonFeedback(int buttonIndex);          // Brief button flash

Relay Functions

void initRELAY();                         // Initialize relays
void operateRELAY(uint16_t relay, boolean state); // Control regular relay
void operateSSR(uint16_t relay, boolean state);   // Control SSR

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow Arduino coding standards
  • Add comments to complex logic
  • Test hardware compatibility
  • Update documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

Sajed Lopez Mendoza


⭐ Star this repository if you find it useful!

For questions or support, please open an issue on GitHub.

About

An automated Arduino-based system that grinds eggshells to precise weights and reacts them with vinegar to produce calcium acetate fertilizer, with intelligent monitoring and control throughout the entire synthesis process.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors