Monitor Green house remotely using the Arduino WiFi

  INTRODUCTION 

We live in a world where everything can be controlled and operated automatically, but there are still a few important sectors in our country where automation has not been adopted or not been put to a full-fledged use, perhaps because of several reasons one such reason is cost. One such field is that of agriculture. Agriculture has been one of the primary occupations of man since early civilizations and even today manual interventions in farming are inevitable. Greenhouses form an important part of the agriculture and horticulture sectors in our country as they can be used to grow plants under controlled climatic conditions for optimum produce. Automating a greenhouse envisages monitoring and controlling of the climatic parameters which directly or indirectly govern the plant growth and hence their produce. Automation is process control of industrial machinery and processes, thereby replacing human operators.

1.1 Current Scenario

Greenhouse in Pakistan are being deployed in the high-altitude regions where the sub- zero temperature up to -40° C makes any kind of plantation almost impossible and in arid regions where conditions for plant growth are hostile. The existing set-ups primarily are:

1.1.1 Manual Setup

This set-up involves visual inspection of the plant growth, manual irrigation of plants, turning ON and OFF the temperature controllers, manual spraying of the fertilizers and pesticides. It is time consuming, vulnerable to human error and hence less accurate and unreliable.

1.1.2 Partially Automated Setup

This set-up is a combination of manual supervision and partial automation and is similar to manual set-up in most respects but it reduces the labor involved in terms of irrigating the set-up.

1.1.3 Fully Automated

This is a sophisticated set-up which is well equipped to react to most of the climatic changes occurring inside the greenhouse. It works on a feedback system which helps it to respond to the external stimuli efficiently.  Although this set-up overcomes the problems caused due to human errors it is not completely automated and expensive.

1.2 Proposed Model for Automation of GREENHOUSE

The proposed system is an embedded system which will closely monitor and control the  microclimatic  parameters  of  a  greenhouse  on  a  regular  basis  round  the  clock  for cultivation of crops or specific plant species which could maximize their production over the whole crop growth season and to eliminate the difficulties involved in the system by reducing human intervention to the best possible extent.

The objective of this project is to design a simple, easy to install, microcontroller based circuit to monitor and record the values of temperature, humidity, soil moisture and sunlight of the natural environment that are continuously modified and controlled in order optimize them to achieve maximum plant growth and yield.

The controller used is a low power, cost efficient chip manufactured by ATMEL called Arduino wits its Wi-Fi shield. It communicates with the various sensor modules in real time in order to control the light, aeration and drainage process efficiently inside a greenhouse by actuating a cooler, fogger, dripper and lights respectively according to the necessary condition of the crops. An integrated Liquid crystal display (LCD) is also used for real time display of data acquired from the various sensors and the status of the various device.

Also, the use of easily available components reduces the manufacturing and maintenance costs. The design is quite flexible as the software can be changed any time. It can thus be tailor-made to the specific requirements of the user.

This makes the proposed system to be an economical, portable and a low maintenance solution for greenhouse applications, especially in rural areas and for small scale agriculturists. Thus, this system is easy to maintain, flexible and low cost solution.

SYSTEM MODEL

 

 

 

 

 

 

 

SYSTEM MODEL

 Figure 2.1 Block diagram of the system

 

Arduino WiFi

 

 

2.2 Parts of the System

  1. Sensors
    1. Temperature sensor (DHT11)
    2. Humidity sensor (DHT 11)
    3. Light sensor (LDR)
    4. Moisture sensor
  2. Arduino UNO
  • Arduino YUN
  1. Liquid Crystal Display (JHD204A)
  2. Actuators – Relays (H-bridge)
  3. Android

vii. Devices controlled

  1. Water Pump
  2. Sprayer
  3. Cooler (Simulated as a Fan )
  4. Artificial Lights (Simulated as a Bulb)

This part of the system consists of various sensors, namely soil moisture, humidity, temperature and light. These sensors sense various parameters- temperature, humidity, soil moisture and light intensity and are then sent to the memory module

2.2.1 Arduino UNO

The Arduino UNO is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to get started.

The UNO differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.

“UNO” means one in Italian and is named to mark the upcoming release of Arduino 1.0. The UNO and version 1.0 will be the reference versions of Arduino, moving forward. The UNO is the latest in a series of USB Arduino boards, and the reference model for the Arduino platform; for a comparison with previous versions.

2.2.2 Arduino YUN

The Arduino YUN is a microcontroller board based on the ATmega32u4 (datasheet) and the Atheros AR9331. The Atheros processor supports a Linux distribution based on Open w.r.t named Open w.r.t YUN. The board has built-in Ethernet and WiFi support, a USB-A port, micro-SD card slot, 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, an ICSP header, and a 3 reset buttons. The YUN distinguishes itself from other Arduino boards in that it can communicate with the Linux distribution onboard, offering a powerful networked computer with the ease of Arduino. In addition to Linux commands like URL, you can write your own shell and python scripts for robust interactions.

The YUN is similar to the Leonardo in that the ATmega32u4 has built-in USB communication, eliminating the need for a secondary processor. This allows the YUN to appear to a connected computer as a mouse and keyboard, in addition to a virtual (CDC) serial / COM port.

2.2.3 Actuators

An array of actuators can be used in the system such as relays, contactors, and change over switches etc. They are used to turn on AC devices such as motors, coolers, pumps, fogging machines, sprayers. For the purpose of demonstration relays have been used to drive AC bulbs to simulate actuators and AC devices. A complete working system can be realized by simply replacing these simulation devices by the actual devices.

2.2.4 Display Unit

A Liquid crystal display is used to indicate the present status of parameters and the respective AC devises (simulated using bulbs). The information is displayed in two modes which can be selected using a push button switch which toggles between the modes. Any display can be interfaced to the system with respective changes in driver circuitry and code

2.2.5 Android Interface

Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google. With a user interface based on direct manipulation, Android is designed primarily for touchscreen mobile devices such as smartphones and tablet computers, with specialized user interfaces for televisions (Android TV), cars (Android Auto), and wrist watches (Android Wear). The OS uses touch inputs that loosely correspond to real-world actions, like swiping, tapping, pinching, and reverse pinching to manipulate on-screen objects, and a virtual keyboard. Despite being primarily designed for touchscreen input, it also has been used in game consoles, digital cameras, and other electronics.

2.3 Step followed in designing the System
Three general steps can be followed to appropriately select the control system:

Step #1: Identify measurable variables important to production.

It is very important to correctly identify the parameters that are going to be measured by the controller’s data acquisition interface, and how they are to be measured.

 

The set of variables typically used in greenhouse control is shown below:

Sr. No. Variable to be monitored Its Importance
1 Temperature Affects all plant metabolic functions.
2 Humidity Affects transpiration rate and the plant’s thermal control mechanisms.
3 Soil Moisture Affects salinity, and pH of irrigation water.
4 Solar Radiation Affects photosynthetic rate, responsible for most thermal load during warm periods

 

Table 2.1 Importance of the various parameters 

An electronic sensor for measuring a variable must readily available, accurate, and reliable and low in cost. If a sensor is not available, the variable cannot be incorporated into the control system, even if it is very important. Many times variables that cannot be directly or continuously measured can be controlled in a limited way by the system.  For example, fertility levels in nutrient solutions for greenhouse production are difficult to measure continuously.

Step #2: Investigate the control strategies

An important element in considering a control system is the control strategy that is to be followed. The simplest strategy is to use threshold sensors that directly affect actuation of devices.  For  example,  the  temperature  inside  a  greenhouse  can  be affected  by  controlling  heaters,  fans,  or  window  openings  once  it  exceeds  the maximum allowable limit. The light intensity can be controlled using four threshold levels. As the light intensity decreases one light may be turned on. With a further decrease in its intensity a second light would be powered, and so on; thus ensuring that the plants are not deprived of adequate sunlight even during the winter season or a cloudy day. More complex control strategies are those based not only on the current values of the controlled variables, but also on the previous history of the system, including the rates at which the system variables are changing.

Step #3: Identify the software and the hardware to be used

It is very important that control system functions are specified before deciding what software and hardware system to purchase.

The model chosen must have the ability to:

  1. Expand the number of measured variables (input subsystem) and controlled devices (output  subsystem)  so  that  growth  and  changing  needs  of  the production operation can be satisfied in the future.
  2. Provide a flexible and easy to use interface.
  3. It must ensure high precision measurement and must have the ability resist noise.

Hardware must always follow the selection of software, with the hardware required being supported by the software selected. In addition to functional capabilities, the selection of  the  control  hardware  should  include  factors  such  as  reliability,  support,  previous experiences with the equipment (successes and failures), and cost.

 

HARDWARE DESCRIPTION

3.1 Transducers

A transducer is a device which measures a physical quantity and converts it into a signal which can be read by an observer or by an instrument. Monitoring and controlling of a greenhouse  environment  involves  sensing  the  changes  occurring  inside  it  which  can influence  the rate of growth  in plants.  The parameters  which  are of importance  are the temperature  inside  the  greenhouse  which  affect  the  photosynthetic   and  transpiration processes are humidity, moisture content in the soil, the illumination etc. Since all these parameters  are  interlinked,  a  closed  loop  (feedback)  control  system  is  employed  in monitoring it.  The sensors used in this system are:

  1. Soil Moisture Sensor
  2. Light Sensor (LDR (Light Dependent Resistor))
  3. Humidity Sensor (DHT 11)
  4. Temperature Sensor (DHT11)

3.1.1 Soil Moisture Sensor

 

Fig. 3.1 Moisture Sensor                                             (adafruit.com/fc-28)

 

3.1.1.1 Features of the Soil moisture sensor
  • This is a simple and easy moisture sensor can be used for the detection of soil moisture, when soil water shortage, the module outputs a high level, whereas the output low level. Using the sensor produces a watering device automatically, let you don’t choose and employ persons to manage the plants in the garden.
  • The sensitivity is adjustable digital potentiometer to adjust (blue).
  • The working voltage of 3.3 V to 5 V.
  • Simple digital output, + voltage directly by single chip microcomputer.
  • A fixed bolt hole convenient installation.
  • Control panel PCB size: 3 cm * 1.6 cm soil probe size: 6 cm * 2 cm.
  • The power indicator light (red) and digital switch output indicator light (green).
  • The comparator USES the LM393 chips, work stability.

Electronic block Arduino Soil Moisture Sensor Interface specifications

  1. VCC: External 3.3Vto5V
  2. GND: External GND
  3. DO: Digital output interface (0and1)
  4. AO: Analog output interface (this interface is generally not do application)

 

3.1 Soil moisture sensor

Fig: 3.2 soil moisture sensor connection to Arduino

3.1.1.2 Functional Description of Soil Moisture Sensor

The two copper leads act as the sensor probes. They are immersed into the specimen soil whose moisture content is under test. The soil is examined under three conditions:

Case #1: Dry Condition

The probes are placed in the soil under dry conditions and are inserted up to a fair depth of the soil. As there is no conduction path between the two copper leads the sensor circuit remains open. The voltage output of the emitter in this case ranges from 0 to 0.5V.

Case #2: Optimum Condition

When water is added to the soil, it percolates through the successive layers of it and spreads across the layers of soil due to capillary force. This water increases the moisture content of the soil. This leads to an increase in its conductivity which forms a conductive path between the two sensor probes leading to a close path for the current flowing from the supply to the transistor through the sensor probes. The voltage output of the circuit taken at the emitter of the transistor in the optimum case ranges from 1.9 to 3.4V approximately.

Case #3: Excess Water Condition

With the increase in water content beyond the optimum level, the conductivity of the soil increases drastically and a steady conduction path is established between the two sensor leads and the voltage output from the sensor increases no further beyond a certain limit. The maximum possible value for it is not more than 4.2V.
3.1.2 Light Sensor
Light Dependent Resistor (LDR) also known as photoconductor or photocell, is a device which has a resistance which varies according to the amount of light falling on its surface. Since LDR is extremely sensitive in visible light range, it is well suited for the proposed application.

 

Fig. 3.3 Light Dependent Resistor

3.1.2.1 Features of the light sensor

The Light Dependent Resistor (LDR) is made using the semiconductor Cadmium Sulphide (CdS).The light falling on the brown zigzag lines on the sensor causes the resistance of the device to fall. This is known as a negative co-efficient. There are some LDRs that work in the opposite way i.e. their resistance increases with light (called positive co- efficient). The resistance of the LDR decreases as the intensity of the light falling on it increases. Incident photons drive electrons from the valence band into the conduction band.
Fig. 3.3.1 Structure of a Light Dependent Resistor, showing Cadmium Sulphide track and an atom to illustrate electrons in the valence and conduction bands

3.1.2.2 Functional description

An LDR and a normal resistor are wired in series across a voltage, as shown in the circuit below. Depending on which is tied to the 5V and which to 0V, the voltage at the point between them, call it the sensor node, will either rise or fall with increasing light. If the LDR is the component tied directly to the 5V, the sensor node will increase in voltage with increasing light. The LDR’s resistance can reach 10 k ohms in dark conditions and about 100 ohms in full brightness. The circuit used for sensing light in our system uses a 10 kΩ fixed resistor which is tied to +5V. Hence the voltage value in this case decreases with increase in light intensity.

 

Fig. 3.4 Light sensor circuit

The sensor node voltage is compared with the threshold voltages for different levels of light intensity corresponding to the four conditions- Optimum, dim, dark and night. The   relationship   between   the   resistance   RL     and   light   intensity   Lux   for a    typical LDR is:

 RL = 500 / Lux kΩ  … (3.1)

With the LDR connected to 5V through a 10K resistor, the output voltage of the LDR is:

Vo = 5*RL / (RL+10)… (3.2)

In order to increase the sensitivity of the sensor we must reduce the value of the fixed resistor in series with the sensor. This may be done by putting other resistors in parallel with it.

3.1.3 Humidity Sensor

The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). It’s fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, so when using our library, sensor readings can be up to 2 seconds old.

 

Fig 3.5 Humidity sensor                                                    (adafruit.com/dht11)

 

3.1.3.1 Features

  • Low cost
  • 3 to 5V power and I/O
  • 5mA max current use during conversion (while requesting data)
  • Good for 20-80% humidity readings with 5% accuracy
  • Good for 0-50°C temperature readings ±2°C accuracy
  • No more than 1 Hz sampling rate (once every second)
  • Body size 15.5mm x 12mm x 5.5mm
  • 4 pins with 0.1″ spacing

Fig: 3.6 Humidity Sensor Circuit

3.1.4 Temperature Sensor

The DHT11 is a relatively cheap sensor for measuring temperature and humidity. This article describes a small library for reading both from the sensor. The DHT22 is similar to the DHT11and has greater accuracy. However, this library is not suitable for the DHT21 or DHT22 as they have a different data format.

3.1.4.1 Pin Configuration:

The DHT11 has three lines: GND, +5V and a single data line. By means of a handshake, the values are clocked out over the single digital line.

 

Fig: 3.7 top view of DHT11

 

 

 

 

Pin Name Description
1 Vdd Power Supply
2 Data Serial Data Output
3 NC Not Connected
4 GND Ground

Table 3.1 Pin Configuration of DHT11
3.1.4.2 WIRING:
Connect the sensor to the Arduino as shown below:

DHT11 Arduino
Pin 1 Vcc
Pin 2 Analog 0
Pin 3 GND

Table 3.2 Wiring Segment

Fig. 3.8 Temperature sensor circuit

3.3 Microcontroller (ATmega2560) 

3.3.1 Criteria for choosing a Microcontroller

The basic criteria for choosing a microcontroller suitable for the application are:

  • The first and foremost criterion is that it must meet the task at hand efficiently and cost effectively. In analyzing the needs of a microcontroller-based project, it is seen whether an 8- bit, 16-bit or 32-bit microcontroller can best handle the computing needs of the task most effectively. Among the other considerations in this category are:
    1. Speed: The highest speed that the microcontroller supports.
    2. Packaging: It may be a 40-pin DIP (dual inline package) or a QFP (quad flat package), or some other packaging format. This is important in terms of space, assembling, and prototyping the end product.
  • Power consumption: This is especially critical for battery-powered products. The number of I/O pins and the timer on the chip.
  1. How easy it is to upgrade to higher –performance or lower consumption versions.
  2. Cost per unit: This is important in terms of the final cost of the product in which a microcontroller is used.
  • The second criterion in choosing a microcontroller is how easy it is to develop products around it. Key considerations include the availability of an assembler, debugger, compiler, technical support.
  • The third  criterion  in  choosing  a  microcontroller  is  its  ready  availability  in  needed quantities both now and in the future. Currently of the leading 8-bit microcontrollers, the 8051 family has the largest number of diversified suppliers. By supplier is meant a producer besides the originator of the microcontroller. In the case of the 8051, this has originated by Intel several companies also currently producing the 8051. Thus the microcontroller AT89S52, satisfying the criterion necessary for the proposed application is chosen for the task.

3.3.2 ARDUINO UNO

The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to get started.

The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.

Revision 2 of the Uno board has a resistor pulling the 8U2 HWB line to ground, making it easier to put into DFU mode.

3.2.2.1 Arduino UNO Features

  • 0 pin out: added SDA and SCL pins that are near to the AREF pin and two other new pins placed near to the RESET pin, the IOREF that allow the shields to adapt to the voltage provided from the board. In future, shields will be compatible with both the board that uses the AVR, which operates with 5V and with the Arduino Due that operates with 3.3V. The second one is a not connected pin that is reserved for future purposes.
  • Stronger RESET circuit.
  • At mega 16U2 replace the 8U2.

“UNO” means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino, moving forward.

 

 

 

Fig: 3.9 Arduino UNO                                                  (arduino.cc/arduinouno)

Microcontroller ATmega328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O pins 14
Analog input pins 6
DC current per I/O pin 40 Ma
DC current for 3.3v pin 50 mA
Flash Ram 32 kb
SRAM 2 kb
EEPROM 1 kb
Clock Speed 16MHz

Table 3.3 Arduino UNO Features

3.3.2.2 Power

The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically. External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board’s power jack. Leads from a battery can be inserted in the GND and Vin pin headers of the POWER connector. The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

The power pins are as follows:

VIN. The input voltage to the Arduino board when it’s using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.

5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 – 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don’t advise it.

3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.

GND. Ground pins.

IOREF. This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs for working with the 5V or 3.3V.

3.3.2.3 Memory

The ATmega328 has 32 KB (with 0.5 KB used for the boot loader). It also has 2 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

3.3.2.4 Input and Output

Each of the 14 digital pins on the Uno can be used as an input or output, using pin Mode, digital Write, and digital Read () functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 KOhms. In addition, some pins have specialized functions:

  • Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data.

These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

  • External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.
  • PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite()
  • SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.
  • LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off.

The UNO has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function. Additionally, some pins have specialized functionality:

  • TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire

There are a couple of other pins on the board:

 3.3.2.5 Communication

The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels this serial communication over USB and appears as a virtual com port to software on the computer. The ’16U2 firmware uses the standard USB COM drivers, and no external driver is needed. However, on Windows, an .inf file is required. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1). A Software Serial library allows for serial communication on any of the Uno’s digital pins. The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus; see the documentation for details. For SPI communication, use the SPI library.

3.3.2.6   Programming:

The Arduino Uno can be programmed with the Arduino software (download). Select “Arduino Uno from the Tools > Board menu (according to the microcontroller on your board). For details, see the reference and tutorials. The ATmega328 on the Arduino Uno comes preburned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol (reference, C header files). You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header using Arduino ISP or similar; see these instructions for details. The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is available. The ATmega16U2/8U2 is loaded with a DFU bootloader, which can be activated by:

3.3.2.7 Automatic (Software) Reset

Rather than requiring a physical press of the reset button before an upload, the Arduino Uno is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of theATmega8U2/16U2 is connected to the reset line of the ATmega328 via a 100 Nano farad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.

This setup has other implications. When the Uno is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the Uno. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data.  The Uno contains a trace that can be cut to disable the auto-reset. The pads on either side of the trace can be soldered together to re-enable it. It’s labeled “RESET-EN”. You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line; see this forum thread for details.

3.3.2.8 USB Overcurrent Protection

The Arduino UNO has a resettable polyfuse that protects your computer’s USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.

3.3.2.9   Physical Characteristics

The maximum length and width of the Uno PCB are 2.7 and 2.1 inches respectively, with the USB connector and power jack extending beyond the former dimension. Four screw holes allow the board to be attached to a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil (0.16″), not an even multiple of the 100 mil spacing of the other pins.

3.3.3 ARDUINO YUN

The Arduino YUN is a microcontroller board based on the ATmega32u4 (datasheet) and the Atheros AR9331. The Atheros processor supports a Linux distribution based on OpenWrt named OpenWrt-Yun. The board has built-in Ethernet and Wi-Fi support, a USB-A port, micro-SD card slot, 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, an ICSP header, and a 3 reset buttons.

NB: In some countries, it is prohibited to sell Wi-Fi enabled devices without government approval. While waiting for proper certification, some local distributors are disabling WiFi functionality

Fig 3.10 Arduino YUN                                                                        (arduino.cc/arduinoyun)

The YUN distinguishes itself from other Arduino boards in that it can communicate with the Linux distribution onboard, offering a powerful networked computer with the ease of Arduino. In addition to Linux commands like cURL, you can write your own shell and python scripts for robust interactions.

The YUN is similar to the Leonardo in that the ATmega32u4 has built-in USB communication, eliminating the need for a secondary processor. This allows the YUN to appear to a connected computer as a mouse and keyboard, in addition to a virtual (CDC) serial / COM port.

 

Fig 3.11 Internal Communication                                                    (arduino.cc/arduinoyun)

 

The Bridge library facilitates communication between the two processors, giving Arduino sketches the ability to run shell scripts, communicate with network interfaces, and receive information from the AR9331 processor. The USB host, network interfaces and SD card are not connected to the 32U4, but the AR9331, and the Bridge library also enables the Arduino to interface with those peripherals.

3.3.3.1 FEATURES

Because the YUN has two processors, the summary section shows the characteristics of each one in two separate tables. AVR Arduino microcontroller

 

 

 

Microcontroller ATmega32u4
Operating Voltage 5v
Input Voltage An5valog0
Digital I/O pins 20
PWM channels 7
Analog Input Channels 12
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 32 KB (of which 4 KB used by bootloader)
SRAM 2.5 KB
EEPROM 1 KB
Clock Speed 16 MHz
Linux microprocessor
Processor Atheros AR9331
Architecture MIPS @400MHz
Operating Voltage 3.3V
Ethernet IEEE 802.3 10/100Mbit/s
Wi-Fi IEEE 802.11b/g/n
USB Type 2.0 Host
Card Reader Micro-SD only
RAM 64 MB DDR2
Flash Memory 16 MB

 

Table3.4 Arduino Yun  Features

3.3.3.2 Power

It is recommended to power the board via the micro-USB connection with 5VDC. If you are powering the board though the Vin pin, you must supply a regulated 5VDC. There is no on-board voltage regulator for higher voltages, which will damage the board. The YUN is also compatible with PoE power supply but in order to use this feature you need to mount a PoE module on the board or buy a preassembled board.

The power pins are as follows:

  • The input voltage to the Arduino board. Unlike other Arduino boards, if you are going to provide power to the board through this pin, you must provide a regulated 5V.
  • The power supply used to power the microcontrollers and other components on the board. This can come either from VIN or be supplied by USB.
  • A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.
  • Ground pins.
  • The voltage at which the I/O pins of the board are operating (i.e. VCC for the board). This is 5V on the YUN.
3.3.3.3 Memory

The ATmega32u4 has 32 KB (with 4 KB used for the bootloader). It also has 2.5 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library). The memory on the AR9331 is not embedded inside the processor. The RAM and the storage memory are externally connected. The YUN has 64 MB of DDR2 RAM and 16 MB of flash memory. The flash memory is preloaded in factory with a Linux distribution based on OpenWrt called OpenWrt-Yun. You can change the content of the factory image, such as when you install a program or when you change a configuration file. You can return to the factory configuration by pressing the “WLAN RST” button for 30 seconds.

The OpenWrt-Yun installation occupies around 9 MB of the 16 MB available of the internal flash memory. You can use a micro SD card if you need more disk space for installing applications.

3.3.3.4 Input and Output

It is not possible to access the I/O pins of the Atheros AR9331. All I/O lines are tied to the 32U4. Each of the 20 digital I/O pins on the YUN can be used as an input or output, using pinMode(), digitalWrite() anddigitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 KOhms. In addition, some pins have specialized functions:

  • Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the YUN, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 The hardware serials of the ATmega32U4 and the AR9331 on the YUN are connected together and are used to communicate between the two processors. As is common in Linux systems, on the serial port of the AR9331 is exposed the console for access to the system, this means that you can access to the programs and tools offered by Linux from your sketch.
  • TWI: 2 (SDA) and 3 (SCL). Support TWI communication using the Wire library.
  • External Interrupts: 3 (interrupt 0), 2 (interrupt 1), 0 (interrupt 2), 1 (interrupt 3) and 7 (interrupt 4). These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details. Is not recommended to use pins 0 and 1 as interrupts because they are the also the hardware serial port used to talk with the Linux processor. Pin 7 is connected to the AR9331 processor and it may be used as handshake signal in future. Is recommended to be careful of possible conflicts if you intend to use it as interrupt.
  • PWM: 3, 5, 6, 9, 10, 11, and 13. Provide 8-bit PWM output with the analogWrite()
  • SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the YUN’s 6-pin ICSP header, the shield will not work. The SPI pins are also connected to the AR9331 gpio pins, where it has been implemented in software the SPI interface. This means that the ATMega32u4 and the AR9331 can also communicate using the SPI protocol.
  • LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off.
  • There are several other status LEDs on the YUN, indicating power, WLAN connection, WAN connection and USB.
  • Analog Inputs: A0 – A5, A6 – A11 (on digital pins 4, 6, 8, 9, 10, and 12). The YUN has 12 analog inputs, labeled A0 through A11, all of which can also be used as digital I/O. Pins A0-A5 appear in the same locations as on the Uno; inputs A6-A11 are on digital I/O pins 4, 6, 8, 9, 10, and 12 respectively. Each analog input provide 10 bits of resolution (i.e. 1024 different values). By default the analog inputs measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function.
  • Reference voltage for the analog inputs. Used with analogReference().

There are 3 reset buttons with different functions on the board:

  • YUN RST. Bring this line LOW to reset the AR9331 microprocessor. Resetting the AR9331 will cause the reboot of the Linux system. All the data stored in RAM will be lost and all the programs that are running will be terminated.
  • 32U4 RST. Bring this line LOW to reset the ATmega32U4 microcontroller. Typically used to add a reset button to shields which block the one on the board.
  • WLAN RST. This button has a double feature. Primarily serves to restore the Wi-Fi to the factory configuration. The factory configuration consist to put the Wi-Fi of the YUN in access point mode (AP) and assign to it the default IP address that is 192.168.240.1, in this condition you can connect with your computer to the a Wi-Fi network that appear with the SSID name “Arduino Yun-XXXXXXXXXXXX”, where the twelve ‘X’ are the MAC address of your YUN. Once connected you can reach the web panel of the YUN with a browser at the 192.168.240.1 or “http://arduino.local Note that restoring the Wi-Fi configuration will cause the reboot of the Linux environment. To restore your Wi-Fi configuration you have to press and hold the WLAN RST button for 5 seconds. When you press the button the WLAN blue LED will start to blink and will keep still blinking when you release the button after 5 seconds indicating that the WiFi restore procedure has been recorded. The second function of the WLAN RST button is to restore the Linux image to the default factory image. To restore the Linux environment you must press the button for 30 seconds. Note that restoring the factory image make you lose all the files saved and software installed on the on-board flash memory connected to the AR9331.
3.3.3.5 Communication

The YUN has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. TheATmega32U4 provides a dedicated UART TTL (5V) serial communication. The 32U4 also allows for serial (CDC) communication over USB and appears as a virtual com port to software on the computer. The chip also acts as a full speed USB 2.0 device, using standard USB COM drivers. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB connection to the computer. Digital pins 0 and 1 are used for serial communication between the 32U4 and the AR9331. Communication between the processors is handled by the Bridge library. A Software Serial library allows for serial communication on any of the YUN’s digital pins. Pins 0 and 1 should be avoided as they are used by the Bridge library.

The ATmega32U4 also supports I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus; see the documentation for details. For SPI communication, use the SPI library. The YUN appears as a generic keyboard and mouse, and can be programmed to control these input devices using the Keyboard classes. The onboard Ethernet and Wi-Fi interfaces are exposed directly to the AR9331 processor. To send and receive data through them, use the Bridge library. To configure the interfaces, you can access the network control panel as described in the getting started page. The YUN also has USB host capabilities through OpenWrt-Yun. You can connect peripherals like USB flash devices for additional storage, keyboards, or webcams. You may need to download and install additional software for these devices to work. For information on adding software to the AR9331, refer to the notes on using the package manager.

3.3.3.6 Programming

The YUN can be programmed with the Arduino software (download). Select “Arduino YUN from the Tools > Board menu (according to the microcontroller on your board). For details, see the reference and tutorials. The ATmega32U4 on the Arduino YUN comes preburned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the AVR109 protocol. You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header using Arduino ISP or similar; see these instructions for details.

3.3.3.7 Automatic (Software) Reset and Bootloader Initiation

Rather than requiring a physical press of the reset button before an upload, the YUN is designed in a way that allows it to be reset by software running on a connected computer. The reset is triggered when the YUN’s virtual (CDC) serial / COM port is opened at 1200 baud and then closed. When this happens, the processor will reset, breaking the USB connection to the computer (meaning that the virtual serial / COM port will disappear). After the processor resets, the bootloader starts, remaining active for about 8 seconds. The bootloader can also be initiated by pressing the reset button on the YUN. Note that when the board first powers up, it will jump straight to the user sketch, if present, rather than initiating the bootloader. Because of the way the YUN handles reset it’s best to let the Arduino software try to initiate the reset before uploading, especially if you are in the habit of pressing the reset button before uploading on other boards. If the software can’t reset the board you can always start the bootloader by pressing the reset button on the board.

3.3.3.8 USB Overcurrent Protection

The YUN has a resettable polyfuse that protects your computer’s USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.

3.3.3.9 Physical Characteristics

The maximum length and width of the YUN PCB are 2.7 and 2.1 inches respectively, with the USB connector extending beyond the former dimension. Four screw holes allow the board to be attached to a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil (0.16″), not an even multiple of the 100 mil spacing of the other pins.

Weight of the board is 32 g.

3.4 Liquid Crystal Display

A liquid crystal display (LCD) is a thin, flat display device made up of any number of color or monochrome pixels arrayed in front of a light source or reflector. Each pixel consists of a column of liquid crystal molecules suspended between two transparent electrodes, and two polarizing filters, the axes of polarity of which are perpendicular to each other. Without the liquid crystals between them, light passing through one would be blocked by the other. The liquid crystal twists the polarization of light entering one filter to allow it to pass through the other. Many microcontroller devices use ‘smart LCD’ displays to output visual information. LCD displays designed around JHD204A module, are inexpensive, easy to use, and it is even possible to produce a readout using the 8×80 pixels of the display. They have a standard ASCII set of characters and mathematical symbols. For an 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4bit data bus it only requires the supply lines plus seven extra lines. When the LCD display is not enabled, data lines are tristate and they do not interfere with the operation of the microcontroller.

3.4.1 Signals to the LCD

The LCD also requires 3 control lines from the microcontroller:

1) Enable (E)

This line allows access to the display through R/W and RS lines. When this line is low, the LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the LCD checks the state of the two control lines and responds accordingly.

2) Read/Write (R/W)

This line determines the direction of data between the LCD and microcontroller.

When it is low, data is written to the LCD. When it is high, data is read from the LCD.

3) Register selects (RS)

With the help of this line, the LCD interprets the type of data on data lines. When it is low, an instruction is being written to the LCD. When it is high, a character is being written to the LCD.

3.4.1.1 Logic status on control lines
  • E-0 Access to LCD disabled
  • E-1 Access to LCD enabled
  • R/W-0 Writing data to LCD
  • R/W-1 Reading data from LCD
  • RS-0 Instructions
  • RS-1 Character  
3.4.1.2 Writing and reading the data from the LCD

1. Writing data to the LCD is done in several steps

  • Set R/W bit to low
  • Set RS bit to logic 0 or 1 (instruction or character)
  • Set data to data lines (if it is writing)
  • Set E line to high
  • Set E line to low

2. Read data from data lines (if it is reading)

  • Set R/W bit to high
  • Set RS bit to logic 0 or 1 (instruction or character)
  • Set data to data lines (if it is writing)
  • Set E line to high
  • Set E line to low

6) 3.4.2 Pin Description

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (Two pins are extra in both for back-light LED connections).

 

Table 3.1 Pin description of the LCD

3.5 Relays

A relay is an electrical switch that opens and closes under the control of another electrical circuit. In the original form, the switch is operated by an electromagnet to open or close one or many sets of contacts. It was invented by Joseph Henry in 1835. Because a relay is able to control an output circuit of higher power than the input circuit, it can be considered to be, in a broad sense, a form of an electrical amplifier.

 

 

Fig. 3.11 Sugar cube relay

relay
Figure 3.12 Relay Driving Circuit

Despite the speed of technological developments, some products prove so popular that their key parameters and design features remain virtually unchanged for years. One such product is the ‘sugar cube’ relay, shown in the figure above, which has proved useful to many designers who needed to switch up to 10A, whilst using relatively little PCB area. Since relays are switches, the terminology applied to switches is also applied to relays. A relay will switch one or more poles, each of whose contacts can be thrown by energizing the coil in one of three ways:

  1. Normally – open (NO) contacts connect the circuit when the relay is activate d; the circuit is disconnected when the relay is inactive. It is also called a FORM A contact or “make” contact.
  2. Normally – closed (NC) contacts disconnect the circuit when the relay is activated; the circuit is connected when relay is inactive. It is also called FORM B contact or” break” contact.
  3. Change-over or double-throw contacts control two circuits; one normally open contact and one normally –closed contact with a common terminal. It is also called a Form C “transfer “contact.

The following types of relays are commonly encountered:

 

 

“C” denotes the common terminal in SPDT and DPDT types

Fig. 3.13 Different types of Relays

  • SPST Single Pole Single Throw: These have two terminals which can be connected or disconnected. Including two for the coil, such a relay has four terminals in total. It is ambiguous whether the pole is normally open or normally closed. The terminology “SPNO” and “SPNC” is sometimes used to resolve the ambiguity.
  • SPDT Single Pole Double Throw: A common terminal connects to either of two others. Including two for the coil, such a relay has five terminals in total.
  • DPST Double Pole Single Throw: These have two pairs of terminals. Equivalent to two SPST switches or relays actuated by a single coil. Including two for the coil, such a relay has six terminals in total. It is ambiguous whether the poles are normally open, normally closed, or one of each.
  • DPDT Double Pole Double Throw: These have two rows of change-over terminals. Equivalent to two SPDT switches or relays actuated by a single coil. Such a relay has eight terminals, including the coil.
  • QPDT Quadruple Pole Double Throw: Often referred to as Quad Pole Double Throw, or 4PDT. These have four rows of change-over terminals. Equivalent to four SPDT switches or relays actuated by a single coil or two DPDT relays. In total, fourteen terminals including the coil.

The Relay interfacing circuitry used in the application is:

 

Fig. 3.14 Relay circuitry

3.6 Solar Power Supply

Solar Powered 12V 10W

Converts daylight into electricity to charge 12V batteries, extending battery life.

  • Suitable for trickle charging a wide range of batteries and power packs.
  • Requires only daylight (not direct sunlight).
  • Amorphous solar panel charges even in cloudy and overcast weather.
  • Blocking diode prevents reverse charging and protects battery discharge at night.
  • Pre-cut holes for easy mounting • Link up to 10 panels together for increased power.
  • Ideal for indoor and outdoor use.
  • Perfect for batteries stored in caravans, boats and vehicles in long-term storage.

A solar battery charger for big size vehicles such as caravans, motor homes, boats which has 15W power and has been designed specifically to prevent battery drain from 12 Volt car batteries. This is ideal for your car, motorcycle, snowmobile or your caravan. This product has been designed to work with 12V batteries, to help manage battery drain during every season. It can be used for car and wherever else a 12 volt battery is required. Batteries naturally drain power, especially in cold conditions. If they are allowed to become flat, they may never regain full power. Suction cups are part of the package and can be attached to the charger to enable you to mount the charger where it can best collect sunlight. Interchangeable connectors are available, which include alligator battery clamps and a cigarette lighter plug. In some makes of vehicles, the cigarette lighter may not operate when the ignition is turned off. In such cases, you can connect the charger directly on to the battery by using the alligator battery clamps and cable provided. There is a flashing blue charging LED indicator which lets you know whether the vehicle is being charged and the whole system is working. The outer housing is made of durable ABS plastic. It also has a blocking diode to prevent reverse charging, which makes this product extremely useful. Keep your battery topped up with solar power. This charger ensures that your battery would work even when the day is overcast or dull.  

 

Ultrasonic-Sensor-Library-for-Proteus-3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *