You are on page 1of 13

6.

Green energy

6.1 Project Purpose

The goal of this project is to work with other electrical devices, read data from them from
multiple pins and to assemble a more complex system which produces electricity.

What you need:

● 1 Low Power Meter


● 1 Grove cable
● 1 Servomotor with propeller
● 1 Photovoltaic panel
● 1 Multimeter

Figure 1. What you need


6.2 Theoretical notions

6.2.1 The Low power meter

In this lab, we will generate electrical current by using alternative, green power sources such as
wind or solar energy and in order to measure the voltage and the current generated, we will
need an electrical device which will work as a voltmeter and ammeter. The main board knows
how to measure voltage (it is the value it reads from a pin), however it cannot measure current.
Therefore, we will use the low power meter device which measures both parameters and sends
them to the main board.

Figure 2. Low power meter schematic

The overly simplified schematic of the board can be seen above. Basically, the board measures
the voltage and the current that comes from the electricity generator through a voltmeter and an
ammeter provided by the device.

The board also exposes a Grove socket through which it sends analog signals which represent
the voltage and the current measured by our device. Therefore, the grove socket should be
connected to an analog grove socket on the main board. As you might notice in scheme above,
we have two pins through which the values for the V​out and I​out are
​ sent. As a result, if we
connect the grove to the A0 grove socket, we will have A0 pin for current and the A1 pin for
voltage.

Unfortunately, the values sent by the device are not actual real values, since it contains multiple
amplifiers which alter them in order for the device to be able to send them.

For the current, the formula which defines the dependency of the real current on the output
current is shown below:

I ​ ​= Iout
​ ​* 10 / 33

For the voltage, it is a bit more complicated. The general formula from which we get the actual
voltage is:

V = V​out*​ D * 3.3 / 1023 / M

The values for the D and M are manually set by hardware, on the board with the help of a
jumper. On the back of the device are the values we can set for M (x1 or x2) or for D ( /1.1 or
/4).

Figure 3. Low power meter back side

Depending on the values selected, we can measure different voltages:

● D = 1.1 and M = 1 -- which makes the device return the exact input voltage to the output;
this, however, means that we get a regulation of a maximum 3V input.
● D = 1.1 and M = 2 -- which allows a maximum input of 1.5V; ​this will be used for the
servomotor with propeller.
● D = 4 and M = 1 -- which allows a maximum input voltage of 8V; ​this will be used for the
photovoltaic panel.
● D = 4 and M = 2 -- which allows a maximum input of 4V to 5V.

After you choose the correct values for the chosen application, turn the device on the other side,
and switch the jumpers on the correct pins.

Figure 4. Low power meter jumpers

In our case, the jumper for D is set for the lower two pins, which means we have a value of 1.1
for D and the jumper for M is set on the left two pins, which means we have a value of 2 for M.
As you might notice, this is the setup needed for connecting a servomotor to the device.

The servomotor we will use is a ​rotary actuator that allows precise control of angular position,
velocity and acceleration. It is basically a motor with a position feedback sensor. It can be used
either for generating electrical current or as a consumer.

The photovoltaic panel is a panel which consists of solar cells made out of materials which
exhibit the photovoltaic effect.

6.2.2 The LCD

An LCD (​L​iquid ​C​rystal ​D​isplay) is a flat, compact screen that uses liquid crystals’ properties in
order to make specific patterns that allow or block light to pass through. It is basically a matrix of
pixels that you can control so that each pixel is either visible or not. Because the liquid crystals
do not emit light itself, the LCD requires a backlight, which lights up the crystals so the pattern
can be seen.

The LCD we are going to use in our application is 16x2 LCD which can display data on 16
columns and 2 rows. Therefore, in total, we can display 32 characters on our LCD display.

The LCD is controlled, mainly, through 11 pins, of which 8 pins are the data lines and the other
3 are the control lines. The display also offers other 5 pins which are used for powering the
LCD, backlight and contrast control (we need these pins, because, as mentioned above, the
liquid crystals inside the LCD are not capable of emitting light, so we need an external light
source, which will be controlled through these extra pins).

Now, let’s take a look at the pins exposed by the LCD:

Figure 5. LCD pins

We will not go into further detail about what each of the pins means anymore than what is
shown in the picture above, since it is out of the scope of our project. On our board, as you can
see, we already have a mounted LCD and all the pin purposes shown above are abstracted
through the usage of a few functions which will be discussed below.

6.2.3 Control the LCD


The ​wyliozero module exposes the necessary functions to control the LCD. First of all, we need
to import the module and then initialise the class we use in order to control the LCD on the
device:

display = LabLCD()

In order to clean up the display from previous usage, we need to use:

display.clear()

If we do not use the clear function, the program will overwrite the previous message and some
characters from the previous message might remain (to be more specific, if the new message is
shorter than the previous one, we will see trailing characters).

If we want to write a message on the LCD display, we will have to set the cursor on a line at a
specific position and then write the message.

For example, in order to set the cursor at the beginning of the first line, we use:

display.set_cursor(0,0)

If we want to display the same text on the second line, we use:

display.set_cursor(0,1)

Finally, in order to display actual text on the display we have the following function:

display.message("Current: " + str(current) + " A")

Pay attention! ​Even if you try to write a string longer than 16 characters on a line, only the first
16 will be written, while the others will be discarded.

6.3 Tutorial - Green energy

6.3.1 Measure the servomotor voltage output

We will now use the multimeter in order to measure the maximum output voltage value of the
servomotor.
Figure 6. Multimeter

As shown in the picture above, the multimeter has three main key elements:
● A selection knob, on which you set what you want to measure (Ampers, Volts or Ohms)
and the scale up to which you measure (for example: 2V scale means we can measure
up to 2V; 200mV means we can measure up to 200mV). We will use the 200 mV scale
for the servomotor.
● A display on which we can see the value measured by the multimeter.
● Two Ports to which we have two probes connected (which are most probably needle
tipped).

In order to connect the multimeter to the servomotor, plugin the red probe to the red cable of the
servomotor and the black probe to the black cable of the servomotor (red means ‘+’ or power,
while black means ‘-’ or ground).

After you connect the servomotor to the multimeter, rotate the propeller as fast as possible and
write down four separate values in the table below:

1st voltage measurement

2nd voltage measurement

3nd voltage measurement

4nd voltage measurement


6.3.2 Measure the photovoltaic panel voltage

We will now use the multimeter in order to measure the maximum output value of the
photovoltaic panel. Therefore, in order to do that, connect the photovoltaic panel to the
multimeter similar to the way we did for the servomotor: red probe to the red cable and black
probe to the black cable. After that, allow different sunlight exposures to reach the panel in order
to achieve maximum voltage and write down at least four different measurements:

1st voltage measurement

2nd voltage measurement

3nd voltage measurement

4nd voltage measurement

Remember​ to change the scale of the multimeter to bigger one if ​you see the meter screen
change and then read ‘1’ or to a lower scale if the value is too low.

6.3.3 Connect the device to the board

In this tutorial, we will measure the current and the voltage generated by the servomotor.
Therefore, we will need to set the Low Power Meter in order to be able to measure the voltage
and the current.

Since we have a servomotor, we will set D = 1.1 and M = 2 as explained in the theoretical
section of this lab. Visually, the configuration will have the two jumpers as in the picture below:
one on the last two pins of the D section and the first two pins of the M section.
Figure 7. The low power meter jumpers setup

After that, we will connect the device to the main board. As we mentioned in the ​Theoretical
notions​ part of the project, the data which is sent from the device to the board, is sent through
analog signals and therefore, we must use the analog pins of the board. Choose a grove socket
on the board and write down the names of the 2 pins here:

Voltage measurement pin

Current measurement pin

Pay attention! ​You will use only ​one ​grove socket. However, since two different values are sent
from the Low Power Meter to the board, both of the data pins of the grove socket will be used.
Write the two data pins names.

Then, just connect the device to the board through the designated grove socket.
Figure 8. Low power meter connected to Wyliodrin Lab Station

In our, case when we use the A0 grove, we will get on A1 the value for the voltage and on A0
the value for current.

The next step is to connect the servomotor to the device. The cable from the servomotor should
be connected to the Low Power Meter as shown in the picture below (the red cable to the left
pin and the black cable to the right pin). If it helps, you can check that black cable from the
servomotor corresponds to the red cable from the grove and the black cable corresponds to the
red cable from the grove.
Figure 9. Windmill connected to the device

6.3.4 The code

#import all the functions from the wyliozero module


from wyliozero import *
from time import sleep

# we will use this import in order to round a number which is not integer to maximum
# four decimals
from decimal import Decimal

# mention the pins used for the voltage and the current measurement and set their purpose
pinMode(the_pin_we_chose_for_the_voltage, ‘input’)
pinMode(the_pin_we_chose_for_the_current, ‘input’)

# initialise the class we use in order to control the display


display = LabLCD()

# use a main infinite loop in which we read data from the device
while True:

# make sure the display is clear from previous text


LabLCD().clear()

# read the current output from the device


current = analogRead(A0)
# convert the value read to the actual current value
current = current * 10.0 / 33

# make sure the value is only 5 characters long (first digit, a “.” and maximum 3 other
# digits) so that the message displayed is no longer than 16 characters and can be
# displayed in only one line
current = round(current, 3)

#​ r​ ead the voltage output from the device


voltage = analogRead(A1)

#​ c​ onvert the value read to the actual voltage value


voltage = voltage * 4 * 3.3 / 1023 / 1

# make sure the value is only 5 characters long (first digit, a “.” and maximum 3 other
# digits) so that the message displayed is no longer than 16 characters and can be
# displayed in only one line
voltage = round(voltage, 3)

# set the cursor for the first line


LabLCD().set_cursor(0,0)

# write the voltage value on the first line of the LCD


LabLCD().message("Voltage: " + str(voltage) + " V")

# set the cursor for the second line


LabLCD().set_cursor(0,1)

# write the current on the second line of the LCD


LabLCD().message("Current: " + str(current) + " A")

# sleep for a small amount of time


sleep(0.4)

6.4 Exercises

1. Measure the voltage and current generated by the photovoltaic panel.

Remember!! ​Before​ connecting the photovoltaic panel to the Low Power Meter,​ change the
jumpers ​on the device to be set for measuring the correct output voltage (read again the Low
Power Meter part of the Theoretical Notions section in order to find out how to set up the
device)​. ​If you fail to do so, you will ​break​ the Low Power Meter device!!

2. Compute the energy generated by the photovoltaic panel and by the windmill
(servomotor).
3. Display the energy computed in the previous exercise on the LCD.
4. For one of the energy sources you want to use: photovoltaic panel and servomotor,
connect it to the board through the Low Power Meter device, compute the energy
generated, connect the house that we used in the previous lab and turn an LED on
based on how much energy is generated.
5. Set a threshold value and light up the LED only if the energy generated by the sensor is
higher than a certain value.
6. Work in teams and connect simultaneously the servomotor and the photovoltaic panel
and turn an LED on accordingly to the energy generated in order to see which of the
energy sources generates more power.

You might also like