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

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

View and Edit Project In Cirkit DesignerImage 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

Microcontroller

Sensors

Actuators

Display

Communication Modules

Motor Driver

Timekeeping

Interface

Miscellaneous

Wiring Details

Power Supply

Microcontroller

Sensors

Actuators

Display

Communication Modules

Motor Driver

Timekeeping

Interface

Miscellaneous

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.