Closing the Chapter on Code Development

  • Saturday, Jun 8, 2024
blog-image

Closing the Chapter on Code


This week we made serious advancements in the development of the software used in our prototype. João and Lucas have been working hard to develop a working iteration of the needed code to perform the various tasks that our product promises to execute. Our software is divided into two parts: the first one is the code for the Arduino, that focuses on the rotation of the blinds and the solar tracking and the second part is the code for the ESP8266 that allows Wi-Fi communication needed for the web app.

The blinds have two operation modes: an automatic mode and a manual mode.

In the automatic mode, the solar height is calculated, given the latitude and longitude. The ESP8266 starts by sending to the Arduino the current date and hour (UTC), which are also needed for this particular calculation. Then, the solar blinds are rotated in order to maximize the energy produced, which means to have the same inclination as the current solar height. To achieve that, it is necessary to evaluate what is the difference between the current inclination of the solar cells and the pretended one and calculate the number of notches that need to be rotated on the motor. If the variation between the pretended angle of elevation and the current one is not sufficient to rotate at least one notch of the motor, then that deviation is stored and it will only be considered when the difference between the two angles produces some effect on the rotation of the motor. It was also needed to make a small adjustment because it was empirically determined that the motor would only rotate for angles inferior to about 60 degrees. So, if the angle is superior to 60 degrees, two successful rotations, each one corresponding to half of the desired elevation angle, are done.

The manual mode operates similarly to the automatic mode, utilizing the same functions to adjust the blinds’ rotation. However, unlike the automatic mode, which calculates the panel elevation using the SolarCalculator library, the manual mode receives the required elevation through the ESP8266 module, which communicates with the user application.

The user application allows the user to select the automatic or the manual mode and, in the case of the latter, to select what is the desired inclination for the solar blinds. It also allows the user to see graphically the power produced by the solar panels.

In order to calculate the power production, it was introduced a resistor of about 39 Ω at the end of the circuit. The voltage that passes through that resistor is read by the Arduino. As the value of the resistor is known, the current is obtained by applying Ohm’s Law and, therefore, it is possible to calculate the power obtained by multiplying voltage with current. After the calculations, the data is sent from the Arduino to the ESP8266.

You can check all the code mentioned in our GitHub repository: https://github.com/JoaoRibeiro0306/SolarBlinds.