Professional Documents
Culture Documents
Thesis
Thesis
Thesis
EDUCATION
PROJECT
(Mechanical Design)
by
Also, we have special thanks to Dr. Pham Bach Duong and Mr. Nguyen Thoi,
International Education Exchange Center, Ho Chi Minh City University of Technology
and Education, who always care and support us with valuable hardware design and
programming advices.
Worksheet
Table i. Division of main tasks among members
Members Tasks
3D: 3-Dimension
I / O: Inputs / Outputs
PC: Personal Computer
COM: Communication
GND: Ground
OTA: Over-The-Air
Worksheet
List of figures
List of tables
Abbreviations
Abstract .............................................................................................................................
I. Introduction ..............................................................................................................
References .........................................................................................................................
Appendix ...........................................................................................................................
Abstract
It has become increasingly important in today’s society to know where our food comes
from and that it has not been transported over a long distance due to the environmental
aspects that is brings. This combined with the fact that more people tend to move to
bigger cities gives an increased need for smart solutions for growing vegetables and herbs
on limited spaces at home such as balconies or nearby the windows. This project can
meet their demand, an particularly automatic garden system with planting, watering and
harvesting indoor should be developed. It is essential nowadays, so that people can do
self-cultivation of vegetables and take care of them easily.
The idea of this system is generated from the controlling devices such as robot arm,
stepper motor by using Arduino in order to plant, water and harvest automatically with
the high accuracy. Besides, users can observe the system from other places by using
cameras and control the system by using IoT applications via the Internet lines (with
different wifi addresses).
In conclusion, this smart system can meet the requirement of people in terms of time and
place. In particular, it can be implemented in house due to its small size and exceptional
functions compared to other products.
Keywords: Smart system, planting and monitoring, Robotic Arm, IoT applications,
Arduino for IoT.
Chapter I. Introduction
1.1. Demand of users:
Targeted users are the urban families want to grow green and clean vegetables for the
needs of healthy food for the family but they do not have much time to plant and care,
their houses have modest area as well as they do not have many knowledge and
experiences about agriculture. The need for a smart gardening systems which can plant,
water and harvest automatically, take care of vegetables and herbs or allow users to
remote monitoring and controlling the system that is becoming more practical for every
family.
With the rapid development of IoT, IoT devices are also growing and diversifying. One
device that is considered as popular and accessible today is the Arduino UNO R3. A
flexible, useful microprocessor board. It serves various needs such as: entertainment,
learning, application development. It is easy to connect to computers, with other
arduinos, with other IoT devices, with sensors, etc.
In addition, IoT applications are also numerous, practical and diverse, such as smart
homes, smart wear devices, smart cities, smart electric grids, industrial Internet,
automotive connections, intelligent retail chains, smart farms, etc.
b) Robotic Arm
In the industrial world, automation is one of the most important elements for
development. It helps to reduce the need for humans and increase efficiency and
productivity. The field of automation occupies large areas, mostly in industrial
manufacturing and in addition to this; automation is applied to build a lot of sophisticated
equipment which are used daily such as medical equipment (x-ray machines, radiography
etc.), refrigerators, automobiles etc. Among all of these outcomes, the Robotic Arm is
one of them, which is widely used in industrial proposes.[4]
A Robotic Arm can be compared to a human hand. It has a free rotating joint (rotation)
and a translational joint (displacement) for the movement of the arm. This arm movement
is usually driven by an electric driver (motor) or a pneumatic and a hydraulic system
(pistons). These actuators are controlled by a microcontroller (CPU), usually
programmable and made to perform a set of sequential tasks. Most of these robotic arms
are designed to be used in industrial purposes for fast and reliable performance, helping
for mass productions.[5]
In this project, the control system refers to the development of a system which controls
the automatic movements and accurate positioning of the robotic arm. And this also
includes the designing of a gripper as an end effector. During this designing process, we
are supposed to use our engineering knowledge. This thesis includes various aspects of
Mechanical Engineering; automations (control system), concepts of electronic drives,
general engineering subjects, parts design (strength of materials) and mathematics etc.
The result is that this thesis helps to develop the skills of practical knowledge about the
subject matter in real life.
Capture the explosion of Internet of Things trends, advantages of robotic arm and based
on practical needs, our team chose the topic "Design of a smart system for planting
and monitoring". And to realize the knowledge we have learned about Arduino, our
team will build a smart garden to address the needs of clean vegetables in daily meals,
energy saving, time to care and environmental protection.
The "Smart system for planting and monitoring" will contribute to the process of
industrialization, modernization, technology transfering to every family, improve the
quality of life. Also, this is a solution suitable for the development of modern science and
technology. The system will help guiding us to produce clean food for the family from
the preparation step until the collection of finished products. From anywhere, with an
Internet connection, users can monitor, control and take care of their familes’ small
garden in the most efficient way possible.
1.4. Methods
In this project, some methods are proposed as follows:
a) Smart system using robot arms and IoT system can plant, harvest and take care of
plants automatically. The image of system will be displayed on the website
through camera, so users can easily to manage and follow the status of seeds.
b) To make users feel easier, smart system using robot arms and IoT system can
handle almost of the job. It can sow seeds, water, take care of plants and harvest
plants automatically. It has camera sensor that monitors the health of plants and
send information to users by receiving messages from website, smartphone, and
PC. The automatic robot arm in the system will work in a set up time which can be
adjusted by users.
1.5. Main features of this smart system
Automatic planting, harvesting and caring: The system automatically plants,
waters and harvests vegetables via set-up time.
Monitoring: user can monitor the state of the garden (humidity, temperature, light,
rain, planting time, current development stage, actual image and video) via
software on the smartphone or laptop or website (Thingspeak.com).
Remote controlling: The user can easily control the devices in the garden as
desired via smartphone, laptop or website from anywhere via the Internet.
Notification: The system will notify users whenever there is a problem related to
the garden quickly, fully and promptly.
1.6. Advantages of this system:
Simple, easy to use, full of knowledge to help everyone grow their own
vegetables.
Automated, smart, time-saving.
Maximum cost savings for users.
Meet basic needs for home vegetable production for families.
This smart system uses smart devices and automation technology to help people save
time and effort in planting clean vegetables. The system helps the users enjoy the comfort
of life and easily manage their small garden. Only with a smartphone or a web browser,
they can control, monitor and take care of their beloved garden anywhere.
In smart gardens, electronic devices can connect to the Internet and mobile phones,
allowing owners to remote controlling widgets or schedule devices to automatically
perform tasks. In addition, electronic devices can understand each other's language and
interact with each other.
Edyn includes a database of thousands of plant varieties and soil conditions. It uses
algorithms to directly analyze the data transmitted to the sensor. Both water valves are
also equipped with sunlight sensors. One of the weaknesses of this smart garden system
is the use of lithium-polymer batteries, which is difficult to operate for a long time.
Figure 2.4. Sending notifications and suggestions to users’ Smartphones in real-time[7]
b) Garden Space
Figure 2.5. Garden Space in the real life and its functions[8]
This system is for people who tried and failed at growing their very own vegetables at
home. So the Garden Space Group decided to create a system which has a robotic smart
camera that helps people grow food at home. This smart camera monitors, waters and
protects users’ garden for the three pronged approach to food growing great allowing
asporing and experienced growers like themselves to enjoy the full payoff and benefit of
growing.
Figure 2.6. Smart robotic camera[8]
First, there’s the monitoring Garden Space has a unique 360° camera that keeps watching
on their plants 24/7 and monitors information on plant health and growth rates, so users
know exactly what’s happening in their gardens. And because it’s done by a camera, it
can look over the entire garden no matter its shape or layer. All users have to do is follow
a planting guide on their mobile application or simply tell Garden Space what they’ve
planted.
The third thing Garden Space does is protect users’ gardens. Sensing when uninvited
guests sneak into their garden for a midnight snack. Garden Space got a faces sensor
which targets the pests with water to ward them away keeping users’ plants safe in a
harm freeway. No one but users will get to enjoy their homegrown food.
Figure 2.8. Garden Space water beam to water the plants and ward the pests[8]
Garden place arms users with tools to get the most out of their growing no matter they’re
new or experienced. And just in case they do need help, Garden Space’s mobile
application is available to guide them. Getting started with Garden Space is simple. Just
place the unit in the garden, connect it to water supply and their home wifi, plug in their
standard garden hose and they’re ready to grow. The handy app is their garden command
center.
Figure 2.9. Command center in the mobile application[8]
Plus, thanks to its solar power, so there’s no batteries to replace and saving money for
electric cost. And, it’s also great for the environment.
FarmBot allows people farm from anywhere. Users control and configure FarmBot using
the free FarmBot web application at my.FarmBot.io. FarmBot company expects to
indefinitely offer free service adequate for home growing needs, though they may charge
for commercial or industrial FarmBot usage, for FarmBots larger than 3m x 6m in area,
and/or for FarmBots growing large numbers of plants concurrently. Users can always
host the software on their own server if they do not want to use company’s service.
Graphically design your farm by dragging and dropping plants into the map. The game-
like interface is learned in just a few minutes so you’ll have the whole growing season
planned in no time.
The web app allows users to easily configure and control their FarmBot from a web
browser on your laptop, tablet, or smartphone. The application features real-time manual
controls and logging, a sequence builder for creating custom routines for FarmBot to
execute, and a drag-and-drop farm designer so they can graphically design and manage
their farms.
Figure 2.14. The map for planting in FarmBot’s web appplication[9]
Growing Regimens
Build regimens for taking care of a plant throughout its entire life by scheduling
sequences to run when the plant is a certain age. Regimens can be reused, making
replanting a breeze.
Sequence Building
Quickly create custom sequences to take full advantage of your hardware – no coding is
required. Simply drag and drop basic operations together, adjust the specifications, and
save.
Real-Time Control
Move FarmBot and operate its tools in real-time with the manual controls. Scare birds
away from work or next time friends are over, pull out your phone for a quick and
impressive demo.
MQTT Gateway
Message Queuing Telemetry Transport (MQTT) is a publish / subscribe protocol used for
Internet of Things devices with low bandwidth, high reliability and the ability to be used
in unstable networks.
Because this protocol uses low bandwidth in a high latency environment, it is an ideal
protocol for M2M applications. MQTT has a client / server model, where each sensor is a
client and connects to a server, which can be understood as a broker, through the TCP
(Transmission Control Protocol). MQTT is a message-oriented protocol. Each message is
a fragment of the signal and the broker can not see.[10]
The MQTT Gateway is a cloud application that acts as an intermediary for all messages
between the FarmBot web app and FarmBot devices. It handles socket connections,
device identification, and authentication.[10]
Device Software
FarmBot Raspberry Pi Controller
FarmBot's Raspberry Pi uses this software to maintain a connection and synchronize with
the web application via FarmBot Mesh. This allows FarmBot to download and execute
scheduled events, be controlled in real-time, and upload logs and sensor data. The
controller communicates with the Arduino over USB to send G and F code commands
and also receive collected data.
This software is flashed onto FarmBot's Arduino MEGA 2560 microcontroller and is
responsible for physically operating FarmBot's hardware, tools, sensors, and other
electronics. It receives G and F codes from FarmBot Raspberry Pi Controller via the USB
serial connection, and then moves the motors and reads and writes pins accordingly. It
also sends collected data from the rotary encoders and pin reads back to the Raspberry Pi.
WiFi Configurator
FarmBot OS has a WiFi Configurator utility built in allowing you to easily enter WiFi
and web app credentials from a WiFi enabled device (such as a laptop or smartphone).
This is useful for initial setup in order to get your FarmBot connected to your home WiFi.
External Resources
OpenFarm.cc: OpenFarm is a free and open database for farming and gardening
knowledge. This service provides crop and growing information to the web app for a
streamlined user experienced.
There are many software systems contributing to FarmBot's functionality. The diagram
below shows the different components and how data flows between them.
Figure 2.15. FarmBot Software High Level Overview[9]
Hardware design
Aluminum Extrusions
These black anodized beams serve as both the primary structural element of FarmBot and
its linear guide system, allowing precise movements in the X, Y, and Z directions.
Figure 2.16. Types of Aluminum extrusions[9]
Plates and Brackets
Plates and brackets are stamped and machined out of high grade aluminum alloys. Then
they are tumble polished to remove burrs, sandblasted to remove surface defects, and
anodized to achieve a premium quality aesthetic and feel. Please note that some non-
structural components may be made of plastic in future kits.
Plastic parts
The plastic components have been injection molded with ABS or precision machined
from Delrin. They are both tough and able to withstand UV rays.
Figure 2.22. Plastic parts of FarmBot[9]
Fasteners and Hardware
All fasteners are made of stainless steel, allowing them to stand up to the outdoor
environment without rusting or corroding.
- Waste management
- Environmental management
- Smart shopping
- Management of personal devices
- Intelligent gauges
- Home automation
The impact of IoT is very diverse, in the areas of infrastructure management, health,
construction and automation, transportation, etc. Specifically in the medical field, IoT
devices can be used to remote monitoring health and emergency notification systems.
Health monitoring devices can range from blood pressure and pulse rate to advanced
instruments capable of monitoring special implants, such as pacemakers or advanced
hearing aids. In the area of infrastructure management, IoT monitors and controls the
activities of urban and rural infrastructure such as bridges, railways and farms as an
important application of IoT. The IoT infrastructure can be used to track any events or
changes in structural conditions that may be within the safety threshold.
A robotic arm is a type of mechanical arm, usually programmable, with similar functions
to a human arm; the arm may be the sum total of the mechanism or may be part of a more
complex robot. The links of such a manipulator are connected by joints allowing either
rotational motion (such as in an articulated robot) or translational (linear) displacement.
The links of the manipulator can be considered to form a kinematic chain. The terminus
of the kinematic chain of the manipulator is called the end effector and it is analogous to
the human hand.[5]
The end effector, or robotic hand, can be designed to perform any desired task such as
welding, gripping, spinning etc., depending on the application. For example, robot arms
in automotive assembly lines perform a variety of tasks such as welding and parts
rotation and placement during assembly. In some circumstances, close emulation of the
human hand is desired, as in robots designed to conduct bomb disarmament and disposal.
In the industrial world, automation is one of the most important elements for
development. It helps to reduce the need for humans and increase efficiency and
productivity. Robotic Arm is one of them, which is widely used in industrial proposes. A
Robotic Arm can be compared to a human hand. It has a free rotating joint (rotation) and
a translational joint (displacement) for the movement of the arm. and to construct a
gripper which used for pick and place any material as well as to draw any alphabet on the
board that draws by user in the paint. It also used for drilling, cutting and painting
purpose. The following thinks are involved in this: Designing a layout for a Robot and
other components together, Wiring Design and wiring installation, Designing the gripper
& Programming. On the other hand, in case of mass-produced goods, customized control
systems are economic due to the lower cost of the components, which can be optimally
chosen instead of a "generic" solution, and where the non-recurring engineering charges
are spread over thousands or millions of units.This robotic arm useful in large scale
industries for pick and place purpose, paint on any car and machine, etc. These robotic
arms are designed to be used in industrial purposes for fast and reliable performance,
helping for mass productions.
The Robotic Arm shown in figure 2.34 is from the HAMK laboratory which was
designed and constructed by Nicolas Mustaka (an exchange student from Greece, 2009).
This robot has six axes which are driven by DC motors (24Vdc) and it is made to be
controlled manually by using sets of two potentiometers for each joint. To control a
single joint, two potentiometers are used connected to each other in a feedback amplifier
circuit. The comparator circuit compares the voltage between the axis potentiometer and
the driver potentiometer, and it drives the motor in two directions depending on the
The output voltage for driving the motor depends upon the two potentiometers voltage
value: the driving potentiometer and the axis potentiometer. Two potentiometers are
integrated into the feedback amplifier circuit. The driving potentiometer voltage works
like an input voltage and it can be set by the user whereas the axis potentiometer works
like feedback voltage, altering the output. The axis potentiometer voltage depends upon
the position of the axis and its changes due to the rotation of the axis. When the input
voltage and feedback voltage are in the same phase, then the output becomes positive
and it drives the motors in a positive direction until the input voltage(driving
potentiometer) and the feedback voltage (axis potentiometer) have the same voltage
value. When the input voltage and feedback voltage are in the inverse phase, then the
output becomes negative and it drives the motors in a negative direction until these
voltages are the same. In every case, the direction of the motor is set in such a way that
it rotates to change the voltage of the axis potentiometer the same as the driving
In general, the arm of a robot has a number of joints .The current approach to the design
of control system for robot joints is to treat each joint of the arm as a simple joint
servomechanism, ignoring the effect of the movements of all other joints. In industrial
robots, hydraulic or pneumatic actuators may be used rather than dc servomotors. Due to
it's excellent speed and position control characteristic ,the dc servomotors has been
widely used in industry ,therefore the actuator is assumed to be an armature-control dc
motor[13]. In addition it is assumed that the robot arm is connected to the motor through
gears. PID controllers have been widely used for speed and position control of robot arm.
This paper endeavors to design a system using Genetic Algorithm (GA). GA is a
stochastic algorithm based on principles of natural selection and genetics. GAs are a
stochastic global search method that mimics the process of natural evolution. Using
genetic algorithms to perform the tuning of the controller will result in the optimum
controller being evaluated for the system every time. The objective of this paper is to
show that by using the GA method of tuning a system , an optimization can be achieved.
This can be seen by comparing the result of the GA optimized system against the
classically tuned system.[14]
𝐾𝑖
𝐾𝑝 + + 𝐾𝐷 𝑆
𝑆
Figure 2.35. The block diagram of the robot joint control system[15]
Tuning of PID controller using genetic algorithm approach
GA is a stochastic global adaptive search optimization technique based on the
mechanisms of natural selection. Recently, GA has been recognized as an effective and
efficient technique to solve optimization problem. Compared with other optimization
techniques. GA starts with an initial population containing a number of chromosomes
where each one represents a solution of the problem which performance is evaluated by a
fitness function. Basically, GA consists of three main stages: Selection, Crossover and
Mutation. The application of these three basic operations allows the creation of new
individuals which may be better than their parents[13]. This algorithm is repeated for many
generations and finally stops when reaching individuals that represent the optimum
solution to the problem. The GA architecture is shown in Figure 2.36.
Genetic Algorithm For PID Tuning
The implementation of the tuning procedure through genetic algorithms starts with the
definition of the chromosome representation. The chromosome is formed by three values
that correspond to the three gains to be adjusted in order to achieve a satisfactory
behavior. The gains Kp , Ki and Kd are real numbers and characterize the individual to
be evaluated. The objective function is the calculation of its associated fitness. The
fitness function is the measure of the quality of chromosome and can be defined as.[15]
Figure 2.36. Simulation flow chart for the computation of GA-PID controller
specifications[15]
b) Ziegler -Nichols Rule For Tuning PID Controller
The control system performs poor in characteristics and even it becomes unstable, if
improper values of the controller tuning constants are used. So it becomes necessary to
tune the controller specifications to achieve good control performance with the proper
choice of tuning constants. Controller tuning involves the selection of the values of Kp,
Ki and Kd. By setting Ki =0 and Kd=0, we obtain the closed- loop transfer function. The
value of Kp that makes the system marginally stable so that sustained oscillation occurs
can be obtained by use of Routh's stability criterion.[16]
When using PID technology in the robot, the results show that the robot is not working as
expectations. The theological reason is that the values of Kp, Ki and Kd are not
satisfactory. Each robot has a different physical characteristics, so the coefficients must
also change accordingly. The proposed method below can determine the values of Kp, Ki
and Kd using a flow-chart.[16]
In conclusion, The step responses under PID controller tuned by GA for three fitness
functions are faster than that response under PID controller tuned by Zigler –Nichols.
However, the Zigler –Nichols method is good for giving the designer the initial guess for
the PID tuning. The step response under PID controller tuned by GA is better in terms of
minimizing the max overshoot, the rise time and the settling time .Finally the mean
square error associated with GA-PID controller is less than the error associated with
conventional approach.
Figure 2.37. Flow-chart for correcting of PID[16]
Introduced in 2005, Arduino designers try to provide an easy, inexpensive way for lovers,
students and professionals to create devices that interact with the environment through
sensors and actuators. Common examples for beginner lovers include simple robots,
temperature controls, and motion detection. Comes with it is an integrated development
environment (IDE) running on common PCs and allows users to write programs for
Aduino in C or C ++.
The price of Arduino boards fluctuate around 150,000 vnd - 600,000 vnd. It is estimated
that by mid-2011 more than 300,000 Arduino artefacts have been commercially
produced, and that by the year 2013, about 700,000 official circuits have been shipped to
consumers.
The Arduino Board will put most of the I / O pins of the microcontroller to use for those
external circuits. Diecimila, Duemilanove, and now Uno offer 14 digital I / O pins, 6 of
which can generate pulses PWM (pulse width modulation) and 6 analog input pins,
which can be used as 6 I / O pins. These pins are designed above the board surface,
through the 0.10-inch (2.5 mm) header. Many shield application plug-ins are also
commercially available. Arduino Nano boards, and Arduino-compatible Bare Bones
Boards and Boarduinos can provide male header pins on the board's upper side for
plugging into breadboards.
Many extensions to Arduino are implemented by adding output drivers. Some variants
use different processors, with varying degrees of compatibility.
Arduino programs are written in C or C ++. The Arduino IDE comes with a software
library called "Wiring", from the original Wiring project, which can make input / output
operations easier.
The Arduino IDE uses the GNU toolchain and AVR Libc to compile the program, and
uses avrdude to upload the program to the board. Since the Arduino platform is the Atmel
microcontroller, the development environment of Atmel, AVR Studio or newer Atmel
Studio versions can also be used to make software development for Arduino.
Arduino is chosen as the processing brain of many devices from simple to complex.
Among them, there are several applications that really demonstrate the superiority of the
Arduino because of their ability to perform many complex tasks. The following is a list
of some of Arduino's outstanding applications:
Arduino Uno R3 is a 3rd generation Arduino Uno, the most popular Arduino family in
the current Arduino line. It has a very powerful application from simple to complex:
flashing strobe control, remote signal processing, temperature gauge, robot, etc.
Kit Arduino Uno is a microcontroller board based on the AVR ATmega328 chip. Thus,
the board has 14 digital inputs / outputs (6 pins can be used as PWM pulse width
modulation pins), 6 pins acting as analog inputs. Analog Inputs, 16MHz quartz oscillator,
USB connection, separate power supply with AC-DC adapter, RESET button and ICSP
connectors.
2. USB Port: The USB port on the Arduino board connects to the USB cable
3. Reset button: The reset button is used to reset the running program. Sometimes the
program runs error, the user can reset the program.
5. Signal output: There are all 14 output pins in the Arduino Uno, the pins marked with ~
are pins that can be pulsed (PWM), which can control the motor speed or brightness.
lights. Figure 2.40 shows very clearly the pins to this pulse.
6. IC ATmega 328: IC Atmega 328 is the soul of the Arduino Uno motherboard, which is
used in data acquisition from sensor, data processing, output signal, etc.
7. ICSP pins of ATmega 328: ICSP pins of ATmega 328 are used for SPI (Serial
Peripheral Interface) interfaces, some Arduino applications use this pins, such as using
RFID module RC522 with Arduino. or Ethernet Shield with Arduino.
8. Analog Signal Pin: These pins take the analog signal from the sensor to the IC Atmega
328 processor. There are 6 pins for Analog signal, from A0 to A5.
9. Power supply for sensors: These pins are used to power external devices such as
sensors, RC servos, etc. On this area there are available GND pins (ground pins, negative
pins) 5V pin, 3.3V pin as shown in Figure 2.40. Thanks to these pins, the user does not
need the power transformer when supplying the sensor, role, servo rc ... Also in this area
there are Vin foot and foot reset, IOREF foot. However, these pins are not commonly
used so please do not go into it.
10. External Power Source: The external power outlet uses external power sources such
as batteries, batteries, or Arduino adapters. The power supply to this port is DC power
from 6V to 20V, but the best voltage that the manufacturer recommends is from 7 to
12V.
11. In addition, the Arduino Uno has a number of other noteworthy components. There
are four LEDs on the board, including one led on the source, two led Tx and Rx, and one
led L. The Tx and Rx leds will blink when data is transmitted. from board to computer or
vice versa via USB. L is connected to pin number 13. This led is referred to as led on
board, which allows the user to practice simple tasks without using external leds. In the
14 pins of the pin also has two pins 0 and 1 can transmit data serial TTL. There are some
applications that need this feature, such as the Arduino Uno control application on the
phone using the HC05 bluetooth. In addition, pin 2 and pin 3 are also used for
interrupting programs, while some other pins can be used for other functions, as shown in
Figure 2.40.
Algorithm mapping
Arduino IDE programs typically revolve around two setup functions - void setup
() and loop () - void loop ().
The void setup () function is used to declare the initial settings and only once, such
as setting which pins are input, output pins, or baud rate settings for serial
communication.
The void loop () function repeats the operation or task that the user has
programmed.
Figure 2.41. Algorithm mapping on Arduino IDE
2.5. Introduction of module Wifi ESP8266
2.5.1. Inroduction of Wifi ESP8266
The ESP8266 is a cheap, inexpensive, 2.4 Ghz programmable integrated Wi-Fi chip
manufactured by a Chinese semiconductor company, Espressif Systems.
Originally released in August 2014, the package is marketed as the Model ESP-01
Module, produced by 3rd party: AI-Thinker. Ability to connect to the Internet over Wi-Fi
network quickly and use very little components. The price is very cheap compared to the
features and capabilities ESP8266 can do.
ESP8266 has a huge developer community around the world, offering a variety of open
source programming modules that enable people to access and build applications very
quickly. All ESP8266 chips on the market today carry the ESP8266EX, which is an
upgraded version of the ESP8266.
Figure 2.42. Pins connection and Block diagram of ESP8266
In this model, we will load an available firmware provided by Espressif so that the
ESP8266 acts as a standalone Wifi module. Our task is to program an external MCU that
communicates with the ESP8266 to configure the Wifi connection and transmit / receive
data from the Wifi network.
The operating principle of this model can be shown in the figure below:
Figure 2.43. Operating Principle of ESP8266: Firmware communicates with AT
command
Here we communicate with the ESP8266 through the UART standard so just connect two
TXD / RXD signals and two power cables to the ESP8266 module to be able to
communicate. External MCU can be a board microcontroller such as Arduino board or
PC.
This is the simplest and fastest programming model. We are going to use the ESP8266 as
a wifi module and just configure the Wifi network, passwords, and connect and transmit
data on the UART interface.
Chip configuration commands: Allows you to check the operating status, reset
chip, read firmware version information, or configure UART, Sleep mode etc.
Wifi network configuration commands: Supports commands such as operation
mode (Station, AP, AP + station), read list of wireless networks around, configure
Wifi network information to connect, or configure DHCP, WPS, MDNS, smart
config, ... Most Wifi related configurations are fully supported for normal to
advanced needs.
TCP / IP configuration scripts that allow configuration of TCP, UDP, SSL, ping
commands, timeout configuration for data transfer, DNS, etc. This section mainly
supports data transmission.
Direct programming on the ESP8266 chip
In this model, we will program a firmware for ESP8266 using the SDK library provided
by Espressif. We will follow this model for applications that want to use the ES8266 to
control the device directly without an external MCU driver; Or we need features that the
standard firmware does not offer.
The library code files provide an HAL driver, which defines the address of the
control register, as well as software modules such as RTOS, Memory Managment,
etc.
Compilers and linkers to compile source code and generate * .bin firmware files
for ESP8266
Software to transfer * .bin files to ESP8266 via UART (we need to change the
value of some GPIO pins to ESP8266 into firmware load mode from UART)
Espressif does not currently support an IDE program like IAR, Keil to program ESP8266.
So we will use a basic text editor (Java, Visual Studio, or even Notepad, ...) to write the
application code for ESP8266, then use the compiler to compile the code with the SDK.
support for binary files. Finally, we use the download tool to load the firmware into the
device.
No need to talk much about the Adruino programming language, it is so famous and you
just search Adruino on google it will come out a lot of documentation in both English and
Vietnamese. This is a relatively accessible language for amateurs who still love to
discover new things to create a product.
Currently in the developing community a project called ArduinoESP8266 provides the
Arduino core library to compile the ESP8266 firmware while still using the familiar
Arduino commands. Home of this project in https://github.com/esp8266/Arduino
As depicted in the figure, we can use the familiar command in the Adruino IDE. When
compiled in the Arduino IDE, the ESP8266 library converts arduino commands into
ESP8266 code using Non-OS SDK APIs.
With direct programming support for Esp8266 on this platform, people familiar with
Adruino programming can programmatically communicate with the ESP8266 board in an
easy, time-saving way. Currently, the latest library of the ESP8266 on Adruino is based
on Non-OS SDK version 1.5.3 fully supports the necessary functions of a wifi module
such as: TCP, UDP, HTTP settings, MDNS, SSDP, DNS servers, OTA, etc. It also
supports interfaces such as flash memory, SD cards, servos, SPI, I2C. As depicted in the
figure, we can use the familiar command in the Adruino IDE. When compiled in the
Arduino IDE, the ESP8266 library converts arduino commands into ESP8266 code using
Non-OS SDK APIs.
ESP8266 plays the connection between arduino and server. ESP8266 connects to
Arduino via UART. The ESP8266 sends signals to the server via the Message Queuing
Telemetry Transport (MQTT) protocol. Arduino sends information about the state of the
sensor, the engine on the processor. Server sends control parameters to the Arduino.
Chapter III. Mechanical design of the system
1.1. Robotic Arm
This project will consists of three main parts. The first part is the construction of the
robotic arm, its electronics and its controller. This will be the most time consuming
portion of the project, and possibly the most difficult to accomplish in under 10 weeks.
Base
460 mm
Servo motors
180°
355 mm
Thanks to all of above specifications in Figure 3.1 and 3.2, the design of Robotic Arm is
very suitable for this system. First, it can rotate 180 degrees, so this system can sow
seeds to the soil tray, water and take care of plants then harvest plants and put them in the
opposite direction easily. Second, due to the maximum height and radius of gyration ( the
length of the Robotic Arm when it’s working and when it backs to the original position),
working area is suitable for the small system ( the width of the soil tray is about 20 to 30
cm). Third, the clamp is quite good for holding seeds and plants, it just needs to be
programmed to not break or crush the things it is carrying.
This Robotic Arm has 5 parts: Base, Shoulder, Elbow, Wrist and Gripper. All of them are
executed by servo motors’ operations and controlled by PID algorithm ( they will be
discussed in Chapter IV).
Wrist
Gripper
Servo motors
Elbow
Base
Shoulder
The second part is the frame. It includes a soil tray, a rail for Robotic Arm run on, a
stepper motor, a transmission system, a water pump, a water tray, and a board to put
seeds in. And the last part is the supervise camera, makes the users feel more easier in
watching the developing of the plants. All the specifications and brief discriptions of
them will be discussed later in Chapter IV.
An overview of the opearation of this system: When users supply power to the system,
the Robotic Arm will takes seeds in the seeds tray then sow them to the ground in the soil
tray. The Robotic Arm needs a short delay for the pump to pump water from water tray
and irrigate the seeds. Now, the stepper motor will pushes the Robotic Arm via the
transmission system with wheels on the rail, and continue the loop for planting and
watering. When it goes to the end of the journey, it will touches the limit switch, and then
the stepper motor will pulls the Robotic Arm to the original position and finish the
process. When the plants is grown enough, users can harvest them by using this system,
now the operation principle is similar to the planting process, but the execution of the
Robotic Arm is completely opposite, it will takes the plants from the soil tray first, then
put them aside. All of above processes will be monitored by a camera and pictures or
videos will be sending to the Internet so users can control the camera to manage their
system easily.
15 cm
Soil tray
Stepper
motor 70 cm
Camera
18 cm 20 cm
Water tray
Water pump
15 cm
Seeds box
20 cm
Power supply:
When lots of equipment connect to the adaptor so that the current of adaptor is not good
enough to keep the equipment working properly.
To overcome the problem mentioned above. Switching Power Supply is one of the
perfect solutions. It ensures stable output voltage and current in the process of work. In
addition, it makes easier to manage different input streams and is easy to identify when
encountering problems
There are many different types of microprocessors currently sold in the market from 8 -
bit microcontroller such as PIC10F320, ATMega328, ATMega2560 to 32 - bit
microcontroller as AT32UC3A0512. Based on the specs and requirements of the design,
the 8-bit microcontroller is the most affordable option as well as the most technically
responsive
PIC10F320 has the advantage of compact size, large memory capacity. In fact,
ATMega2560 and ATMega328 is the best choice for this project. The ATMega 2560 has
a large memory capacity and the large number of input and output ports that make it
suitable for robot control. ATMega328 is a multi-function processor that can operate
stably so it is well suited for controlling stepper motor and water pump and receiving the
input signal of soil moisture sensor. ATmega2560 and atmega328 are affordable, fast
processor, can combine many different devices and very suitable for the requirements of
the whole system.
In real projects, to ensure continuity of equipment during operation. The link between
ATMega328 and ATMega2560 is set up to ensure synchronization between devices.
Water pump:
After had done the placement of seeds right place. To ensure that the plants do not die
due to lack of water. A pump is one of the necessary components. There are various types
of pumps with AC or DC input in different sizes and capacities.
With AC motors, the output waterpower will be very large which makes plants to die. So
selecting DC Motor with enough waterpower is the most reasonable option. In this
project, water pump with output power 60W -12V is a reasonable choice of price as well
as demand.
Controlling the robot arm requires the servo motors to operate at the right angles. There
are several types of RC Servo Motor currently available on the market such as MG996R
Servo Motor Digital High Torque, RC Servo Digital RC FR1501 and RC Servo MG90S.
RC FR1501 is one of the best servos. It has stall torque up to 17kg / cm and speed: 0.16s
/ 60 degree However the price is quite high. MG90S has lower torque than FR1501 at
1.8kg / cm to 2.2kg / cm at 0.1s / 60 degree. The advantage is cheap. The MG996R can
reach traction of 3.5kg / cm to 5.5kg / cm with rotational speed from 0.13s - 0.17s / 60
degrees. From the above specifications, MG996R is the best choice in terms of both
stability, demand as well as price of the product.
Table 4.1. Applying PID algorithm for controlling positions of the Robotic Arm
Servo motor name Times Kp Ki Kd Angle
1 2 6 3 177.6
2 2.2 4.5 2.3 178.7
Base
3 2.7 3.4 3.4 179.2
4 2.9 3.2 3.6 179.9
1 3 2 4 86.3
2 3.2 1.6 3.8 88.7
Shoulder
3 3.3 1.8 3.5 89.4
4 3.5 1.7 3.3 89.8
1 2.5 3 1 74.5
2 2.3 2.6 1.2 76.8
Elbow
3 2.2 2.3 1.6 78.9
4 2.2 2.1 1.9 79.7
1 1.8 3 2 52.2
2 1.6 3.2 2.1 53.7
Wrist
3 1.4 2.6 2 54.4
4 1.5 2.4 2.2 54.8
1 4 2 3 8.2
2 4.1 2.4 2.8 8.4
Gripper
3 4.3 2.2 2.6 8.5
4 4.2 2.1 2.5 8.8
Stepping motors are synchronous motors used to convert control signals in the form of
successive discrete pulses into rotational angular motion or rotor motion that is capable of
fixing the rotor to the required positions
In terms of structure, the stepper motor can be considered as a combination of two types
of engines: non-contact DC motor and small-speed synchronous motor.
The A4988 stepper motor driver carrier is a breakout board for Allegro’s easy-to-use
A4988 micro stepping bipolar stepper motor driver. The driver features adjustable current
limiting, overcurrent protection, and five different micro step resolutions. It operates
from 8 – 35 V and can deliver up to 2 A per coil.
The specifications of A4988 stepper motor driver carrier is very suitable for the proposed
project and reasonable price
Specifications
Mechanical Part
Water P385 water Voltage: 12V
pump pump Power output: 60W –
5A
Pressure: 8kg (0.8
Mpa)
Flow rate: 5L/min
Weight: 0.6 Kg
Diameter tube input:
12 mm
Maximum allowable
line length: 90
meters.
Automatic pressure
switch off when the
water lock.
of antennas
16 GPIO pins
Supports SDIO 2.0,
UART, SPI, I²C,
PWM, I²S with
DMA
1 10 bit ADC
Wide operating
temperature range: -
40C ~ 125C
Flash Memory:
256KB of which
8KB used by
bootloader
SRAM: 8KB
EEPROM: 4KB
Clock Speed:
16MHz
Arduino Microcontroller:
UNO R3 ATMega328
Operating voltage:
5V
Input voltage
(recommended): 7V
- 12V
Input Voltage
(limits): 6 – 20V
Digital I/O pins: 14
(of which 6 provide
PWM output)
Analog input pins: 6
DC Current per I/O
pin: 40mA
DC Current for 3.3V
Pin: 50mA
Flash Memory:
32KB of which
Electrical Part
0.5KB used by
bootloader
SRAM: 2KB
EEPROM: 1KB
Clock Speed:
16MHz
Contrast, Saturation,
Chromaticity
Input power: DC
5V/2.0A
Color Balance: Can
be adjusted
automatically or
manually
Infrared night view:
20m
Support IP address:
static IP, dynamic
IP, Ubiquitous Wifi
Power supply: The power supply module will supply the power for operation the
all the system and modules. It is also provide the power to operation camera
CPU Module: This module will receive the input signal from soil moisture sensor
and mobile phone. In addition, it will send the control signal to robot arm, water
pump, and stepper motor. Arduino Mega 2560 and Arduino UNO R3 are used in
the project.
Human interface module: The input signal to operate the process. Besides this
module also indicates the status of system.
Robot arm: receiving the signal from CPU module, moving to the specified
position, and send backing the signal to CPU module. MG996R is selected by its
specs.
Water pump: Operated according to instructions of CPU Module
Camera: Send and receive signals from Mobile phone.
Wi-Fi module: Send the data to Server. ESP8266 is useful for the project.
Stepper Motor driver: Control the stepper motors. It can forward or reverse as
desired. A4988 is used to control one stepper motor.
Power Supply
Mobile phone
Camera
Stepper motor
In addition to the role of hardware, the software also plays a very important role and
knows as the “backbone” of the whole system. The software that mentioned below
controls the robot arm and sends the signal to the designed server.
Start
Write pin to
beginning angle
False
Pin = 1
True
Servo motors
move to x angle
End
The servo motor in robot arm includes 5 parts: base, shoulder, elbow, wrist, gripper move
to an angle which was already set up by user in sequence after the microprocessor read
pin of servo motors. If the microprocessor got unwanted signal, by using PID algorithm
the system will reset automatically, it means that the servo motors will move to the
beginning angle. On the other hand, PID algorithm can make servo motors move in
stable, and the speed of servo motors can be changed easily.
In order to move the robot arm to the right position, motor and water pump are used. Two
devices are controlled through the flowchart in Figure 4.3.
When the system starts, it will reset the three preset values P, L, M. P is the number of
times the pump is activated, M is the number of forward motor times and L is the number
of reverse motor times.
To locate the last point of the cycle. Limit Switch was used. In case the limit switch is not
activated, the program will perform a comparison of the number of forward motor times.
If the number of times the pump activation is less than two, the value will be adding one
and turn on a water pump in 2 seconds. Else, if it is greater than two, the water pump will
not be turned on.
After the P value comparison has been made, the program will continue to compare the
number of forward motor times. If this value is less than three, the program will execute
the job, the value will be adding one and active the forward motor. If this value is greater
than three, the program will proceed to check the value of the limit switch.
If the limit switch value has changed. The program will continue to check the number of
reverse motor times. If this value is less than one then the value will be adding one and
the reverse motor will be activated and the whole process will be finished.
Start
P = 0; L = 0; M = 0
True
Limit Switch
=1
False
L<1
P<2
False
True
Active Water Active Reverse
Pump Motor
Disable Water
L = L+1
Pump
P = P+1
End
M<3
True
False Active Forward
Motor
M = M+1
The actual image of the system below including the overall image and image when it
works:
Figure 5.1. The general of smart system for planting and monitoring
The actual picture in Figure 5.1 shows overall system, which includes:
In figure above, after push the start button, robot arm went to sow seeds from backside
After release seed, robot arm water amount of water, which can be set up by user to the
seed (Figure 5.4)
When the seeds grow up enough for us to harvest, robot arm will automatic harvest and
leave it in one place (Figure 5.5)
Figure 5.6. Motor pulls the robot arm forward (left to right)
The step motor will pull to another side, the process keep repeat until robot arm reach the
end of the line show in Figure 5.6.
Figure 5.7. Motor pulls the robot arm reverse (right to left)
In the Figure 5.7, when robot arm reach the end of the line, step motor will pull it back to
original location.
Figure 5.8. Monitoring Camera
The camera is used to monitor the planting the seeds and spit out the trees in Figure 5.8.
5.2. Discussions
After testing the system several times, a list of criteria is set up to evaluate the product
quickly and accurately. It is presented in Table 5.1.
Successful
80% 70% 80% 60% 80%
rate
The data of Table 5.1 shows the success or failure of each process, the success rate is
quite high on all sides. The rate is 80% for taking seeds, watering, moving. It is relatively
low about 60% for spiting trees. It can be seen that important system processes work
quite well. However, in order for the system to achieve a 100% success rate, it will require the
hand gripper need to upgrade.
User manual
Step 1: Connecting your system to power supply and waiting for system start
Step 2: Press the start button.
At this time, the robot arm will execute taking the seeds and then rotation 180 degrees to
perform sowing the seeds.
It takes 20 seconds to complete this process. While that time, the pump is activated to
water the seeds. The robot arm will perform two sowing. During the robot arm takes new
seeds, forward motor is activated and the robot arm is moved to a new position.
After sowing and watering have completed, the robot arm will spit out the tress in the box
and bring it out. This process will be repeated twice. After completing the whole process,
the reverse motor is activated to pull the motor to its original position.
Note: During the operation, if encounter any problems, please press the RESET button to
reboot the system to fix the problem.
In the real circuit test, the system is worked perfectly. The servos of robot arm move to
the desired location. Perform well programming requirements. Meet the requirements.
The water pump and motor system work wells on pre-installed time. However, the robot
is disturbed over long periods of operation, which results in it no longer working properly
initially. In addition, the use of time to delay the start of motor and water pump
sometimes leads to some big errors.
To solve this problem, the PID algorithm has been adjusted some values to help the arm
operate stably and accurately. It has adjusted and presented in Table 5.2 below:
Table 5.2. The new PID value after having adjusted
Servo
motor Base Shoulder Elbow Wrist Gripper
name
Old New Old New Old New Old New Old New
Kp 2.9 2.95 3.5 3.6 2.2 2.3 1.5 1.6 4.2 4.5
Ki 3.2 3.15 1.7 2 2.1 1.8 2.4 2.7 2.1 2
Kd 3.6 3.52 3.3 3.4 1.9 1.6 2.2 2.4 2.5 2.1
Angle 179.9 179.96 89.8 89.95 79.7 79.85 54.8 54.92 8.8 8.92
From the above table, some values have been adjust to allow the motors move to the
exactly corner. With the new values of PID algorithm, the servos of robot arm work
more stability and not disturbed over a long time.
For motors and pumps, using the synchronization method among many processors is the
most optimized. This method minimizes latency, increases accuracy, and exploits the full
functionality of the device. Helping to save operation and repair time.
And if we want to sell this system, we have an estimated cost for it is shown in the table
5.3 below
4. DC motor 2 300,000
5. Wheel 8 80,000
6. Camera 1 200,000
Total 5,500,000
Chapter VI: Conclusion and Future works
6.1. Conclusion
In this thesis, a smart system for planting and monitoring plants at home has been
developed. The system uses a Robotic Arm to plant seeds and harvest plants, a stepper
motor and a transmission system to make the Robotic Arm cover the whole system. It
also has a watering system to take care of the plants and a monitoring camera to make
users feel easier to control and take care of their systems.
Nonetheless, the system also has some drawbacks in terms of hardware and software:
Software: because of using 2 Arduino, so it is not synchronized and it makes too many
difficulties in the logic programming between the Robotic Arm, the motor and the water
pump, so it is still not working as well as we expect and the delay is quite long.
Besides the results, due to time limiation, some potetial ideas cannot implemented in this
project. These mentioned drawbacks above could lead to further works that may carry out
in the future:
[3] “Let’s Have a Close Look of IoT – The Future Internet”, written by Poornima
Prakash, November 13, 2015.
[4] “Controlling a Robotic Arm Manipulator with a PLC”, HAMK University of Applied
Sciences, written by Bhim Bahadur Lama, 2012.
[6] “Green IQ Smart garden hub wifi irrigation controller”, Vesternet – Smart home
simplified.
[8] “Garden Space - A robot for growing your own food at home.”
[11] “The Internet of Things: Unlocking the language potential”, CAPITA – Translation
and interpreting
[12] “Position Control Of Robot Arm Using Genetic Algorithm Based On PID
Controller”, written by Majed D. Youns, Salih M. Attya and Abdulla I. Abdulla, College
of Electronics Engineering / University of Mosul /Mosul, Iraq, 2012.
[14] L.phillips and D.Harbar, "Feedback Controller System ",3rd edition , Prentice Hall,
1996
[15]A. Varsek, T. Urbacic and B. Filipic, "Genetic Algorithms in Controller Design and
Tuning", IEEE Trans. Sys.Man and Cyber, Vol. 23, No. 5, pp1330-1339, 1993.
[16] K Ogata, "Modern Control Systems", University of Minnesota, Prentice Hall, 2003
Appendix