Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Solar-Powered Arduino Mega 2560 Controlled Environment Monitoring System with Data Logging and Wi-Fi Connectivity

Image of Solar-Powered Arduino Mega 2560 Controlled Environment Monitoring System with Data Logging and Wi-Fi Connectivity

Circuit Documentation

Summary

This circuit is designed to interface various components with an Arduino Mega 2560 microcontroller. It includes input devices (pushbuttons), output devices (DC motor, servomotor, loudspeaker, and LCD screen), sensors (ultrasonic sensor, load cell), a real-time clock (RTC), a motor driver, and communication modules (SD card module, ESP8266 WiFi module). The circuit is powered by a 12V battery regulated by a charge controller, which also interfaces with a solar panel for charging. The circuit's functionality is controlled by embedded code running on the Arduino Mega 2560.

Component List

Power Supply

  • 12V Battery: Provides the main power source for the circuit.
  • Solar Panel: Supplies power to charge the battery through the charge controller.
  • Charge Controller: Manages the charging of the battery from the solar panel and provides power to the load.

Microcontroller

  • Arduino Mega 2560: The central processing unit of the circuit, interfacing with all other components.

Sensors

  • HC-SR04 Ultrasonic Sensor: Measures distance by emitting ultrasonic waves.
  • Load Cell - Red/white/black/green: A weight sensor that measures force or load.

Actuators

  • DC Motor: Converts electrical energy into mechanical motion.
  • Servomotor SG90: A small rotary actuator that allows for precise control of angular position.
  • Loudspeaker: Converts electrical signals into sound.

Display

  • I2C LCD 16x2 Screen: A liquid crystal display that can show 16 characters per line on 2 lines.

Communication Modules

  • SDmodule: An SD card module for data logging and storage.
  • ESP8266 NodeMCU: A WiFi module for wireless communication.

Motor Driver

  • L298N DC Motor Driver: Controls the direction and speed of the DC motor.

Timekeeping

  • DS1302 RTC: A real-time clock for keeping track of the current time and date.

Interface

  • Pushbuttons: Four pushbuttons used as input devices to interact with the microcontroller.

Miscellaneous

  • Resistors: Four resistors, likely used for pull-up or pull-down configurations for the pushbuttons.
  • HX711 - Bridge Sensor Interface: An ADC converter for the load cell sensor.
  • Loudspeaker: An output device to produce audio signals.

Wiring Details

Power Supply

  • 12V Battery:

    • VCC connected to Charge Controller Battery Positive.
    • GND connected to Charge Controller Battery Negative.
  • Solar Panel:

    • + connected to Charge Controller Solar Positive.
    • - connected to Charge Controller Solar Negative.
  • Charge Controller:

    • Load Positive connected to L298N Motor Driver 12V.
    • Load Negative connected to common ground.

Microcontroller

  • Arduino Mega 2560:
    • Digital pins D2 to D12 and D14 to D53 connected to various components for control signals.
    • Analog pins A0 to A11 connected to sensors and pushbuttons.
    • 5V and 3V3 pins provide power to various components.
    • GND connected to common ground.

Sensors

  • HC-SR04 Ultrasonic Sensor:

    • VCC connected to 5V from Arduino.
    • TRIG connected to Arduino pin D2.
    • ECHO connected to Arduino pin D3.
    • GND connected to common ground.
  • Load Cell - Red/white/black/green:

    • E+, A-, E-, A+ connected to HX711 Bridge Sensor Interface.

Actuators

  • DC Motor:

    • pin 1 connected to L298N Motor Driver OUT1.
    • pin 2 connected to L298N Motor Driver OUT2.
  • Servomotor SG90:

    • SIG connected to Arduino pin D12.
    • VCC connected to 5V from Arduino.
    • GND connected to common ground.
  • Loudspeaker:

    • pin1 connected to common ground.
    • pin2 connected to Arduino pin D11.

Display

  • I2C LCD 16x2 Screen:
    • SCL connected to Arduino pin D21/SCL.
    • SDA connected to Arduino pin D20/SDA.
    • VCC (5V) connected to 5V from Arduino.
    • GND connected to common ground.

Communication Modules

  • SDmodule:

    • CS connected to Arduino pin D53.
    • SCK connected to Arduino pin D52.
    • MOSI connected to Arduino pin D51.
    • MISO connected to Arduino pin D50.
    • VCC connected to 5V from Arduino.
    • GND connected to common ground.
  • ESP8266 NodeMCU:

    • TX connected to Arduino pin D15/RX3.
    • RX connected to Arduino pin D14/TX3.
    • Other pins not specified in the net list.

Motor Driver

  • L298N DC Motor Driver:
    • IN1 connected to Arduino pin D7.
    • IN2 connected to Arduino pin D8.
    • ENA connected to Arduino pin D9.
    • 12V connected to Charge Controller Load Positive.
    • GND connected to common ground.
    • 5V connected to 5V from Arduino.

Timekeeping

  • DS1302 RTC:
    • VCC connected to 3V3 from Arduino.
    • GND connected to common ground.
    • CLK connected to Arduino pin D6.
    • DATA connected to Arduino pin D5.
    • RST connected to Arduino pin D4.

Interface

  • Pushbuttons:
    • Each pushbutton has one pin connected to an Arduino analog pin (A8 to A11) and another pin connected to a resistor, which is then connected to common ground.

Miscellaneous

  • Resistors:

    • Connected between pushbuttons and common ground.
  • HX711 - Bridge Sensor Interface:

    • E+, E-, A-, A+ connected to Load Cell.
    • GND - GROUND connected to common ground.
    • DATA (OUT) connected to Arduino pin A0.
    • SCK - CLOCK (IN) connected to Arduino pin A1.
    • 3.3/3.5V Supply connected to 5V from Arduino.

Documented Code

#include <L298N.h>

// Pin definition
const unsigned int IN1 = 7;
const unsigned int IN2 = 8;
const unsigned int EN = 9;

// Create one motor instance
L298N motor(EN, IN1, IN2);

void setup()
{
  // Used to display information
  Serial.begin(9600);

  // Wait for Serial Monitor to be opened
  while (!Serial)
  {
    //do nothing
  }

  // Set initial speed
  motor.setSpeed(70);
}

void loop()
{

  // Tell the motor to go forward (may depend by your wiring)
  motor.forward();

  // Alternative method:
  // motor.run(L298N::FORWARD);

  //print the motor status in the serial monitor
  printSomeInfo();

  delay(3000);

  // Stop
  motor.stop();

  // Alternative method:
  // motor.run(L298N::STOP);

  printSomeInfo();

  // Change speed
  motor.setSpeed(255);

  delay(3000);

  // Tell the motor to go back (may depend by your wiring)
  motor.backward();

  // Alternative method:
  // motor.run(L298N::BACKWARD);

  printSomeInfo();

  motor.setSpeed(120);

  delay(3000);

  // Stop
  motor.stop();

  printSomeInfo();

  delay(3000);
}

/*
Print some informations in Serial Monitor
*/
void printSomeInfo()
{
  Serial.print("Motor is moving = ");
  Serial.print(motor.isMoving());
  Serial.print(" at speed = ");
  Serial.println(motor.getSpeed());
}

This code snippet is designed to control a DC motor using the L298N motor driver. It sets up the motor with initial speed, runs the motor forward and backward, stops the motor, and prints the motor status to the serial monitor. The motor's speed is also adjusted within the loop.