Introduction: Solar Tracker

Hello, my name is Jochem Forrez and i'm studding Multi Media and Communication Technology at Howest (Kortrijk, Belgium). For school we needed to make a project. I made a Solar tracker (solar panel that follows the sun), i found it a really interesting project and its fun to make.

The project uses 4 light depended resistor to find the brightest light source. It also measures the current flow and voltage of the battery and solar panel. This is displayed on a website and visualised via graphs. You can also control the two servo with the website.


For this project you need:

Raspberry Pi
Phaesun Sun Plus 5 Polykristallijn solar panel 5W
Adafruit INA219 Current Sensor Breakout x2
Ldr x4
servo (strong) x2
nextion display
3.7v battery
power-supply 3.3V and 5V
SparkFun Sunny Buddy - MPPT Solar Charge
allot breadboard jumper cables :)
threaded rod of M3
nuts and washers of M3
1K resistor x4

Step 1: Step 1: Electronics

Here you can get a fritzing schema with all the components. the current sensor and the sunny buddy need some soldering.

Step 2: Step 2: Database

this is my data base model. This is hosted on the raspberry pi using MariaDB. It logs all the sensors and setting if its in manual mode or not.

Step 3: Step 3: Website

Here you can see some image on the site the site can be reach with the ip that the raspberry has (you can find it on the display). On the site you can see all the graphs of the sensor and control the solar panel.

Step 4: Step 4: Case

For a case i just took a plastic box and cut/drilled small holes for the cables and a big hole for the display. I glued all the components (not the servos and ldr's). In total i drilled 3 small holes for the cables: 1 for the ldr's, 1 for the cables of the solar panel and 1 for the servos (cables).

For the solar panel i use scrap mdf panels i had at home. the desing is not perfect and if you can try to make it better but it works. You need 2 parts in wood.

One big U shaped peace for the dimensions you can look at the picture

And one big platform you can make it any size you want mine is 400*300*20 mm

once you have these parts you need to drill a hole in the middle of the aluminium back site of the solar panel that is around 125 mm and 17.5 mm on both sides so you can stick a threaded rod of M3 with a drill not smaller than 3 mm and not bigger than 5 mm (you can go bigger but its not recommended).

Than cut a threaded rod M3 350mm in length add a nut on it so you can use it as a counter nut for the servo add that rod on your servo and keep going until its thigh and than tighten the counter nut so it can loosen anymore i tried to visualise where you need nuts and washer there is a picture of it.

For the y axis i also cut a threaded rod of M3 90 mm long and use a counter nut and a nut to fasten it.

Step 5: Step 5: Setting Up Raspberry Pi OS

Here is a tutorial from raspberry on how to setup the OS:

Here is a tutorial how to ssh to raspberry:

once you can do this you can login with username: PI and password Raspberry
First thing you want to do is change the password of the pi this can be done with the command: sudo raspi-config than you go to 1 Change User Password and change the password don't forget it or you need to start over.

go in raspi-config to setting 4 Localisation Options and set all the setting right for your country and keyboard

in 2 network option you can setup your wifi

in 5 you need SPI, I2C, Serial, Remote GPIO on

to install the web server you need to install Apache with this command (sudo apt install apache2 -y) in the terminal. you can test if it works when pasting the ip of your raspberry in a browser.

and some library need to be installed to get the program working just copy and past in the terminal

sud opip3 install mysql-connector-python
sudo pip3 install flask-cors
sudo pip3 install gevent
sudo pip3 install gevent-websocket
sudo pip3 install pi-ina219

Step 6: Step 6: Code

On this GitHub you can find the code of the project you can install it and run it