Showing posts with label tracker. Show all posts
Showing posts with label tracker. Show all posts

Sunday

Enhancing Solar Tracking Using Tensorflow and Machine Learning



Abstract:

A solar tracking system is a device or mechanism designed to orient solar panels, solar collectors, or other solar energy harvesting equipment so that they continuously face the sun as it moves across the sky. The primary purpose of a solar tracking system is to maximize the efficiency and energy output of solar power generation systems by ensuring that they receive the maximum amount of sunlight throughout the day.

There are two main types of solar tracking systems:

1. Single-Axis Tracking: These systems track the sun's movement along one axis, typically either the east-west axis (horizontal tracking) or the north-south axis (vertical tracking). Single-axis trackers adjust the tilt angle of solar panels or collectors to follow the sun's path from sunrise to sunset. Horizontal single-axis trackers are more common and cost-effective for residential and commercial installations.

2. Dual-Axis Tracking: Dual-axis tracking systems are more complex and can track the sun's movement in both the east-west and north-south directions. This allows solar panels or collectors to follow the sun's path more accurately throughout the day, maximizing energy production. Dual-axis trackers are often used in concentrated solar power (CSP) plants and large-scale solar installations.

Key components of a solar tracking system typically include sensors, motors, and a controller. Sensors detect the sun's position, and the controller calculates the optimal angle and direction for the solar panels or collectors. Motors then adjust the position of the solar equipment accordingly.

Advantages of solar tracking systems include increased energy production and efficiency compared to fixed solar installations. However, they are more complex and expensive to install and maintain. The choice between fixed and tracking systems depends on factors like location, available space, budget, and energy production goals.

Solar tracking systems are commonly used in solar power generation applications, including solar photovoltaic (PV) systems, solar thermal systems, and concentrated solar power (CSP) plants. They help harness the sun's energy more effectively, making solar power a more viable and efficient renewable energy source.

A novel approach to solar tracking, leveraging deep learning techniques, is under exploration and experimentation using TensorFlow, an open-source machine learning framework. TensorFlow introduces flexibility to the implementation process and extends development capabilities. It enables the deployment of neural networks across a wide range of devices, including embedded systems, mobile devices, and mini-computers. Moreover, TensorFlow supports various types of neural networks that can be fine-tuned and retrained for specific applications. Initial findings are promising, as the retrained networks accurately identify the Sun and target objects, enabling precise tracking of the Sun's apparent trajectory without additional information.


Introduction:

Solar tracking systems (STSs) are crucial for optimizing system efficiency and minimizing expenses. Traditional STSs have drawbacks, such as limited tracking range and susceptibility to environmental conditions.

Computer vision-based control addresses these drawbacks by using a strategically positioned camera to identify the Sun and target areas. The midpoint between the intersections of the solar and target vectors on an image plane is then computed and used as input for the STS controller.

This versatile approach can be applied to various solar technologies, irrespective of the solar tracker type. It involves detecting the Sun and the tower target area using a camera positioned at 0° and aligned with the collector's optical axis. The midpoint between the solar and target vectors' intersections with an image plane is then computed and used as input for the STS controller.


Neural Network Models:

Several pretrained neural network models available in TensorFlow and Keras eg. ResNet50, AlexNet, and VGG16 or CV2 are enough to find the brightest spot on the image, which have been considered for this work. These models have been fine-tuned to identify the Sun, target, heliostats, and clouds. The choice of model affects factors such as speed and precision. "SSD MobileNet V1 quantized" stands out as the most accurate model, while "SSD MobileNet V1 0.75 depth or VGG16" is the fastest. Further optimization of model configurations and training parameters may yield improved results.

So converted all Keras models into TensorFlow lite model. A TFLite model that you can use for inference on mobile and edge devices. Note that the TFLite model may not be the same as the original Keras model due to optimizations and quantization performed during the conversion process.

We also kept this one step advance with EDGE TPU to use in Coral type of hardware.


Training:

After creating different TF2.0 models for a series of detections. Needed to convert those models to work on EDGE [Enhanced Data rates for GSM Evolution] microcontroller eg. Raspberrypi where processing power and memory are very limited compared to where we trained our models eg. Google Colab Pro with high-end TPU and GPU processing power available.

Neural network training is an iterative process, and the RMSPropOptimizer provided by TensorFlow has been used in this study. Training is computationally intensive, and a GPU cluster with CUDA support was employed to reduce training time. The average training time was approximately 24 hours.


Validation:

Validation involves an independent image set with labeled object classes (Sun, and cloud). Metrics such as mean average precision (mAP) and inference time are used to evaluate neural network performance. The results indicate that "SSD MobileNet V1 quantized" is the most accurate model, while "SSD MobileNet V1 0.75 depth" is the fastest. "Mask R-CNN Inception V2" offers both object detection and semantic segmentation capabilities.


Implementation:

The computer vision-based STS approach has been implemented for both low-end embedded and mobile devices, in addition to common computers. A Raspberry Pi 3 Model B+ with a Pi camera was used for embedded devices. TensorFlow serves as the underlying machine learning framework.


Examples:

Images taken from Raspberry Pi and mobile devices demonstrate the successful detection of objects (Sun, target, and heliostats) and the computation of tracking errors. These examples illustrate the practical application of the approach.


Conclusion and Future Work:

The adoption of TensorFlow and machine learning has improved the speed and accuracy of the solar tracking approach. The flexibility of TensorFlow enables implementation on various devices. Ongoing work includes expanding the image datasets for training and validation, evaluating new neural networks, and optimizing implementations. Future work involves autonomous heliostat control using embedded devices to assess control accuracy and determine optimal image resolutions.

Building a solar tracker system with machine learning, a camera, Raspberry Pi/Arduino, motors, and GPS involves several steps. Here's a high-level plan:


1. Hardware Setup:

   - Camera: Connect a compatible camera module (e.g., Raspberry Pi Camera) to the Raspberry Pi.

   - Motors: Use motors or servo motors to control the movement of solar panels. Ensure they can be interfaced with Raspberry Pi/Arduino.

   - Raspberry Pi/Arduino: Choose the appropriate board for processing and control.


2. Solar Detection with Machine Learning:

   - Train a machine learning model to detect the sun in images. You can use a pre-trained model for object detection or train your own model using a dataset of images with and without the sun.

   - Integrate the trained model into your application running on Raspberry Pi for real-time sun detection.


3. Motor Control:

   - Write code to control the motors/servo motors based on the sun's position. Ensure that the solar panels are oriented towards the sun for maximum efficiency.

   - Implement a feedback loop to continuously adjust the position based on the machine learning model's output.


4. GPS Integration:

   - Integrate a GPS module to provide location information.

   - Implement a fail-safe mechanism to check for cloudy weather using weather APIs or local sensors.

   - If cloudy, park the solar panels horizontally or in a safe position.


5. Power Management:

   - Implement efficient power management to ensure the system runs on solar power or a combination of solar and battery power.


6. User Interface (Optional):

   - Develop a user interface for monitoring the solar tracker's status and making manual adjustments if needed.


7. Testing and Calibration:

   - Test the system in various weather conditions to ensure robust performance.

   - Calibrate the system to improve accuracy and responsiveness.


8. Safety Considerations:

   - Implement safety features to protect the system in case of malfunctions or unexpected events.


9. Documentation:

   - Document the system architecture, wiring diagrams, code, and calibration procedures.


10. Deployment:

   - Install the solar tracker in a location with optimal sunlight exposure.

   - Monitor and maintain the system regularly.


Calculating the movement of the solar tracker based on the sun's position in the image involves determining the angle of deviation from the center of the horizon. Here's a simplified approach using basic geometry:


1. Identify Sun Position:

   - Use your trained machine learning model to detect the sun's position in the image. Get the coordinates (x, y) of the detected sun.


2. Calculate Deviation from Center:

   - Calculate the horizontal deviation from the center of the image:

     ```python

     image_width = ...  # Width of the image in pixels

     center_x = image_width / 2

     deviation = sun_x - center_x

     ```


3. Convert Deviation to Angle:

   - Convert the deviation to an angle by considering the field of view of the camera. If the camera has a known field of view (FOV), you can use it to calculate the angle:

     ```python

     fov = ...  # Field of view in degrees

     pixels_per_degree = image_width / fov

     angle = deviation / pixels_per_degree

     ```


4. Adjust Motor Position:

   - Use the calculated angle to adjust the position of the solar tracker's motors. The angle will determine in which direction and how much the solar panels need to move.


5. Feedback Loop:

   - Implement a feedback loop to continuously adjust the motor position based on the changing sun position. This can be done by periodically capturing images, detecting the sun, and making real-time adjustments.


Here's a simple Python function to calculate the angle based on the sun's position:


```python

def calculate_angle(image_width, sun_x, fov):

    center_x = image_width / 2

    deviation = sun_x - center_x

    pixels_per_degree = image_width / fov

    angle = deviation / pixels_per_degree

    return angle

```


Remember to adapt the values of `image_width` (width of the image in pixels) and `fov` (field of view) based on your specific camera specifications.


This approach assumes a linear relationship between pixel deviation and angle. For precise tracking, you may need to consider more sophisticated methods and calibration based on your specific setup.


You can find more code here https://github.com/dhirajpatra/jupyter_notebooks/blob/main/DataScienceProjects/image_processing/find_the_bright_spot.ipynb


Friday

Sun Tracking System Using ML

 

unplush

Title: Sun Tracking System Using Raspberry Pi or ESP32 Camera Module and Machine Learning for Solar Panels

Abstract:

This hypothetical research paper presents a novel approach to design and implement a sun tracking system for solar panels using a Raspberry Pi or ESP32 camera module and machine learning techniques. The proposed system aims to optimize the energy output of solar panels by automatically adjusting their orientation to follow the movement of the sun throughout the day. The system utilizes computer vision algorithms based on a pre-trained machine learning model to detect the sun’s position in captured images and subsequently control a servo motor to align the solar panel optimally.

unplush

1. Introduction:

The growing demand for renewable energy sources has intensified the need for efficient solar energy harvesting. Sun tracking systems enhance the overall efficiency of solar panels by dynamically adjusting their orientation to face the sun directly. This paper presents a cost-effective and scalable approach using Raspberry Pi camera and machine learning to autonomously track the sun.

2. Related Work:

Review existing literature on sun tracking systems, computer vision techniques, and machine learning applications in solar energy optimization. Identify gaps in the research and highlight the uniqueness of the proposed approach.

3. System Architecture:

Illustrate the high-level architecture of the sun tracking system, including components such as Raspberry Pi, camera module or ESP32 Camera, servo motor, and machine learning model. Describe how these components interact to achieve sun tracking.

4. Image Capture and Processing:

Detail the image capture process performed by the Raspberry Pi camera module at regular intervals (e.g., every 10 minutes). Explain the preprocessing steps to enhance image quality and isolate the sun from the background.

5. Machine Learning Model:

Describe the pre-trained machine learning model used for sun detection in the captured images. Clarify the choice of the model, its training process, and its effectiveness in accurately identifying the sun’s position.

You can find out an example Jupyter Notebook here https://github.com/dhirajpatra/jupyter_notebooks/blob/main/DataScienceProjects/image_processing/find_the_bright_spot.ipynb

6. Sun Position Calculation:

I have used mere CV2 and Gaussian method for the above example which trac the bright spot in an image. For our case it is sun ofcourse.

It also calculate the how many degree upward movement required. We can take the easy pattern by dividing the imaeg/photo equal four parts and to check how many degree the sun is in the image upward [x].

my own code produced

7. Servo Motor Control:

Here are the steps on how to move a servo motor fitted with a camera based on the microcontroller telling the servo which degree it needs to move to upward:

Attach the servo motor to the microcontroller.

Initialize the servo motor.

Create a variable to store the desired angle.

Read the desired angle from the microcontroller.

Move the servo motor to the desired angle.

Here is an example code that you can use:

import serv


def main():
# Attach the servo motor to the microcontroller.
servo_motor = servo.Servo(12)


# Initialize the servo motor.
servo_motor.initialize()


# Create a variable to store the desired angle.
desired_angle = 90


# Read the desired angle from the microcontroller.
desired_angle = input("Enter the desired angle: ")


# Move the servo motor to the desired angle.
servo_motor.write(desired_angle)


if __name__ == "__main__":
main()

This code will first attach the servo motor to the microcontroller and initialize it. Then, it will create a variable to store the desired angle. The desired angle will be read from the microcontroller. Finally, the servo motor will be moved to the desired angle.

8. Experimental Setup:

Outline the hardware components used in the experimental setup, including the Raspberry Pi, camera ESP32 camera module, servo motor, and solar panel. Describe the environment and testing conditions.

We need to direct the tracker to move the row of panels.

By combining Raspberry Pi camera module and machine learning, this research paper presents a cost-effective and scalable solution for solar panel sun tracking. The proposed system’s potential benefits include increased solar energy harvesting efficiency, reduced energy costs, and a more sustainable approach to renewable energy utilization. With further research and development, this sun tracking system has the potential to contribute significantly to the transition towards greener energy sources.

Thank you. I am a Software Architect | AI, Data Science, IoT, Cloud ⌨️ 👨🏽‍💻

Love to learn and share knowledge.

ETL with Python

  Photo by Hyundai Motor Group ETL System and Tools: ETL (Extract, Transform, Load) systems are essential for data integration and analytics...