BREAKING NEWS

10 November 2015

Irrigation controller with LCD Arduino

 The project to create a central irrigation Arduino continues and since many have asked me to have a LCD screen on the unit I decided to take a few projects and fuse them together.


Add an LCD display 16 × 2 and the buttons you can use the  LCD keypad and run time adjustment in addition to the bands of irrigation.
Unfortunately, the LCD keypad is incompatible with the Relay Shield previously chosen for the project because they both use the pins 5,6,7,8 for different controls, the relay use them to:
relay shield
and the LCD keypad uses the same pin to control the display 16 × 2.
A downside is the fact that in both shield can not change the pin to which the circuits are connected and that makes you have to choose which one to replace, I preferred to replace the keypad with LCD display ACM1602B already used in this article and 5 buttons some connected the LCD Keypad.
I will devote the connection button for a specific item.

Irrigation controller with Arduino LCD ACM1602B

the display ACM1602B was the subject of some items is as simple display is connected to the RTC Shield to display the date and time, you can find all the description in this article .
Before using the power unit design irrigation Arduino is necessary that you change the connections and the sketch used, so starting from the article in which the display already living with the RTC Shield perform changes to allow the display of live even with the Relay Shield the Arduino control irrigation.

Connections of the control irrigation with the Arduino ACM1602B

The display ACM1602B looks like the following links:
Arduino control irrigation
  • Enable
  • RS
  • D4
  • D5
  • D6
  • D7
  • Contrast
  • BLACKLIGHT
all these pins must be connected to the Arduino as shown in the figure:
control irrigation Arduino connections
in practice will move the pin D4-D7 from pins 7, 6, 5, 4 Arduino pins 10, 11, 12, 13, freeing the pin 5,6,7 used by the Relay Shield.
It also moves the pin RS and EN respectively from 0:11 to 4:03 pin of Arduino.
Pin 3 was used to manage the display contrast, you can use pin 9 remains free after the move.

The sketch of tests to control irrigation Arduino LCD

the sketch you see below part from sketches made with the RTC clock Arduino Shield and the display ACM1602B to which you will apply the changes to make it work with the new connections.
The purpose of this sketch is to let you verify that all the shield of the project can be operated with the LCD 16 × 2 Appenna wired.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<Font> <font> / * </ font> </ font> <font> </ font> <font> <font>
 * RTC & LCD </ font> </ font> <font> </ font> <font> <font>
 * </ Font> </ font> <font> </ font> <font> <font>
 * Author: Mauro Alfieri </ font> </ font> <font> </ font> <font> <font>
 * Tw: mauroalfieri </ font> </ font> <font> </ font> <font> <font>
 * </ Font> </ font> <font> </ font> <font> <font>
 * Web: http: //www.mauroalfieri.it</font> </ font> <font> </ font> <font> <font>
 * / </ Font> </ font> <font> </ font>
<Font> </ font> <font> <font>
#include <Wire.h> </ font> </ font> <font> </ font> <font> <font>
#include <RTClib.h> </ font> </ font> <font> </ font> <font> <font>
#include <LiquidCrystal.h> </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
#define BACKLIGHT 2 </ font> </ font> <font> </ font> <font> <font>
#define CONTRAST 9 </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
char buffer [10]; </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
RTC_DS1307 RTC; </ font> </ font> <font> </ font> <font> <font>
LiquidCrystal LCD (4, 3, 10, 11, 12, 13); </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
void setup () {</ font> </ font> <font> </ font> <font> <font>
    pinMode (BACKLIGHT, OUTPUT); </ font> </ font> <font> </ font> <font> <font>
    pinMode (CONTRAST, OUTPUT); </ font> </ font> <font> </ font> <font> <font>
    digitalWrite (BACKLIGHT, HIGH); </ font> </ font> <font> </ font> <font> <font>
    analogWrite (CONTRAST, 40); </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
    Wire.begin (); </ font> </ font> <font> </ font> <font> <font>
    RTC.begin (); </ font> </ font> <font> </ font> <font> <font>
    lcd.begin (16, 2); </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
    RTC.sqw (1); </ font> </ font> <font> </ font> <font> <font>
    if (! RTC.isrunning ()) {</ font> </ font> <font> </ font> <font> <font>
      RTC.adjust (DateTime (__ DATE__, __TIME __)); </ font> </ font> <font> </ font> <font> <font>
    } </ Font> </ font> <font> </ font> <font> <font>
} </ Font> </ font> <font> </ font>
<Font> </ font> <font> <font>
void loop () {</ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
    DateTime now = RTC.now (); </ font> </ font> <font> </ font> <font> <font>
    lcd.clear (); </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
    sprintf (buffer, "% 02d / 02d% /% d" , now.day (), now.month (), now.year ()); </ font> </ font> <font> </ font> < font> <font>
    lcd.setCursor (0,0); </ font> </ font> <font> </ font> <font> <font>
    lcd.print (buffer); </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
    char buffer [10] = "" ; </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
    sprintf (buffer, "% 02d:% 02d:% 02d" , now.hour (), now.minute (), now.second ()); </ font> </ font> <font> </ font> < font> <font>
    lcd.setCursor (0.1); </ font> </ font> <font> </ font> <font> <font>
    lcd.print (buffer); </ font> </ font> <font> </ font>
<Font> </ font> <font> <font>
    delay (1000); </ font> </ font> <font> </ font> <font> <font>
} </ Font> </ font>
lines where you have to make changes that are the line 15 changes from:
<Font> <font> #define CONTRAST 3 </ font> </ font>
to
<Font> <font> #define CONTRAST 9 </ font> </ font>
and the line 20, you have to change from:
<Font> <font> LiquidCrystal LCD (12, 11, 7, 6, 5, 4); </ font> </ font>
to
<Font> <font> LiquidCrystal LCD (4, 3, 10, 11, 12, 13); </ font> </ font>
The rest of the sketch you can leave it unchanged.
Performing upload the sketch on the control unit with LCD Arduino irrigation will see the correct date and time set in the RTC Shield it is proof that everything works properly and there are no conflicts between the pins used by the shield project.

Share this:

Post a Comment

 
Back To Top
Distributed By Blogger Templates | Designed By OddThemes