Keywords

1 Introduction

The International Telecommunication Union (ITU) has defined the IoT as a global infrastructure for the information society that enables the provision of advanced services by connecting (physical and virtual) things, based on existing and evolving interoperable information and communication technologies [1]. The IoT, or as it is called the Internet of Everything (IoE), includes all devices that can communicate with the Internet and that can collect, send and process the data they capture from their surrounding environment using embedded sensors and processors in addition to the communication networks [2, 3]. IoT applications are expected to equip billions of objects with connectivity and intelligence [4]. It is already being deployed extensively, in various fields, namely: wearables [5], smart buildings [6], smart cities applications [7], health care [8], agriculture [9], industrial automation [10], solar monitoring systems [11], etc. In this chapter, we leverage some of the IoT technologies to design and build an IoT-based solar tracker system, where an IoT application is proposed to control and monitor this system.

To maximize the absorption of sunlight and thereby increasing energy production, it is necessary to integrate solar tracker systems into conventional solar energy systems, where the solar panels can be fixed on a structure that moves according to the sun’s path. 10–50% additional output energy can be obtained by using solar tracker systems that track the sunlight instead of conventional systems that attach at a fixed angle [12]. Depending on the mechanisms used to orient the solar panels, solar tracker devices can be divided into single or double axis devices. Single-axis devices can only track sunlight by rotating around a horizontal or vertical axis, i.e. they track the sun’s movement in one direction (toward East and West or toward South and North). While dual-axis solar tracker devices can rotate vertically and horizontally to ensure solar panels are always perpendicular to the sunlight [13]. Various solar tracker systems have been reported in the literature and they differ according to employed tracking methods [14]. For instance, a sensor-based solar tracker has been proposed in our previous works, it uses light sensors to predicts the sun’s position (intensity of light) to track the sun for maximum power generation [15, 16]. The solar tracker system detects the sun position with the help of Light Dependent Resistor (LDR) sensors and sends the data to the controller. This latter then processes these data to command two servomotors that rotate a photovoltaic (PV) panel, in the optimal directions, to move toward the sunlight. For more details, authors in [17] have categorized solar tracker systems based on five tracking methods: sensor-based tracker method, geometric and astronomical equation-based method, open- or closed loop-based method, artificial intelligent-based method, and a combination of two or more of these methods. Indisputable that solar tracker systems have manifested a high ability for increasing the efficiency of solar panels to produce more energy. Besides, making a solar tracker device as a connected object using IoT technologies can be more profitable and advantageous, where the user can remotely control the device and access its data, including the electrical and environmental parameters linked to the solar panels, from an IoT platform. These data can be used to evaluate the solar tracker operation, as well as to assess the PV energy potential, early detection and diagnosis of electrical faults, evaluate the weather variations, and preventive maintenance.

However, to the authors’ knowledge, there are only a few attempts available in the literature that deal with this subject. Authors in [18] have developed a dual-axis solar tracker with IoT monitoring using the Ubidots IoT platform. A WiFi ESP8266 board has been employed to connect their tracker device with the internet to communicate with the IoT monitoring application, where its data, including voltage, current, and power are displayed. The same WiFi board has been used by the Authors in [19], who have elaborated a single axis solar tracker, to send the same mentioned data to the cloud server of the ThingSpeak IoT platform so that they can be visualized in a dashboard that preconfigured on ThingSpeak. Furthermore, a monitoring solution of a solar tracker using Raspberry Pi3 (RPi3) board and a personal developed cloud server has been established in [20]. It uses socket programming using Python language to communicate between the “client” that runs on a remote laptop and “server” that runs on RPi3. There are two ways to design an IoT monitoring platform, either we design it ourselves, or using one of the available IoT platforms, which most of them are open source. By using the second way, the development process of an IoT project can be done easily and as early as possible. Because IoT platforms are designed to reduce an IoT project development time by enabling ready-made, reusable technology stack and are compatible with and support various hardware platforms (such as Arduino and Raspberry) [21]. To this end, IoT platforms are widely used by engineers and researchers in their IoT projects [22,23,24,25].

This chapter aims to present a simple and low-cost IoT solution to monitor and control a dual-axis solar tracker system. A low-cost and popular embedded board (Arduino) is used along with LDR sensors, servomotors, and associated circuits to control a PV panel to track the sunlight for maximum power generation. Different sensors are employed to measure electrical output parameters (voltage, current, and power) and environmental parameters (temperature, humidity) linked to the solar tracker system. An Ethernet shield is used to connect the system over the Internet and to exchange data between hardware and the cloud server using Message Queuing Telemetry Transport (MQTT) protocol. Data processing and activities that occur can be monitored online through an IoT monitoring application developed on Cayenne IoT platform. The solar tracker can also take commands from the monitoring platform. In addition, the application includes an alert system to notify the user when a sensor has reached a certain predefined event. The hardware and software used have been chosen to be simple and inexpensive. Arduino board is used due to its low-cost and its easy-to-use hardware and software [26, 27]. Likewise, Cayenne IoT platform is used due to its easy-to-use interface and protocols. It is an open-source IoT platform that has a simple Application Programming Interface (API) to store and retrieve data from things using the MQQT protocol over the Internet or via a Local Area Network [28].

The rest of this chapter is structured around three sections. Section “Research methodology” describes the architecture of the proposed IoT-based solar tracker system and presents the hardware and software used to develop it. Section “Results and discussion” lists and discusses the experimental results. Finally, the main conclusions of this chapter are drawn in Section “Conclusion”.

2 Research Methodology

2.1 System Description

The proposed IoT-based solar tracker system is depicted in Fig. 1. It is a dual-axis solar tracker that can rotate automatically to track the sun position using LDR sensors, or manually by the user through the dashboard of an IoT application. The system starts with detects the sun position (intensity of light) by LDR sensors and sends the data to the controller (Arduino Mega board). This latter then processes these data to command servomotors (SM1 and SM2) that hold the PV panel to rotate toward the sun. The values of the generated PV voltage and current, temperature, and humidity are also sent to the Arduino through associated sensors. Next, the Ethernet shield, which is mounted with Arduino and allows it to be connected to the Internet, will send the data that has been taking and/or processed by Arduino to the cloud (webserver). Lastly, the solar tracker data, including LDR sensors, PV power, temperature, and humidity, are displayed in real time in the IoT monitoring application via pre-created Widgets. The IoT monitoring application is designed using Cayenne myDevices platform. Once the user is connected to the internet from his computer or smartphone, he can visualize, in the dashboard of the IoT application, all solar tracker data in their associated widgets. Therefore, the user has the necessary data linked to the environment and performance of the PV panel. In addition, in the manual mode, the servomotors will take angle directions from their associated widgets in the dashboard. Hence, the user can control his system to seek the best environmental conditions and extract the maximum energy from the PV panel. The IoT application is also programmed to send notification alerts (SMS or Email) when a senor reaches a predefined threshold value.

Fig. 1
figure 1

Schematic of the IoT-based solar tracker system

2.2 Hardware Design

As shown in Fig. 2, the IoT solar tracker system consists of the PV panel, two servomotors, four LDR sensors, a voltage divider circuit, temperature and humidity sensor, a Led and the Arduino Mega board.

Fig. 2
figure 2

Electronic circuit of IoT-based solar tracker system

The used PV panel is 115 by 85 mm in size with a 1.6 W output and can generate a voltage up to 6 V [29]. Two 180° servomotors are used to motorize the solar tracker and they are controlled by the Arduino board through PWM pins 5 and 6. The left-right (L-R) servomotor (MG996R) rotates the solar tracker on the vertical axis (East/West), while the Up-down (U-D) servomotor (SG90) rotates the solar tracker on the horizontal axis (South/North).

Four LDRs (Cds GL5528) are used to sense the sun’s position and which have been fixed in the four corners of the PV panel. The LDR sensors are connected to the Arduino through analog pins from A0 to A3. The LDR is a resistor whose value decreases with increasing light intensity incident on its surface. The LDR sensor is designed as a voltage divider circuit as can be seen in Fig. 2. The output of the voltage divider is connected to an analog input (A0 for instance) of the Arduino. Then, the Analog to Digital Converter (ADC) of the microcontroller converts the analog value read by A0 into a digital value between 0 and 1023 because the ADC is coded in 10 bits. The value of the series resistor in the LDR sensor circuit is 330 Ω.

The temperature and humidity are measured through the DHT22 sensor, which is an ultra-low-cost sensor that is widely used in embedded projects. DHT22 has a thermistor and a capacitive humidity sensor embedded in it to measure temperature and relative humidity. Its temperature range is from −40 to 80 °C with < ± 0.5 °C of accuracy, and its humidity range is from 0 to 100% with ± 2% (Max ± 5%) of accuracy [30]. This sensor uses one signal wire to transmit data to Arduino (digital pin 2), and two wires for power supply.

The PV voltage and current are measured through a voltage divider circuit that acts also as a load and which consists of two series resistors of 10 Ohms. The divider circuit output is connected to the Arduino’s analog pin A4. Furthermore, a LED, which is connected to digital pin 3, reflects in the system circuit the mode state of solar tracker (manual or automatic).

The Arduino Mega with ATmega2560 microcontroller is used as the embedded controller that interacts with the Arduino Ethernet shield along with the monitoring platform. The Ethernet shield, which is mounted above the Arduino board, must be connected with a Wi-Fi router (or PC) through an RJ45 cable as shown in Fig. 3. The Ethernet Shield is based on the Wiznet W5100 Ethernet chip that provides a network (IP) stack for TCP and UDP protocols [31].

Fig. 3
figure 3

Hardware interface between Arduino and Ethernet shield

2.3 Prototype

Figure 4 presents the solar tracker prototype in its detached and assembled state. It consists of the PV panel, the L-R, and U-D servomotors and LDR sensors. The panel is attached to the U-D servomotor on one side and with a bearing on the other side to ensure better flexibility when the solar tracker rotates around the horizontal axis. The assembly is attached to the L-R servomotor. The LDR sensors are fixed in the four corners of the panel inside hollow cylinders. If the panel is not perpendicular to the sun, at least one LDR will be covered by shadow caused by the surrounding cylinder. Hence, there will be a difference in light intensity. The best orientation is when the light intensities are equal in all LDR sensors. Figure 5 shows the entire prototype of the IoT-based solar tracker system, and it is clear that all reported components in the hardware part have been used to build it.

Fig. 4
figure 4

Solar tracker prototype in its detached and assembled state

Fig. 5
figure 5

IoT-based solar tracker prototype

2.4 Software Design

  1. a.

    Arduino IDE

Arduino is an open-source electronics prototyping platform with easy-to-use hardware and software [32]. The Arduino platform provides an integrated development environment (IDE), which includes support for C and C++ programming languages. The used Arduino board in this work is programmed by the IDE that serves as a code editor and from which the program code can be uploaded to the microcontroller through USB cable, as can be shown in Fig. 3. The Arduino Megaboard is utilized to implement all software requirements of the IoT-based solar tracker.

  1. b.

    MyDevices Cayenne

myDevices is a company that offers IoT solutions. It offers an end-to-end platform for the IoT. In our project, we will focus on Cayenne, one of the solutions from myDevices. This tool allows developers, designers, and engineers to build prototypes of the IoT. Cayenne uses the Message Queuing Telemetry Transport (MQTT) protocol to connect any device with the Cayenne cloud. Once connected, the user can send and receive data from the device to the Cayenne dashboard via the Widgets created. MQTT is a publish–subscribe messaging protocol based on the TCP/IP protocol. The publish–subscribe methodology uses a message agent that is responsible for delivering messages to the client. The MQTT is the API for sending information to the Cayenne cloud, or devices controlled by Cayenne. The messaging agent in this connection is the cloud, it manages the different clients (sensors and actuators) that send and receive the data.

To use MQTT with Cayenne, we need to use the Cayenne libraries. For Arduino, the CayenneMQTT library can be installed from the IDE’s Library Manager. To program our Cayenne IoT platform-based IoT application, we will take advantage of the predefined functions. For example, to establish the connection between Cayenne cloud and Arduino Mega equipped with the Ethernet module, we call the CayenneMQTT Ethernet library where we declare our authentication information (the username, password and the ClientID) which should be obtained from the Cayenne Dashboard. Then, in the setup part of the program, we call Cayenne.begin () function to establish the connection with Cayenne dashboard. For each actuator, we create a function with an integer parameter between 0 and 31 imperatively called CAYENNE IN (VIRTUAL CHANNEL). For each sensor, we create a function with an integer parameter between 0 and 31 imperatively called CAYENNE_OUT (VIRTUAL_CHANNEL). In the loop part of the program, we call the predefined function Cayenne.loop (), this function itself calls the functions CAYENNE_OUT and CAYENNE_IN. The virtual channel as its name suggests is a channel that does not physically exist, it characterizes visualization or command widgets. It allows them to be linked with the corresponding sensor or actuator.

  1. c.

    The Embedded Software Design

The embedded software is the piece that will be embedded in the Arduino Megato interact between the Ethernet module and Cayenne cloud (see Appendix). It is designed as follow:

  1. (i)

    The IoT-based solar tracker has two function modes: manual and automatic. A button created in the Cayenne dashboard has a role to switch between the two modes. When it is inactive, the manual mode is selected, otherwise automatic mode. Besides, a function is established in the Arduino code that allows recovering the state of the button. The LED in the system circuit reflects the state of this switch.

Therefore, for the controller to know the selected operating mode, we just need to test the state of the pin in which the LED is connected. For example, if the LED state is low, the controller will call the manual mode function to execute, otherwise, it will call the automatic function.

  1. (ii)

    If the manual mode is selected, the user can directly control the positions of the servomotors to orient the PV panel from east to west by L-R servomotor or from south to north by the U-D servomotor. The control is made from the associated widgets of servomotors in the dashboard of the IoT application.

In this mode, the controller calls Cayenne.loop () function which itself calls all the functions CAYENNE_IN, including those related to servomotors, to execute. The Cayenne.loop () function will also call all the functions CAYENNE_OUT, linked to the sensors, to execute. Where the data related to LDR sensors, PV current, voltage and power, temperature and humidity would be sent to the server so that they can be visualized in their associated widgets in the IoT application.

  1. (iii)

    If the automatic mode is selected, the algorithm shown in Fig. 6 will be executed. The algorithm starts by reading the analog values returned by LDR sensors. Then, it processes these data to command servomotors that move the PV panel toward the sun position. Considering the vertical axis-based solar tracker movement, the average values of the two LDRs on the left and the two LDRs on the right are compared and if the lefts receive more light, the PV panel will move in that direction (clockwise) through the L-R servomotor. The latter will stop when the difference result is between −10 and 10. This range is used to stabilize the controller and to reduce the power consumption of servomotors. Otherwise, if the right set of LDRs receives more light, the PV panel will move in that direction (Counterclockwise) through the L-R servomotor and will continue to rotate until the difference result is in the range [−10, 10]. The same approach is used for the horizontal axis-based solar tracker movement where the average values of the two LDRs on the top and the two LDRs on the bottom are compared.

    Fig. 6
    figure 6

    The flowchart for the automatic mode of the solar tracker

As well as in the automatic mode, the controller will also call the Cayenne.loop () function to send the solar tracker data to the IoT application.

For

  1. d.

    Development of the IoT Monitoring Application

  2. (i)

    Hardware interfacing with Cayenne IoT platform

To interface the hardware, including sensors and actuators, with the IoT platform, we need to follow the next steps:

  • Log in on Cayenne myDevice website after creating an account (Fig. 7a).

    Fig. 7
    figure 7

    Cayenne IoT Platform sign up (a). Cayenne API (b)

  • Then, click on “Bring Your Own Things” from Cayenne API (Fig. 7b).

  • Copy the MQTT credentials (username, password and client ID) from Create App (Fig. 8), and paste them in Arduino source code as described previously. After successfully compiling and uploading the entire code to Arduino Mega, open Serial Monitor in Arduino IDE to get the Cayenne log prints (Fig. 9). As soon as our device comes online and connects to Cayenne, the previous page (Fig. 8) is automatically updated and we will see our device in the online dashboard as can be seen in Fig. 10.

    Fig. 8
    figure 8

    MQTT credentials and device connection to Cayenne

    Fig. 9
    figure 9

    Cayenne log prints on Serial Monitor

    Fig. 10
    figure 10

    Device settings

  • Then, to interface sensors and actuators, i.e. create their widgets, click on “Add new…”, select “Device/Widget” and click on “Custom Widgets” (Fig. 11). Then, select a widget and populate all its associated settings (the channel number must be the same as in code), and finally click on “Add Widget” to add it to the dashboard of your device. For us, we chose the “value” widget for all sensors, “Button” widget for mode switch and the “Slider” widget for servomotors.

    Fig. 11
    figure 11

    Cayenne custom widgets

Finally, Fig. 12 illustrates the designed IoT application for monitoring solar tracker data. Once the connection with the solar tracker system is established, sensor data can be visualized on their associated widgets, the tracking mode (automatic or manual) can be selected from the switch button, as well as controlling servomotors’ angles through their widgets. Sensor data can also be obtained in graphical form by modifying the representation type in their settings, or just by clicking on the graph icon above the widget.

Fig. 12
figure 12

IoT monitoring application of solar tracker system

  1. (ii)

    Alerts creation

One of the most important criteria in a monitoring system is its ability to send notification alerts to inform users when an event, related to their monitored devices, occurs. To this end, we take advantage of one of Cayenne’s features [33] to add alerts to our IoT application, where we can preprogram our application to send a notification alert (SMS, Email, or both) or to perform a specified action. For example, a temperature alert is created to send an email notification to the user (or recipients) when the monitored temperature is reached a threshold value, as can be shown in Fig. 13. To create an alert, click on “Add new…” and select “Trigger”, then set the event and its action and finally click on “save” to add it to the dashboard.

Fig. 13
figure 13

Temperature alert configuration

3 Results and Discussion

Different tests have been carried out to examine the developed IoT-based solar tracker prototype. The experimental setup is illustrated in Fig. 14. The Arduino board is powered with the computer through a USB cable, which is also used to display, in the Serial Monitor of Arduino IDE, the measured parameters and data received from the IoT application. This will allow us to verify whether the captured data from Arduino are correctly and in real-time sent to the IoT application or not. Whereas, Arduino can be powered with an external DC power supply. The Ethernet shield connects the Arduino board to the internet via RJ45 cable. Once the connection with the IoT application is established, the data of the solar tracker system are sent to the monitoring application, where we can view these data live and send commands to the controller.

Fig. 14
figure 14

The experimental setup of the prototype

The system is programmed to send all data from the device regardless of the tracker mode (manual or automatic). First, the automatic mode has been tested, which is activated when the switch mode is in the high state; the LED (mode indicator) in the circuit lights up. The servomotors were automatically controlled according to intensities captured by LDR sensors. Figure 15 presents the samples of data recorded in real time from the solar tracker system in the IoT application during the test period. Figure 15a displays the recorded electrical measurements, namely the current, voltage and power. While Fig. 15b displays the recorded environmental measurements, namely the temperature, humidity and the intensity of light (captured by the top-right LDR) with the accurate time and date. It has been verified, by comparing the data sent from Arduino and those received on the dashboard of the IoT application, that all electrical and environmental measurements are sent properly and in real-time.

Fig. 15
figure 15

Samples of data recorded in real time in the IoT application

To check the reliability of the monitoring application to notify the user when an event occurs, it has been programmed to send an alert. For example, when the monitored temperature is higher than 40 °C. Figure 16 shows the alert notification received in our mailbox at the same time when the temperature exceeds 40° as can be seen in Fig. 15b. Other alerts can be added to the application, such as a malfunction of one of the sensors and/or actuators and a rapid decrease in PV power.

Fig. 16
figure 16

The received notification alerts in the mailbox

Moreover, the proposed IoT prototype has been tested in manual mode, which is activated when the switch mode is in the low state; the LED in the circuit turns off. The servomotors were controlled through their associated widgets in the dashboard. For instance, we have set the slider linked to the L-R servomotor at the center (i.e. at a value of 0.5) and the other slider of U-D servomotor at 0.3, which means that the L-R and U-D motors will rotate by 90° and 30°, respectively. Also, tests have shown that solar tracker properly and rapidly executes commands from the monitoring platform with a time not exceeding 2 s. In the manual mode, the user can remotely position his device in an optimal direction according to the surrounding environment and device location. Moreover, in this mode, the power consumption of motors can be too minimized or, where the user can intervene to position the solar tracker for example in only one direction according to each month or season (winter, spring, summer, and autumn) in the year. However, an amount of PV energy can be lost due to a limitation of the solar tracker operation according to the daily movement of the sun. The servomotor commands can be programmed beforehand without user intervention by creating events and associated actions in the IoT application.

4 Conclusion

In this chapter, a smart prototype has been designed to monitor and control a dual-axis solar tracker system using a simple and efficient IoT solution. The prototype has been tested experimentally. Test results demonstrate that the developed IoT-based solar tracker provides users with a simple monitoring application, in which users can easily and in real-time monitor electrical and environmental parameters of the solar tracker system for further processing and management. Other sensors could be added, for example, solar irradiation and wind sensors to help understand more about the PV power output as well as to test the solar tracker system on its flexibility during high wind. Due to its simplicity, the proposed IoT solution can be employed in various fields to connect devices or things to the internet as well as for research or educational purposes.