You are on page 1of 56

Investigation in to Energy Storage of Solar Energy Harvesting Wireless

Sensor Network

Dissertation
By
Hassan Abdelrahman Ali Ahmed
19480
Supervised by: DR.MICHEAL DRIEBERG
Dissertation submitted in partial fulfillment
of the requirements for the
Bachelor of Engineering (Hons)
(Electrical & Electronic)

SEPTEMBER 2016 Semester

Universiti Teknologi PETRONAS,


32610, Bandar Seri Iskandar,
Perak
CERTIFICATION OF APPROVAL

Investigation in to Energy Storage of Solar Energy Harvesting Wireless


Sensor Network

By

HASSAN ABDELRAHMAN ALI AHMED


19480

A project dissertation submitted to the

Electrical & Electronic Engineering Program

Universiti Teknologi PETRONAS

in partial fulfillment of the requirement for the


BACHELOR OF ENGINEERING (Hons)
(ELECTRICAL & ELECTRONIC)

Approved by,

DR.MICHEAL DRIEBERG

UNIVERSITI TEKNOLOGI PETRONAS


BANDAR SERI ISKANDAR, PERAK
SEPTEMBER Semester 2016

i
Certification of Originality

This is to certify that I am responsible for the work submitted in this project, that the original
work is my own except as specified in the references and acknowledgements, and that the
original work contained herein have not been undertaken or done by unspecified sources or
persons.

__________________________________
Hassan Abdelrahman Ali Ahmed

ii
Abstract

Solar Energy Harvesting Wireless sensor networks (SEH-WSNs) have enabled a wide
variety of applications that require low cost, low power, remote monitoring due to their ease
of deployment coupled with their ability to operate perpetually. However solar photovoltaic
cells do not produce a consistent energy output throughout the day due to shadowing and
varying sunlight intensity therefore the presence of a high capacity storage solution as well as
an energy buffer is vital for continuous operation.

However available energy storage solutions have an extremely limited capacity and
lifetime. An efficient energy storage solution is required to maximize exploitation of solar
energy harvesting mechanisms for WSN applications.

In this project, the suitability of two energy storage solutions, namely NiMH and ultra-
capacitors (commonly referred to as supercapacitors or double layer capacitors) is
investigated for wireless sensor network applications. A suitable hybrid energy storage circuit
is designed for a hardware prototype that consists of a solar panel, sensor node, energy storage
circuit as well as a voltage monitoring mechanism for controlling the switching and
monitoring the behavior of the prototype

iii
Acknowledgement

This work would not be possible without the blessings of Allah.

I would like to thank the esteemed Dr. Micheal Drieberg for his enlightened supervision, kind
assistance and precious feedback.

This work would not be possible without the cooperation of UTPs lab technicians who were
kind enough to give me access to the universitys lab equipment.

This work would not be possible without the coordination of UTP.

This work would not be possible without the social support of my family and friends.

iv
Table of Contents
CERTIFICATION OF APPROVAL .......................................................................................... i

Certification of Originality......................................................................................................... ii

Abstract ..................................................................................................................................... iii

Acknowledgement..................................................................................................................... iv

Table of Contents ....................................................................................................................... v

LIST OF FIGURES ................................................................................................................. vii

LIST OF TABLES .................................................................................................................. viii

Abbreviations and Nomenclature ............................................................................................ viii

CHAPTER 1 PROJECT BACKGROUND ............................................................................... 1

1.1 Background of Study ................................................................................. 1


1.2 Problem Statement ..................................................................................... 2
1.3 Objectives .................................................................................................. 3
1.4 Scope of Study ........................................................................................... 3
CHAPTER 2 LITERATURE REVIEW .................................................................................... 4

2.1 WSNs ......................................................................................................... 4


2.2 SEH-WSNs ................................................................................................ 4
2.3 Energy Storage Architecture for SEH-WSN ............................................. 8
2.4 Previous works and implementations ........................................................ 9
CHAPTER 3 METHODOLOGY ............................................................................................ 11

3.1 Hardware and Software tools required .................................................... 13


3.2.1 Software Tools .......................................................................... 14
3.2.2 Components and Hard ware Tools ............................................ 14
3.2 Tests ......................................................................................................... 23
3.3.1 Testing the voltage monitoring method .................................... 23
3.3.2 Analog switch test ..................................................................... 24
3.3.3 Solar panel and supercapacitor test ........................................... 25
3.3.4 DC Converter Test ................................................................................... 25

v
3.3.5 Power Management Algorithm ................................................................ 26
3.3.6 Arduino Ethernet and Data Logger Shield test ........................................ 28
3.3.7 Testing the Full Circuit without the DC Converter .................................. 28
3.3.8 Full Circuit Test ....................................................................................... 29
CHAPTER 4 RESULTS AND DISCUSSION ........................................................................ 31

4.1 Voltage monitoring test results ................................................................ 31


4.2 Analog switch test results ........................................................................ 31
4.3 Solar panel and Supercapacitor test ......................................................... 32
4.4 DC converter test ..................................................................................... 33
4.5 Power management algorithm test........................................................... 34
4.6 Testing the Arduino Shield ...................................................................... 35
4.7 Full circuit without DC converter ............................................................ 35
4.8 Full Circuit Test ....................................................................................... 36
CHAPTER 5 CONCLUSION AND RECOMMENDATION ................................................. 38

REFERENCES......................................................................................................................... 39

APPENDIX 1.Power Management Code ................................................................................ IX

vi
LIST OF FIGURES
Figure 2.1 Solar panel characteristics [11] ................................................................................ 5
Figure 2.2 Energy harvesting system architecture [6]Energy Storage Solutions for SEH-
WSNs[3]..................................................................................................................................... 6
Figure 2.3 Energy Storage Architecture Block Diagram [7]. ................................................... 8
Figure 2.4 Power management algorithm [7] ......................................................................... 10
Figure 3.1 FYP 1 Gantt chart .................................................................................................. 11
Figure 3.2 FYP 2 Gantt chart .................................................................................................. 12
Figure 3.3 Maxim MAX 4544 SPDT analog switch................................................................ 14
Figure 3.4 NiMH battery discharge behavior [14] ................................................................. 16
Figure 3.5 AA battery holder for 3 cells (cytron.com.my ) .................................................... 16
Figure 3.6 Charging phenomena in supercapacitors ............................................................... 18
Figure 3.7 DC converter [15] .................................................................................................. 20
Figure 3.8 IC adapter............................................................................................................... 20
Figure 3.9 Schottky Diode ...................................................................................................... 21
Figure 3.10 Arduino Mega [16] .............................................................................................. 21
Figure 3.11 Arduino Ethernet Shield ...................................................................................... 22
Figure 3.12 Voltage test circuit ............................................................................................... 23
Figure 3.13 Analog switch test................................................................................................ 24
Figure 3.14 Solar panel and supercapacitor test...................................................................... 25
Figure 3.15 DC converter connection ..................................................................................... 26
Figure 3.16 Power management Algorithm ............................................................................ 27
Figure 3.17 Arduino Ethernet and data logger shield test ....................................................... 28
Figure 3.18 Testing full circuit without DC converter ............................................................ 29
Figure 3.19 Full schematic using Altium designer .................................................................. 29
Figure 4.1 Analog switch test results ...................................................................................... 32
Figure 4.2 Supercapacitor charge-discharge behavior ............................................................ 33
Figure 4.3 DC converter test ................................................................................................... 33
Figure 4.4 Power management algorithm test......................................................................... 34
Figure 4.5 Testing Ethernet Shield ......................................................................................... 35
Figure 4.6 Full circuit without DC converter test ................................................................... 35

vii
Figure 4.7 Full circuit test ....................................................................................................... 36
Figure 4.8 Operation during night time (8pm to 5:51pm) ...................................................... 36
LIST OF TABLES

Table 2.1 Power density comparison of energy harvesting technologies ................................. 5


Table 2.2 Property comparison [2]............................................................................................. 6
Table 2.3 SEH-WSN specifications [4] .................................................................................... 9
Table 3.1 MICAz specifications [13] ...................................................................................... 15
Table 3.2 NiMH Specifications [14] ....................................................................................... 15
Table 3.3 Supercapacitor Specifications ................................................................................. 17
Table 3.4 Solar panel specifications........................................................................................ 19
Table 3.5 DC Converter Specifications [15] ........................................................................... 20
Table 3.6 Arduino Mega specifications [16]........................................................................... 22
Table 3.7 Specifications .......................................................................................................... 22
Table 4.1 Voltage test values .................................................................................................. 31
Table 4.2 DC converter test .................................................................................................... 34

Abbreviations and Nomenclature

WSNs Wireless Sensor Networks


SEH Solar Energy Harvesting
DLC Double Layer Capacitor
SPDT Single Pole Double Throw

viii
CHAPTER 1
PROJECT BACKGROUND

1.1 Background of Study

A wireless sensor network (WSN) is a combination of sensors nodes, also known


as motes, to automatically obtain information from their surroundings, without any
human intervention and send it to a common base for monitoring, intelligent processing
and control [1]. A myriad of application areas are available for WSNs, some
instantiations of such applications are, machine failure diagnostics, vehicle tracking,
atmospheric pollution control and volcano monitoring [2], [3] & [4].

WSNs require a long network lifetime if they are to operate in total autonomy
therefore a sustainable energy source is needed to power the sensor node as battery
capacity is limited therefore a sustainable energy harvesting mechanism is vital [3].
Among the most common energy harvesting technologies are vibration, piezoelectric
and thermoelectric and solar cells [1]. In outdoor applications solar energy is found to
have the highest power density, 15 /2 , with solar energy being readily available
in daytime, making this the most practical energy source for outdoor WSN applications
[1]. Solar energy harvesting is the energy harvesting method selected for this project due
to the aforementioned reasons [5].

A critical factor that must be taken in to consideration when working with WSNs
is energy storage due to the need for these sensors to operate continuously over extended
periods of time[1]. To achieve this, a variety of battery storage solutions for a solar
energy harvesting wireless sensor network system are explored in this project, these are
NiMH,

1
Li ion, thin film batteries and supercapacitors. A hybrid combination of NiMH batteries and
supercapacitors is selected for this project. A prototype is developed by integrating this hybrid
storage combination with a solar panel as the energy source and a sensor mote as the load.
The final step is monitoring the behavior of the prototype to draw conclusions and to ensure
proper functioning of the prototype therefore voltage monitoring is done using an Arduino
microcontroller. An Arduino Ethernet shield with a micro SD card slot is used for storing the
values.

The quantity of harvested energy from the solar cells is inconsistent therefore the
energy storage will need to be optimized to minimize outage time to ensure continuous
operation of the sensors. The effectiveness of this system will be evaluated in terms of the
energy storage capacity, efficiency and reliability of the power management algorithm and
lifetime of the system. The overall lifetime of the system depends on the number of recharge
cycles of the rechargeable batteries and the time period of each recharge cycle. To monitor the
systems efficiency, the voltage at various points will be measured and monitored to ensure
proper operation of the energy storage circuit.

To the best knowledge of the author, hybrid energy storage systems for SEH-WSNs
utilizing NiMH batteries coupled with supercapacitors have not yet been developed and the
author aims to explore this hybrid energy storage combination.

1.2 Problem Statement

Perpetually operating SEH-WSNs require a reliable and robust energy storage solution
in order to operate over an extended period of time with little to no maintenance however
available energy solutions have an extremely limited capacity and lifetime.

2
1.3 Objectives

This project has two main objectives, the first of which is to select a suitable hybrid
energy storage solution from the most commonly used energy storage solutions for WSNs,
namely NiMH, Li-ion, DLCs, and thin film batteries.

The second objective is to develop a working hardware prototype consisting of the


hybrid energy storage solution combined with a solar panel, sensor mote and a DC-DC
converter for regulating voltage to the output, a switching mechanism and an Arduino
microcontroller for monitoring voltage and controlling the switching mechanism accordingly
as well as to ensure proper functioning of the prototype.

1.4 Scope of Study

The scope of this study consists of research on the four aforementioned energy storage
solutions and choosing a hybrid combination for this project. A prototype of the chosen
combination is designed and developed with a voltage monitoring mechanism and a power
management algorithm to control the switching between the different energy storage
solutions. The voltage monitoring mechanism also serves the purpose of monitoring the
overall behavior of the prototype and to ensure its proper functionality.

Hybrid energy storage combinations for SEH-WSNs consisting of DLCs and Li-ion
batteries have been previously tested, in this project however, a hybrid combination of NiMH
batteries and DLCs is investigated to form a combination that provides adequate energy and
has a long lifetime.

3
CHAPTER 2
LITERATURE REVIEW

2.1 WSNs

A wireless sensor network is a network of collaborating embedded devices with


sensing, computation and wireless communication capabilities, used for sensing and
data collection for application specific analysis [4], [5] & [6]. Wireless sensors can
monitor physical or environmental conditions, such as temperature, sound, pressure and
moisture and pass this information to a common base [5], [7].

The small physical size and placement flexibility of WSNs, as well as their ease
of deployment makes them suitable for a variety of monitoring and measuring
applications, attracting a great deal of interest from the industry as well as the academia
[2]. WSN will play a fundamental role in many intelligent building and internet of things
applications that integrate process and technology in order to increase safety, comfort
and productivity for humans [1], [8], [9] & [10]. However this technology will not
remain feasible unless WSNs maintain their flexibility by operating autonomously, with
energy storage being refilled via ambient energy sources [2].

2.2 SEH-WSNs

The conversion of energy from an ambient source in to electrical energy is the


main principle of operation behind energy harvesting systems [5]. The first step in
energy harvesting systems is conversion of the ambient energy in to electrical energy
[5]. In SEH-WSNs, this energy conversion is performed by solar photovoltaic cells.

4
The most suitable energy source for wireless sensor networks that are installed
outdoors is solar energy due to its high power density of 15 /2 , making SEH the most
efficient energy source for WSNs installed outdoors [1] & [6]. A power density comparison
(in mw/cm^2) between solar cells and other harvesting technologies is shown in the table
below. The table shows that solar cells capture much more power per centimeter squared than
piezoelectric, vibration and other harvesting technologies.

Table 2.1 Power density comparison of energy harvesting technologies[6]

A solar panel is used to capture solar energy to operate the WSN [7]. A graph of
current and power versus voltage for a typical solar cell is shown in the figure below. The
graph shows the maximum power point of the solar panel and shows the difference between
the open circuit voltage of the solar panel and maximum power voltage of the solar panel. The
maximum power voltage of a solar panel is the voltage at its terminals when it operates at the
MPP (maximum power point) meanwhile the open circuit of the solar panel is the voltage at
its terminals when no load is connected at its terminals.

Figure 2.1 Solar panel characteristics [11]

5
However, as the energy output of solar cells is inconsistent throughout the day, there is
a need for DC-DC converters or other regulation mechanisms to stabilize the output voltage
and ensure a steady voltage despite fluctuations generating by varying sunlight intensity. This
regulation mechanism must be implemented for the energy storage and load as well to ensure
a stable energy supply to the sensor motes.

Figure 2.2 Energy harvesting system architecture [6]Energy Storage Solutions for SEH-WSNs[3]

The three energy storage solutions under analysis are shown in the table below along
with a property comparison of these energy storage solutions.

Table 2.2 Property comparison [2]


Supercapacitor Thin-Film Li-ion Battery NiMH
Battery Battery

Typical capacity tens of F uAh to mAh few Ah few Ah


(11 F = 7.028
mAh)

Voltage range (V) 0 to 2.5 3 to 4.1 3.3 to 4.2 1 to 1.3

Temperature Range -25 to 70 -40 to 85 -20 to 60 -20 to 65


(Celsius)

Internal resistance tens of m tens of m hundreds of tens of m


m

Recharge cycles 105 to 106 10000 300 to 500 500 to 1000

As the energy capacity of the DLC in the table above is stated in farads, a relation is derived
between mAh and F in order to enable a proper comparison of the DLCs capacity with the
other storage solutions.

6
The derivation is as follows:
- To convert J to mAh:
60 60
= 3.6
1000
- Multiply both sides by V:
3.6 = =

1 2 1
= = 2
2 2

- Equation to obtain energy in mAh given capacitance in F and voltage in V:


3.6 = 0.5 2
1
: =
7.2

- For the DLC in table 1, assuming a capacitance of 11F and a voltage of 4.6 V:

11
= 4.6 = 7.028
7.2

This shows that DLCs have the smallest capacity when compared with the capacities shown
in table 1, Ah to mAh for thin film and few Ah for Li-ion battery and NiMH battery.

Supercapacitors can be used as storage devices as they store electric charge at an


electrolyte or metal interface, this makes them more fit for providing short energy bursts due
to their high power density [1]. Supercapacitors also have a large number of recharge cycles
and hence have a very long lifetime [2]. Another advantage of supercapacitors is that the
range of operating temperatures is very high [7].

Thin film batteries offer a long lifetime and low capacity similar to supercapacitors
and they also offer a higher cell voltage [2]. High internal resistance in thin film batteries

7
however is the main disadvantage, leading to large voltage drops in event of connection of a
load [2]. High internal resistance also prohibits the battery from fast recharge.

Li+ batteries have a longer cycle lifetime than NiMH batteries and they also have a
lower self-discharge rate than NiMH batteries leading to an overall advantage for Li+ in terms
of efficiency [7]. Li+ have a high energy density and high endurance which makes it suitable
for operation in energy autonomous sensor nodes [7].

2.3 Energy Storage Architecture for SEH-WSN

The figure below shows one of the most commonly used energy storage architectures
for the SEH-WSN. The photovoltaic (PV) panel, battery and supercapacitor are each
interfaced with a DC-DC converter. The three converters are connected in parallel to a DC
bus, which acts the main power supply to the sensor motes [7]

Figure 2.3 Energy Storage Architecture Block Diagram [7].

The DC-DC PV converter that interfaces the PV cell to the DC bus also realizes the
maximum power point tracking (MPPT) of the PV panel [7]. MPPT enables the solar panel to
produce optimal output through continuous tracking [5]. Due to the low DLC voltage, the
DC-DC converter connected to it steps down the voltage when the DLC is drawing current
from the circuit as the maximum DLC voltage is in the range of 2.5-2.7V [7]. However when
the DLC is supplying current to the circuit, the converter steps up the voltage to align it with
the DC bus voltage [7].This architecture can be used to test the behavior of the
aforementioned energy storage solutions.

8
2.4 Previous works and implementations

This section highlights the specifications of some of the previous works that have been
done in the area of energy storage for SEH-WSNs.
Table 2.3 SEH-WSN specifications [4]
Solar Energy Battery
Storage Sensor
Node Panel Availability Capacity
Type node used
(mW) (mWh/day) (mAh)
Hydrowatch[4] 276 139 NiMH 2500 TelosB
(100F,2.5V)
Everlast[4],[8] 450 2700 Supercap N/A
34.72
Supercap
(two 22F, For each
Prometheus[10] 130 780 Telos
2.6v& Li capacitor =7.94
battery)
Supercap
For each
(two 22F,
AmbiMax[9] 400 1200 capacitor = Telos
2.3v& Li
7.03v
battery)

The table is a summary of some of the SEH-WSN implementations and their specifications.
The mAh capacity for supercapacitors is calculated using the relation derived in section 2.2.

A vital element of hybrid energy storage solutions for SEH-WSNs is the power
management algorithm which facilitates switching from one energy source to the other at the
appropriate time to ensure maximum exploitation of the available energy storage solutions
and leveraging on the different properties provided by each solution.
The figure below shows a power management algorithm implemented on a hybrid
energy storage solution for a WSN [7].

9
Figure 2.4 Power management algorithm [7]

The algorithm above is divided in to six modes, the first of which is the off state,
where all the storage solutions are fully discharged. The second stage is the soft start stage,
where the solar module provides sufficient energy to power the controllers and the process is
started. As the solar module supply energy begins to increase, the supercapacitor begins to
charge, this is the third stage. The fourth stage which is the battery charge stage starts if the
battery voltage is less than the maximum and the battery dc convertor is enabled. The over
voltage stage is a protection stage where the input is disabled to avoid damaging the
supercapacitor by over charging it. The supercapacitor is disconnected in this stage while the
battery is still charging. The last stage is the battery discharge stage, which occurs when the
supercapacitor voltage is below 0.8 volts. This indicates that the supply power is not enough
to operate the load therefore the battery begins to discharge across the load.

10
CHAPTER 3
METHODOLOGY

This section elaborates on the tools and components used as well as the methods
of testing, the timeline of the project and the proposed architecture of the prototype,
theory of operation and relevant calculations.

The figures below contain the Gantt Charts for FYP I and FYP II. Each key
milestone of the project is denoted by an asterisk.

Figure 3.1 FYP 1 Gantt chart

The first key milestone is the end of the circuit design phase. This is a vital and
perhaps the most tedious phase as a sound and logical design ensures correct flow and
progress of the project. A significant amount of time is dedicated to this phase as any
mistakes in the design phase can be costly and can have a significant impact on the
project flow line.

11
Figure 3.2 FYP 2 Gantt chart

In the FYP II, the focus is on implementation. The circuit and tests are
implemented and the final prototype is produced, tested and verified.

The block diagram below shows the proposed architecture of the prototype
which consists of a solar panel connected to DLC via a schottky diode. The solar panel
and DLC are connected to a NiMH battery via another schottky diode and an SPDT
analog switch.

Figure 3.1 Block diagram for prototype

12
Another schottky diode and analog switch connects the solar panel and
supercapacitors to the load via a switched capacitor DC converter. The load is the Micaz
mote and the dc converter provides a constant voltage output to operate the mote.
Schottky diode 1 prevents reverse current from flowing to the solar panel and it
has a smaller voltage drop (0.2v) as compared to a conventional diode (0.7v). Schottky
diode 2 prevents the battery from discharging in the pathway used for charging.
Schottky diode 3 prevents any current from the battery from flow in the wrong direction
and charging the supercapacitor. An Arduino Mega microcontroller is chosen to monitor
voltage at key points in the prototype (shown via red arrows) and to run the power
management algorithm and control the two analog switches.

The testing process is divided in to stages building up to the final prototype.


Dividing the testing process in to these stages eases the process of troubleshooting by
slowly building up to the desired prototype while ensuring that every stage is
functioning as expected. The steps are as follows:

1) Testing the voltage monitoring mechanism.


2) Testing the analog switches.
3) Testing the solar panel with the supercapacitors and the load.
4) Testing the DC converter
5) Power management algorithm test.
6) Testing the Arduino data logger shield.
7) Testing the solar panel, supercapacitors, analog switch and battery and load.
8) Testing the full circuit.

3.1 Hardware and Software tools required

This section highlights the tools and components used, including their specifications.

13
3.2.1 Software Tools

1) Altium Designer: circuit simulation software.


The circuit schematics shown in this report including that of the final prototype are
designed using Altium Designer.
2) Arduino IDE: Arduino integrated development environment
The Arduino code for power management is written in the Arduino IDE. The IDE can
also be used to display the voltages being measured when monitoring the behavior of the
prototype.

3.2.2 Components and Hard ware Tools

1) Maxim MAX4544 SPDT Analog Switch (2 units required)

There are two MAX4544 switches used in this project. This first one switches
from the solar panel and supercapacitor to the battery to power the load. The other
switch controls the charging of the NiMH battery. Pin 7 (IN) of the analog switch is the
trigger pin, this is connected to the Arduino microcontrollers digital pin to control the
switch based on the voltages of the solar panel, supercapacitor and NiMH battery. The
Arduino digital pin can be set as HIGH (logic 1 or 5v) or LOW (logic 0 or 0v), based on
this logic, we can control the switch as shown in the figure below [12].

Figure 3.3 Maxim MAX 4544 SPDT analog switch


2) MICAz : this is the sensor mote used in this project (1 unit required)
The energy storage system designed in this project is based on the specifications of the
MICAz mote. This is a 2.4 GHz Mote module that is used for enabling low-power,
WSNs [13].

14
Table 3.1 MICAz specifications [13]
Current drawn by RF transceiver : Receive mode 19.7 mA
Current drawn by RF transceiver : , -10 dBm 11 mA
in TX (transmit) mode , -5 dBm 14 mA
, 0 dBm 17.4 mA
Current drawn : sleep mode 1A
Maximum current 30 mA
Batteries 2x AA batteries
Operating voltage (External power) 2.6V DC 3.6V DC

Figure 3.2 MICAz mote [13]


3) NiMH : rechargeable battery (3 units required)

Table 3.2 NiMH Specifications [14]


Chemical System Nickel-Metal Hydride (NiMH)
Nominal voltage of each cell 1.2 V
Maximum voltage of each cell 1.4 V
Rated capacity (mAh) 1500 mAh at 21C
Temperature (Charge) 0C to 40C
Temperature (Discharge) 0C to 50C
Humidity 65 +/- 20%

Figure 3.3 NiMH battery

15
Three energizer rechargeable batteries are connected in series to produce a total
nominal voltage of 3.6v [14]. When the series combination is fully charged, the voltage
of the combination is at the maximum 4.2v. The nominal voltage of a battery is the
voltage measured halfway between the full charged and the fully discharged positions.
Three batteries were selected in order to match the voltage with the solar panel and
supercapacitor voltages in order to eliminate the need for DC converters or voltage
regulators.
The figure below shows the discharge behavior of the battery from a maximum
voltage of 1.4v to 0.9v. It is expected that the battery will last for almost 10 hours when
discharging at a current of 150 mA.

Figure 3.4 NiMH battery discharge behavior [14]

4) AA battery holder for 3 cells (1 unit required)

Figure 3.5 AA battery holder for 3 cells (cytron.com.my )

16
5) Supercapacitor : Panasonic Double Layer Capacitor (2 units required)
Table 3.3 Supercapacitor Specifications
Maximum operating voltage 2.3v
Capacitance 22F
Internal resistance < 0.1 (ohm)

Figure 3.4 Supercapacitor

Two supercapacitors are connected in series to produce a combined voltage of


4.6v; this is to eliminate the need for a DC converter to interface the supercapacitor with
the rest of the circuit.

Supercapacitors can store a much greater amount of charge that regular


capacitors. Activated carbon electrode material with a short charge separation distance
and large surface area created by the opposite charges in the interface between the
electrode and electrode are responsible for the large energy content [1]. Despite their
long lifetime however, supercapacitors have low storage capacity as well as a high self-
discharge rate and are easily affected by whether conditions [2].

17
Figure 3.6 Charging phenomena in supercapacitors
Supercapacitors play an important role in this energy storage design as the
supercapacitor is the first to discharge in the event of insufficient energy output from the
solar panel. Two supercapacitors are connected in series (as shown below) in the
prototype in order to increase the voltage.

Figure 3.5 Supercapacitor series combination

The calculation for the total capacitance and voltage of the series combination is as
follows:

1 1
() = = = 11
1 1 1 1
1 + 2 22 + 22

() = 1 + 2 = 2.3 + 2.3 = 4.6

18
The calculation for the energy capacity of the series combination using the relation
derived in section 2.2 is as follows:

11
= 4.6 = 7.028
7.2

6) Solar Panel: Flexible USB solar panel (1 unit required)

Figure 3.6 Solar Panel

Table 3.4 Solar panel specifications


Power max 1.5 W
Current MPP 300mA
Voltage MPP 5V

7) DC - DC Converter: Texas Instruments LM3670MF-3.3/NOPB, SOT23 Buck


(Step Down) (1 unit required)

LM3670 is a step down DC-DC converter that is optimized for powering low
voltage circuits [15]. The maximum load current that it can provide is 350mA which is
suitable for this application as the sensor mote draws a maximum current of 30 mA.

19
Table 3.5 DC Converter Specifications [15]
Input Voltage Range 2.5 5.5V
Output Voltage 3.3 V DC
Output Current 350 mA

Figure 3.7 DC converter [15]

The figure above shows the DC converter connection for fixed output voltage
application. The connection shown above is implemented in the design of the energy
storage circuit to ensure constant output voltage.

8) IC Adapter SOT 23 to DIP (1 unit required)

Figure 3.8 IC adapter

As the DC converter used in this project is not in DIP format (breadboard format) the IC
adapter shown above is used to perform this conversion.

20
9) Schottky Diode: Through hole Schottky diode (3 units required)

Figure 3.9 Schottky Diode

Schottky diodes are used in this project to stop reverse flow current. Schottky diodes
have a smaller voltage drop (0.2v) as compared to regular diodes therefore they are
selected to be used in this project.
Datasheet: Schottky diode

10) Arduino Mega

An Arduino microcontroller 2560 is a microcontroller board based on the


ATmega2560. It has 54 digital input/output pins and 16 analog inputs, a 16 MHz crystal
oscillator and 4 UARTs (hardware serial ports) [16].

Figure 3.10 Arduino Mega [16]

21
Table 3.6 Arduino Mega specifications [16]

This microcontroller is used in this project to monitor voltage at key points in the circuit
and to control the switching of the analog switches based on these voltage readings.

11) Arduino Ethernet Shield (1 unit required)

The Arduino Ethernet shield has the capability of connecting an Arduino to the internet
however in this project is used for its micro SD card slot. The shield is used to store
voltage data in an SD card to eliminate the need for constant connection to a laptop.

Figure 3.11 Arduino Ethernet Shield

Table 3.7 Specifications


Communication SPI

Micro SD card slot

Standard RJ45 connector

22
3.2 Tests

This section elaborates on the tests that were performed to yield the final
prototype. A systematic design approach is implemented in this project, where each
subsystem in the circuit is tested separately to ensure it is functioning as expected and to
ease the troubleshooting process.

3.3.1 Testing the voltage monitoring method

Voltage can be measuring using an Arduinos analog pin. The analog value is
fed as input to the 10 bit analog to digital convertor (ADC) and it is converted to a
voltage value using cross multiplication where 0v matches 0 ADC value (minimum) and
5v matches the maximum value of the ADC of 1024 (maximum).

In this test three circuits are connected to provide three different voltage values
to be measured by the Arduino. Two Arduino channels are used to measure each of the
voltages.

Figure 3.12 Voltage test circuit

23
3.3.2 Analog switch test

This is a low power single pole double throw (SPDT) switch used for the
purpose of switching between the supercapacitor and the NiMH battery to power the
load. The maximum voltage that can be supplied to power the analog switch is 13V. The
NO (normally open), NC (normally closed) and common can be supplied with a
maximum of V supply + 0.3V (5.3 v).

Figure 3.13 Analog switch test

To ensure proper functionality of the analog switch before it is integrated in to


the SEH-WSN circuit.

A red LED is connected to the NC pin of the analog switch, the same is done at
the NO pin using a green LED. The 5v supply is connected to the common pin, via a 1k
resistor. The red LED should light up immediately. When the analog switch is triggered
using an Arduino digital pin, the NO connection is closed and the red LED lights up. By
observing the behavior stated above, we can ensure that the analog switch is functioning
as expected, this eases the integration process with the complete SEH-WSN circuit.

24
3.3.3 Solar panel and supercapacitor test

The objective of this test is to observe the charging and discharging behavior of
supercapacitors with a solar panel as the power source. The supercapacitor voltage is
monitored using an Arduino along with the solar panel voltage during charging. The
supercapacitor voltage is monitored as it discharges across a 200 ohm load, used to
simulate the sensor mote. This test also serves as a foundation for building the WSN
circuit as the final prototype is based on this circuit. Switch A is closed (connected)
during the charging of the supercapacitor, meanwhile switch B is opened (disconnected).
Once the supercapacitor is fully charged, switch A is opened, disconnecting the solar
panel and schottky diode from the circuit and switch B is closed, enabling the
supercapacitor to discharge across the load.

Figure 3.14 Solar panel and supercapacitor test

3.3.4 DC Converter Test

The DC converter test involves varying the input voltage to the converter and
observing the output to ensure proper functioning of the converter. The circuit shown in
the schematic below is set up and the input voltage is varied from 2.8v to 5v. A 200 ohm
resistor is connected at the output terminal to represent the sensor mote.

25
Figure 3.15 DC converter connection

3.3.5 Power Management Algorithm

A power management algorithm is a set of instructions to control the switching


between the different energy storage solutions available in order to operate the circuit
continuously at maximum efficiency. The power management algorithm developed in
this project consists of five main stages or modes. State zero is the Off Stage, where
the solar panel voltage is very low and not providing enough power to operate the load.
In this mode the supercapacitor and NiMH battery voltages are also too low to power the
load therefore in this stage the solar panel and supercapacitor are connected to the load,
in order to operate the load once the sunlight intensity increases.

The first state is the Supercapacitor Charge stage in which the solar panel
voltage and supercapacitor voltages are between 3.2 and 3.9 volts and the solar panel
voltage is greater than the supercapacitor voltage. In this case the solar panel is
powering the load and charging the supercapacitor.

The second state is the Battery Charge stage where the solar panel and
supercapacitor voltages are above 3.9v and the battery voltage is below 3v. In this state
the solar panel and supercapacitors are powering the sensor mote and charging the
NiMH battery.

26
The third state is the Stop Battery Charging stage where the solar panel and
supercapacitor voltages are still above 3.9v but the battery voltage has reached 3.9v. In
this case charging of the battery stops to avoid overcharging of the battery and the load
is still powered by the solar panel and supercapacitor.

The fourth state is the Supercapacitor Discharge stage in which the solar panel
voltage and supercapacitor voltages are between 3.2 and 3.9 volts and the solar panel
voltage is less than the supercapacitor voltage. In this case the supercapacitor is
powering the load.

The fifth state is the Battery Discharge stage in which the solar panel voltage
and supercapacitor voltages are less than 3.2volts and the battery voltage is greater than
3 volts. In this case the battery is powering the load. The figure is a flow diagram
illustrating the different states in the power management algorithm and the conditions
for the transition from one state to the other.

Figure 3.16 Power management Algorithm

27
3.3.6 Arduino Ethernet and Data Logger Shield test

This shield is used in this project for recording voltage values in the sim card as
the circuit is running. The shield is tested by connecting it to the circuit and
programming it to record the voltages at several points in the circuit and recording those
values in a text file. The figure below shows the shield connected to the Arduino mega
and the micro SD card that is used to store the values.

Figure 3.17 Arduino Ethernet and data logger shield test

3.3.7 Testing the Full Circuit without the DC Converter

The next step in the design process is testing the solar panel, supercapacitor,
battery, analog switches and load without the DC converter. This is to ensure that this
subsystem is working before connecting the final components. At this stage any
mistakes and errors can be identified and corrected. The schematic below shows the
circuit that is tested at this stage.

28
Figure 3.18 Testing full circuit without DC converter

3.3.8 Full Circuit Test

The figure below is the schematic of the final prototype. The design is done
using Altium Designer software.

Figure 3.19 Full schematic using Altium designer

29
A 5v solar panel is used as the power source. The supercapacitor series
combination is rated at 4.6v and functions as an energy buffer, absorbing any
fluctuations in the solar panel voltage and taking over once the solar panel is no longer
providing enough voltage to power the load. The supercapacitors are connected to the
NiMH battery via a schottky diode and analog switch to isolate the capacitor voltage
from the NiMH voltage as the supercapacitor voltage is expected to drop and rise
multiple times a day as the supercapacitor charges and discharges, isolating the NiMH
battery will ensure that the voltage across it does not rise and fall with the capacitor
voltage, the first analog switch is only triggered (connecting the battery to the rest of the
circuit) when the battery needs to be recharged, otherwise the charge path is
disconnected and the battery is completely isolated from the rest of the circuit. This is
important in order to ensure that the NiMH battery remains at it maximum capacity of
4.2v (3.6v is the nominal voltage of the battery) when it is fully charged to enable it to
power the sensor mote when the supercapacitor and solar panels are unable to do so.

The DC-DC converter converts input voltage in the range of 2.5v up to 5.5V and
produces a constant output of 3.3v which is the optimal voltage for operation of the
MICAz mote, however this is a buck converter so it reduces voltage between 3.3v and
5.5v at the input to 3.3v and any voltage in the range of 2.5v to 3.29v is passed along to
the output unchanged. This is acceptable as voltages in the range of 2.5v to 3.3v are in
the input range that enables the mote to operate. A 220 ohm resistor is used as a load to
simulate the sensor mote, labeled WSN in the schematic. As an output voltage of 3.3v
across a 220 ohm resistor produces a current of 15mA, this is the current that is drawn
by the MICAz mote and is therefore an acceptable representation of the mote.

30
CHAPTER 4

RESULTS AND DISCUSSION

4.1 Voltage monitoring test results

The table below shows the results of the voltage test using the Arduino analog
pins to measure voltage.

Table 4.1 Voltage test values

Theoretical/ V (channel Error % V (channel Error % (Ch


DMM value
Calculated 1) (Ch1) 2) 2)
5v 4.77 v 4.92 1.6 4.94 1.2
2.5 v 2.40 2.44 2.4 2.43 2.8
1.67 v 1.7 v 1.66 v 0.59 1.66 v 0.59

As the error in the results is less than 5% this method can be used to monitor
voltage in this project. This method is more efficient that using a DMM as values are
recorded for monitoring and analysis instantaneously without human intervention.

4.2 Analog switch test results

The analog switch is triggered on and off using the Arduino digital pin and it is
concluded that the analog switch functions as expected and it can be triggered using an
Arduino. The figure below shows that the red LED is on when the switch is not
triggered and the green LED is on when the switch is triggered.

31
Figure 4.1 Analog switch test results

4.3 Solar panel and Supercapacitor test

The schematic in section 3.3.3 is connected and the supercapacitor and solar
panel voltages are recorded as the supercapacitor is charged by the solar panel. The
voltage is measured using an Arduino.

The graph below shows the voltage values as the supercapacitor charges up to
4.5 volts in a time period of 1.61 hours and then discharges to 1 volt across the 220 ohm
resistor in a time period of 1.25 hours. The supercapacitor charging behavior is observed
to be slow, this is due to the low sun light intensity at the time of charging (11:00am on
a cloudy day). The charging is done through a schottky diode meanwhile the discharging
is done across a 220 ohm resistor.

The battery is disconnected when the supercapacitor reaches a voltage of 4.5


volts (not the maximum of 4.6v) to prevent overcharging the supercapacitor and to
enable it to discharge across the load and the solar panel voltage is no longer recorded as
it has been disconnected. As soon as the supercapacitor is disconnected from the solar
panel and connected to the load, it is observed that the supercapacitor begins to
discharge. The supercapacitor takes 0.5 hours to discharge from 4.5v to 2.5 v , with the
minimum input required for the sensor mote to operate.

32
Figure 4.2 Supercapacitor charge-discharge behavior

The fluctuations in the solar panel voltage shown above are the main reason for
placing a supercapacitor in this project, as the supercapacitor can take over in these
instances and eliminate the need for the circuit to switch to the battery. The
supercapacitor is chosen due to its high power density and voltage that matches the rest
of the components. This test proves that the solar panel and supercapacitor are
functioning as expected and the next stage of testing can commence.
4.4 DC converter test

The experimentatal setup shown below is the implementation of the schematic in section
3.3.4 above. The DC converter is connected and the input voltage is varied. The
resulting output is shown in the table below.

Figure 4.3 DC converter test

33
Table 4.2 DC converter test
DC converter input voltage DC converter output voltage
5v 3.307v
3.8v 3.307v
2.8v 2.8v
3.3v 3.25v

The DC (buck) converter functions as expected, any input voltage above 3.3v
and below 5.5v is reduced to 3.3v and any input voltage in the range of 2.5v to 3.29 is
passed along to the output. As the MICAz mote can operate in the range of 2.6v to 3.3v
this is a suitable range.
4.5 Power management algorithm test

The power management algorithm test involved setting certain voltage values in
the code and observing if the Arduino switches to the correct state. The figure shown
below shows that the state transitions correspond to the correct voltages.

Figure 4.4 Power management algorithm test

34
4.6 Testing the Arduino Shield

The Arduino shield test reveals that the shield records the voltage data in a text
file as shown in the figure below. Voltage data is being recorded each second along with
the power management algorithm state that the circuit is currently on.

Figure 4.5 Testing Ethernet Shield

4.7 Full circuit without DC converter


The circuit is functioning correctly as can be seen in the figure below, however the
voltage at the output is slightly lower than the solar panel voltage due to the schottky
diode. The solar panel is powering the load currently and the load voltage matches the
solar panel voltage as there is no regulation of the output.

Figure 4.6 Full circuit without DC converter test

35
4.8 Full Circuit Test

Figure 4.7 Full circuit test

The figure above shows the voltages measured when the full prototype is
operating at midday. The solar panel is covered to observe the switching behavior of the
circuit, the solar panel voltage decreases instantaneously and the circuit switches to
condition 4 from condition 1. The supercapacitor discharges until it reaches the
threshold of 3.2 and then switching occurs to condition 5 where the battery is
discharging to power the load.

Figure 4.8 Operation during night time (8pm to 5:51pm)

36
The figure above shows the circuit operation during night time (8:00pm to
5:51am). This is a full circuit test that is done to enable an estimate of the length of time
it takes for the battery to discharge from 4.2v to 3v. In the test the battery is discharged
from 4.028v to 3.804v in a period of 9.51 hours. From this we can estimate that it would
6 times this amount of time to discharge the battery fully (80% discharge is considered
full discharge). Therefore it would take (9.51 X 6 = ) 57 hours for the battery to fully
discharge. If the battery is used 12 hours per day (7pm to 7am), it is estimate that 1
discharge will last for:

57
= 4.75
12

Assuming 1000 recharge cycles as battery lifetime:

4.75 1000 = 4750


4750
= 13.01
365

Using extrapolation we obtain a rough estimate of the lifetime of the system which is 13
years.

37
CHAPTER 5
CONCLUSION AND RECOMMENDATION

In conclusion the hybrid energy storage system that is successfully designed and
developed enables continuous operation of the wireless sensor mote for an extended
period of time that is estimated to be thirteen years, enabling a wide variety of
continuous monitoring applications. The systems is proved to be a significant
improvement compared to the conventional use of NiMH batteries as the only energy
storage mechanism and having to stop the mote to recharge the batteries using a charger.
This estimated time of 13 years makes this energy storage bypass all other energy
storage circuits that have been developed so for, as the sleep mode of the mote has not
been considered and the estimate is made assuming continuous drawing of 15mA by the
mote which is not the case.

The first recommendation for improving the project is to integrate the power
management algorithm in the Micaz mote, thereby allowing the microcontroller within
the mote to control the switching, eliminating the need for the Arduino microcontroller;
this will reduce the cost as well as the size of the system.

Another recommendation is testing the behavior of the circuit using the Micaz
load instead of simulating the load using a resistor. In real time operation of the mote,
there are fluctuations in the current drawn by the mote as it changes from sleep mode to
active mode. To ensure the effectiveness of this energy storage circuit, it must be
confirmed to operate with the sensor mote. The last recommendation to improve the
project is controlling the enable pin of the DC converter using a microcontroller, this
will enable full control of the energy storage system and enable shutting the converter if
it is supplying the wrong voltage to the mote.

38
REFERENCES

[1] K. Naveen and S. Manjunath, "A reliable ultracapacitor based solar energy harvesting
system for Wireless Sensor network enabled intelligent buildings", 2011 2nd International
Conference on Intelligent Agent & Multi-Agent Systems, 2011.
[2] S. Bader and B. Oelmann, "Short-term energy storage for wireless sensor networks using
solar energy harvesting", 2013 10th IEEE INTERNATIONAL CONFERENCE ON
NETWORKING, SENSING AND CONTROL (ICNSC), 2013.
[3] R. Shelke, G. Kulkarni, R. Sutar, P. Bhore, D. Nilesh and S. Belsare, "Energy
Management in Wireless Sensor Network", 2013 UKSim 15th International Conference on
Computer Modelling and Simulation, 2013.
[4] S. Sudevalayam and P. Kulkarni, "Energy Harvesting Sensor Nodes: Survey and
Implications", IEEE Communications Surveys & Tutorials, vol. 13, no. 3, pp. 443-461, 2011.
[5] S. Bader, X. Ma and B. Oelmann, "On the Modeling of Solar-Powered Wireless Sensor
Nodes", JSAN, vol. 3, no. 3, pp. 207-223, 2014.
[6] V. Raghunathan, A. Kansal, J. Hsu, J. Friedman and M. Srivastava, "Design
considerations for solar energy harvesting wireless embedded systems", IPSN 2005. Fourth
International Symposium on Information Processing in Sensor Networks, 2005..
[7] F. Ongaro, S. Saggini and P. Mattavelli, "Li-Ion Battery-Supercapacitor Hybrid Storage
System for a Long Lifetime, Photovoltaic-Based Wireless Sensor Network", IEEE
Transactions on Power Electronics, vol. 27, no. 9, pp. 3944-3952, 2012.
[8] F. Simjee and P. Chou, "Everlast", Proceedings of the 2006 international symposium on
Low power electronics and design - ISLPED '06, 2006.
[9] C. Park and P. Chou, "AmbiMax: Autonomous Energy Harvesting Platform for Multi-
Supply Wireless Sensor Nodes", 2006 3rd Annual IEEE Communications Society on Sensor
and Ad Hoc Communications and Networks, 2006.

39
[10] Xiaofan Jiang, J. Polastre and D. Culler, "Perpetual environmentally powered sensor
networks", IPSN 2005. Fourth International Symposium on Information Processing in Sensor
Networks, 2005.
[11] "Maximizing the Output from Solar Modules | DigiKey", Digikey.com, 2016. [Online].
Available: http://www.digikey.com/en/articles/techzone/2013/dec/maximizing-the-output-
from-solar-modules. [Accessed: 17- Aug- 2016].
[12] Analog Devices, Low-Voltage, Single-Supply Dual SPST/SPDT Analog Switch,
MAX4544 datasheet, Dec. 2002 [Revised Jun. 2007].
[13] MEMSIC, MICAz, Wireless Measurement System, MICAz Mote datasheet, Rev.A
[14] Energizer, nh15-1500, NiMH rechargeable battery datasheet
[15] Texas Instruments, LM3670 Miniature Step-Down DC-DC Converter for Ultra Low
Voltage Circuits, LM360 Dc converter datasheet, Nov. 2004 [Revised Feb. 2013].
[16] Arduino, Arduino Mega2560, Arduino Mega2560 datasheet

40
APPENDIX 1.Power Management Code
/* This is a power management code written by Hassan Abdelrahman Ali Ahmed
* FInal Year Project at Petronas University of Technology
* Investigation in to Energy Storage of Solar Energy Harvesting Wireless Sensor Networks
*/
//Declaration of the relevent libraries
#include <SPI.h>
#include <SD.h>

File dataFile; //Define the file name for storing data in the micro SD card

#define An_Sw1 14 // Analog Switch Trigger1


#define An_Sw2 15 // Analog Switch Trigger2

int analogInputVolts0 = A3;


int analogInputVolts1 = A4;
int analogInputVolts2 = A5;
int analogInputVolts3 = A7;

float readVoltsADC3 = 0.0;


float readVoltsADC4 = 0.0;
float readVoltsADC5 = 0.0;
float readVoltsADC7 = 0.0;

float V_0 = 0.0;


float V_1 = 0.0;
float V_2 = 0.0;
float V_3 = 0.0;

long counter = 0;
int condition = 0;
int nn;
void setup()
{
pinMode(53, OUTPUT);
Serial.begin(9600);

SD.begin();
dataFile = SD.open("testing.txt", FILE_WRITE);
dataFile.print("stating");
dataFile.close();
//myfile = SD.open("textFile.txt", FILE_WRITE);

///myfile.println("Congratulations! You have successfully wrote on the text file.");

IX
//myfile.close(); // close the file:

pinMode(analogInputVolts0, INPUT);
pinMode(analogInputVolts1, INPUT);
pinMode(analogInputVolts2, INPUT);
pinMode(analogInputVolts3, INPUT);

pinMode(An_Sw1, OUTPUT); ///For connecting NiMH to load


pinMode(An_Sw2, OUTPUT); ///For charging NiMH

delay(1000);

void loop()
{

counter ++;

// File dataFile = SD.open("datalog.txt", FILE_WRITE);

readVoltsADC3 = analogRead(analogInputVolts0);
readVoltsADC4 = analogRead(analogInputVolts1);
readVoltsADC5 = analogRead(analogInputVolts2);
readVoltsADC7 = analogRead(analogInputVolts3);

V_0 = (( readVoltsADC3/1024.0)*5.0);
V_1 = (( readVoltsADC4/1024.0)*5.0);
V_2 = (( readVoltsADC5/1024.0)*5.0);
V_3 = (( readVoltsADC7/1024.0)*5.0);

//int condition;

//Mode 0:Solar & supercap & NiMH cannot power the load. Keep using the solar panel, wait for sun
if( (V_0 < 3.2) && (V_0 > 0) &&(V_1 < 3.2) &&(V_1 >0)&& (V_2 < 3)&& (V_2 > 0) )
{
// Serial.println("OFF State \n ");
digitalWrite(An_Sw1, LOW); ///Disconnect NiMH from load use Solar & Supercap wait for sun to be more bright
digitalWrite(An_Sw2, LOW); /// Do NOT charge NiMH Panel is not supplying enough

condition = 0;
}

//SUPERCAP Charge: Mode 1


else if( ((V_0 < 3.9) && (V_0 > 3.2)) && (V_1 < 3.9) && (V_0 > V_1) )

X
{
// Serial.println("STATE 1: Supercapacitor Charge \n");
digitalWrite(An_Sw1, LOW); ///Disconnect NiMH from load use Solar & Supercap wait for sun to be more bright
digitalWrite(An_Sw2, LOW); /// Do NOT charge NiMH Panel is not supplying enough

condition = 1;
}

//Mode 2: Charge NiMH battery

else if( (V_0 > 3.9) && (V_1 > 3.9) && (V_2 < 3) )
{
// Serial.println("State 2: Battery Charge State \n");
digitalWrite(An_Sw1, LOW); ///Disconnect NiMH from load use Solar & Supercap
digitalWrite(An_Sw2, HIGH); ///charge NiMH

condition = 2;
}
//Mode 3: Stop charging NiMH battery

else if( (V_0 > 3.9) && (V_1 > 3.9) && (V_2 > 3.9) )
{
// Serial.println("State 3: Stop Charging \n ");

digitalWrite(An_Sw1, LOW); ///Disconnect NiMH from load use Solar & Supercap
digitalWrite(An_Sw2, LOW); // Do NOT charge NiMH

condition = 3;
}

//Supercap Discharge Mode 4

else if( (V_0 < 3.9) && ((V_1 < 3.9) && (V_1 > 3.2)) && (V_0 < V_1) )
{
// Serial.println("STATE 4 : Supercapacitor discharge \n");
digitalWrite(An_Sw1, LOW); ///Disconnect NiMH from load use Solar & Supercap wait for sun to be more bright
digitalWrite(An_Sw2, LOW); /// Do NOT charge NiMH Panel is not supplying enough

condition = 4;
}
//Mode 5: NiMH discharges to power the load

else if( (V_0 < 3.2) && (V_1 <3.2) && (V_2 > 3) )
{

// Serial.println("State 5: Battery Discharging \n ");

XI
digitalWrite(An_Sw1, HIGH); ///Connect NiMH to load Don't use Solar & Supercap
digitalWrite(An_Sw2, LOW); // Don't charge NiMH

condition = 5;
}

// Each half hour of Data is stored in a seperate file for troubleshooting purposes

// half hour 1
if ( (counter >= 0) && (counter <= 1800) )
{
// Serial.println("inside if 1");
dataFile = SD.open("txtfile.txt", FILE_WRITE);
//if(dataFile==0) Serial.println("Couldnot open");
//nn=dataFile.print(V_0,3);
//Serial.print("printed:"); Serial.println(nn,DEC);
//nn=dataFile.print(",");
//Serial.print("printed:"); Serial.println(nn,DEC);

dataFile.print(V_0,3);dataFile.print(",");
dataFile.print(V_1,3);dataFile.print(",");
dataFile.print(V_2,3);dataFile.print(",");
dataFile.print(V_3,3);dataFile.print(",");
dataFile.println(condition);
dataFile.close();

}
// half hour 2
else if ( (counter > 1800) && (counter <= 3600) )
{

//Serial.println("inside if 2");

dataFile = SD.open("txtfilee.txt", FILE_WRITE);

//if(dataFile==0) Serial.println("Couldnot open"); //Troubleshooting code


//nn=dataFile.print(V_0,3);
//Serial.print("printed:"); Serial.println(nn,DEC);

dataFile.print(V_0,3);dataFile.print(",");
dataFile.print(V_1,3);dataFile.print(",");
dataFile.print(V_2,3);dataFile.print(",");
dataFile.print(V_3,3);dataFile.print(",");
dataFile.println(condition);
dataFile.close();

XII
// half hour 3
else if ( (counter > 3600) && (counter <= 5400) )
{
//Serial.println("inside if 3");

dataFile = SD.open("datalog.txt", FILE_WRITE);

//if(dataFile==0) Serial.println("Couldnot open");


//nn=dataFile.print(V_0,3);
//Serial.print("printed:"); Serial.println(nn,DEC);

dataFile.print(V_0,3);dataFile.print(",");
dataFile.print(V_1,3);dataFile.print(",");
dataFile.print(V_2,3);dataFile.print(",");
dataFile.print(V_3,3);dataFile.print(",");
dataFile.println(condition);
dataFile.close();

}
// half hour 4
else if ( (counter > 5400) && (counter <= 7200) )
{
//Serial.println("inside if 4");
dataFile = SD.open("datalogg.txt", FILE_WRITE);

//if(dataFile==0) Serial.println("Couldnot open");


//nn=dataFile.print(V_0,3);
//Serial.print("printed:"); Serial.println(nn,DEC);

dataFile.print(V_0,3);dataFile.print(",");
dataFile.print(V_1,3);dataFile.print(",");
dataFile.print(V_2,3);dataFile.print(",");
dataFile.print(V_3,3);dataFile.print(",");
dataFile.println(condition);
dataFile.close();

}
// half hour 5
else if ( (counter > 7200) && (counter <= 9000) )
{
//Serial.println("inside if 5");
dataFile = SD.open("txtdata.txt", FILE_WRITE);

//if(dataFile==0) Serial.println("Couldnot open");


//nn=dataFile.print(V_0,3);
//Serial.print("printed:"); Serial.println(nn,DEC);

XIII
dataFile.print(V_0,3);dataFile.print(",");
dataFile.print(V_1,3);dataFile.print(",");
dataFile.print(V_2,3);dataFile.print(",");
dataFile.print(V_3,3);dataFile.print(",");
dataFile.println(condition);
dataFile.close();

}
// half hour 6 --3 hours complete
else if ( (counter > 9000) && (counter <= 10800) )
{
//Serial.println("inside if 6");
dataFile = SD.open("txt.txt", FILE_WRITE);

//if(dataFile==0) Serial.println("Couldnot open");


//nn=dataFile.print(V_0,3);
//Serial.print("printed:"); Serial.println(nn,DEC);

dataFile.print(V_0,3);dataFile.print(",");
dataFile.print(V_1,3);dataFile.print(",");
dataFile.print(V_2,3);dataFile.print(",");
dataFile.print(V_3,3);dataFile.print(",");
dataFile.println(condition);
dataFile.close();

}
// more than 3 hours
else if (counter > 10800)
{
// Serial.println("inside if 7");
dataFile = SD.open("txtlog.txt", FILE_WRITE);

//if(dataFile==0) Serial.println("Couldnot open");


//nn=dataFile.print(V_0,3);
//Serial.print("printed:"); Serial.println(nn,DEC);

dataFile.print(V_0,3);dataFile.print(",");
dataFile.print(V_1,3);dataFile.print(",");
dataFile.print(V_2,3);dataFile.print(",");
dataFile.print(V_3,3);dataFile.print(",");
dataFile.println(condition);
dataFile.close();

Serial.print("\n");

XIV
//Serial.print(" V solar = ");
Serial.print(V_0,3);Serial.print(",");

//Serial.print(" V supercap = ");


Serial.print(V_1,3);Serial.print(",");

// Serial.print(" V battery = ");


Serial.print(V_2,3);Serial.print(",");

// Serial.print(" V load = ");


Serial.print(V_3,3);Serial.print(",");
Serial.print(condition);Serial.print(",");
//// Serial.print(counter);

delay(1000); // Data is captured each second

XV

You might also like