Introduction: TfCD LED Lighting for Indoor Horticulture

As the world gets more urbanized each day, at the cost of nature unfortunately, it becomes more of a challenge to incorporate nature in the everyday life. The technology we stumbled upon, LED lighting for indoor horticulture, offers a solution to this as it encourages and allows plant growth in households that not always or not constantly get sunlight. Possible applications of the technology can be in rooms that aren’t facing the sun, countries on the far north or south of the globe that get limited amounts of daylight during summer or winter or to allow photosynthesis/plant growth throughout the time the sun isn’t up.

Omar Azzalini

Sander Verhage

Step 1: COMPONENTS & LEDs TRY

Before to start, be sure you got everything you need. You may have slightly different components, but you can follow the guide and see how to work with them.

  • LED components

4x 3W red LED (740nm)

3x 1W blue LED (450nm)

1x 33kΩ (1/4W) resistor

1x 390Ω (1/4W) resistor

2x 1Ω (1W) resistor

2x BD139 NPN transistor

  • voltage regulator

1x L7809

1x 100 μF capacitor

1x 10 μF capacitor

  • real time clock module

1307DS RTC

  • controller

1x Arduino UNO board

1x Arduino MICRO board

  • power supply

12V 2A PSU

  • socket

20 x 50 mm protoboard

Step 2: LEDs TRY

Because transistors and resistor are not much reliable, it is better to try which resistor it is necessary for the ideal output current.

So place the LEDs in series by color, and, starting with the given components (BD139 as transistor, 33kΩ and 390Ω as resistor), adjust the LEDs current by changing the resistor value. Take in mind that an higher ohm value means a lower current flow. As it is shown in the last picture we can check with a multi-meter the actual current intensity, avoiding overreaching the maximum supported current.

At this phase you can directly connect the transistor base pin to the ARDUINO 5V output. In such a way you immediately reach the maximum current flow passing trough the circuit.

Step 3: ADD ARDUINO

Because LEDs are powered by a 12V power supply, we need to lower down the voltage in order to provide a more stable operation

Even if ARDUINO UNO and MICRO support a range of 7-12V, if it is always supplied with 12V, the ARDUINO onboard voltage regulator will overheat, damaging the entire board.

With a simple L7809 and two parallel capacitors, as it is shown in the scheme and in the photo, we can easily low the voltage to 9V and power the ARDUINO UNO from the Vin pin.

Step 4: PREPARE THE SOCKET

In order to have a very small and compact form factor is useful to change board and use an ARDUINO MICRO. It maintain the same capability of the ARDUINO UNO, but in 4 times smaller form factor.

Moreover, the already soldered pins of the MICRO board are convenient at this purpose. In the photos is described how we design the PCB, but you can make your own layout. But take in mind that ,because we are using powerful LEDs, the transistor will reach high temperature while fully powered, so a proper dissipation is needed.

Step 5: TEST IT

Before connecting the ARDUINO MICRO, is opportune to test it. So check that everything works with the ARDUINO UNO board and correct eventual mistake. Although it seems a useless step, it will avoid an unpleasant burning of the board.

Moreover carefully check all the voltages and currents remain the same as in the previously steps.

Step 6: CONNECT IT

When you are sure about your work, just connected it and make it works.

Because at this point the transistors are connected to the digital pin 3 and 6 you are no more able to supply them with 5V. So it is come the time to write down some simple code, in order to test it properly.

int red = 3;          		// the PWM pin the LED is attached to
int blue = 6;  
int brightness = 0;    		// how bright the LED is
int i = 1;  
void setup() {
  pinMode(red, OUTPUT);
  pinMode(blue, OUTPUT);
}
void loop() {
  analogWrite(red, brightness);
  analogWrite(blue, brightness);
  brightness = brightness + i;
   if (brightness <= 0 || brightness >= 255) {
    i = -i;
  }
  delay(20);
}

With this short code the LEDs will fade to the maximum brightness and vice-versa.

If you chose different pins to control the LEDs be sure the are PWM pins, just check if there is the symbol ~near the pin number. These pins are 3, 5, 6, 9, 10 and 11.

Step 7: CODE IT

Now just copy the code into you ARDUINO editor and check what you have done it is correct





#include  <Time.h>
#include  <Wire.h>
#include  <DS1307RTC.h>		// a basic DS1307 library that returns time as a time_t
#include  <avr/pgmspace.h> 	//store const array in flash memory

//array[0] values is not used --- days from 1 to 366

const int sunrise[] PROGMEM = {0,    
  752 , 752 , 752 , 752 , 752 , 751 , 751 , 751 , 751 , 750 , 750 , 750 , 749 , 749 , 748 , 748 , 747 , 746 , 746 , 745 , 744 , 743 , 742 , 741 , 741 , 740 , 739 , 738 , 736 , 735 , 734 , 
  733 , 732 , 731 , 729 , 728 , 727 , 725 , 724 , 723 , 721 , 720 , 718 , 717 , 715 , 714 , 712 , 711 , 709 , 707 , 706 , 704 , 703 , 701 , 659 , 657 , 656 , 654 , 652 , 651 , 
  650 , 649 , 647 , 645 , 643 , 641 , 640 , 638 , 636 , 634 , 632 , 630 , 628 , 626 , 625 , 623 , 621 , 619 , 617 , 615 , 613 , 611 , 609 , 607 , 605 , 604 , 602 , 600 , 558 , 556 , 554 ,
  552 , 550 , 548 , 546 , 545 , 543 , 541 , 539 , 537 , 535 , 533 , 532 , 530 , 528 , 526 , 524 , 523 , 521 , 519 , 517 , 516 , 514 , 512 , 511 , 509 , 507 , 506 , 504 , 503 , 501 , 
  500 , 458 , 457 , 455 , 454 , 452 , 451 , 449 , 448 , 447 , 445 , 444 , 443 , 442 , 441 , 439 , 438 , 437 , 436 , 435 , 434 , 433 , 432 , 431 , 430 , 430 , 429 , 428 , 427 , 427 , 426 , 
  425 , 425 , 424 , 424 , 423 , 423 , 423 , 422 , 422 , 422 , 421 , 421 , 421 , 421 , 421 , 421 , 421 , 421 , 421 , 421 , 421 , 422 , 422 , 422 , 423 , 423 , 423 , 424 , 424 , 425 , 
  425 , 426 , 426 , 427 , 428 , 428 , 429 , 430 , 431 , 431 , 432 , 433 , 434 , 435 , 436 , 437 , 438 , 439 , 440 , 441 , 442 , 443 , 444 , 445 , 446 , 447 , 448 , 449 , 450 , 452 , 453 , 
  454 , 455 , 456 , 457 , 459 , 500 , 501 , 502 , 503 , 505 , 506 , 507 , 508 , 509 , 511 , 512 , 513 , 514 , 516 , 517 , 518 , 519 , 520 , 522 , 523 , 524 , 525 , 527 , 528 , 529 , 530 , 
  532 , 533 , 534 , 535 , 536 , 538 , 539 , 540 , 541 , 543 , 544 , 545 , 546 , 547 , 549 , 550 , 551 , 552 , 554 , 555 , 556 , 557 , 559 , 600 , 601 , 602 , 604 , 605 , 606 , 607 , 
  609 , 610 , 611 , 612 , 614 , 615 , 616 , 618 , 619 , 620 , 622 , 623 , 624 , 625 , 627 , 628 , 629 , 631 , 632 , 634 , 635 , 636 , 638 , 639 , 640 , 642 , 643 , 645 , 646 , 647 , 649 ,
  650 , 652 , 653 , 654 , 656 , 657 , 659 , 700 , 701 , 703 , 704 , 706 , 707 , 708 , 710 , 711 , 713 , 714 , 715 , 717 , 718 , 719 , 721 , 722 , 723 , 725 , 726 , 727 , 728 , 729 , 
  731 , 732 , 733 , 734 , 735 , 736 , 737 , 738 , 739 , 740 , 741 , 742 , 743 , 744 , 745 , 745 , 746 , 747 , 747 , 748 , 748 , 749 , 749 , 750 , 750 , 751 , 751 , 751 , 751 , 752 , 752 };
  
const int sunset[] PROGMEM = {0, 
  1637 ,  1638 ,  1639 ,  1640 ,  1641 ,  1642 ,  1643 ,  1644 ,  1646 ,  1647 ,  1648 ,  1649 ,  1650 ,  1652 ,  1653 ,  1654 ,  1655 ,  1657 ,  1658 ,  1659 ,  1701 ,  1702 ,  1704 ,  1705 ,  1706 ,  1708 ,  1709 ,  1711 ,  1712 ,  1714 , 1715 ,  
  1717 ,  1718 ,  1720 ,  1721 ,  1722 ,  1724 ,  1725 ,  1727 ,  1728 ,  1730 ,  1731 ,  1733 ,  1734 ,  1736 ,  1737 ,  1739 ,  1740 ,  1741 ,  1743 ,  1744 ,  1746 ,  1747 ,  1749 ,  1750 ,  1752 ,  1753 ,  1754 ,  1756 ,  1756 , 
  1756 ,  1757 ,  1759 ,  1800 ,  1801 ,  1803 ,  1804 ,  1805 ,  1807 ,  1808 ,  1809 ,  1811 ,  1812 ,  1814 ,  1815 ,  1816 ,  1818 ,  1819 ,  1820 ,  1822 ,  1823 ,   824 ,  1826 ,  1827 ,  1828 ,  1829 ,  1831 ,  1832 ,  1833 ,  1835 ,  1836 , 
  1837 ,  1839 ,  1840 ,  1841 ,  1843 ,  1844 ,  1845 ,  1846 ,  1848 ,  1849 ,  1850 ,  1852 ,  1853 ,  1854 ,  1856 ,  1857 ,  1858 ,  1859 ,  1901 ,  1902 ,  1903 ,  1905 ,  1906 ,  1907 ,  1909 ,  1910 ,  1911 ,  1912 ,  1914 ,  1915 ,  
  1916 ,  1918 ,  1919 ,  1920 ,  1921 ,  1923 ,  1924 ,  1925 ,  1926 ,  1928 ,  1929 ,  1930 ,  1931 ,  1933 ,  1934 ,  1935 ,  1936 ,  1937 ,  1938 ,  1940 ,  1941 ,  1942 ,  1943 ,  1944 ,  1945 ,  1946 ,  1947 ,  1948 ,  1949 ,  1950 ,  1951 ,  
  1952 ,  1953 ,  1954 ,  1954 ,  1955 ,  1956 ,  1957 ,  1957 ,  1958 ,  1959 ,  1959 ,  2000 ,  2001 ,  2001 ,  2002 ,  2002 ,  2002 ,  2003 ,  2003 ,  2003 ,  2004 ,  2004 ,  2004 ,  2004 ,  2004 ,  2005 ,  2005 ,  2005 ,  2005 ,  2004 ,  
  2004 ,  2004 ,  2004 ,  2004 ,  2003 ,  2003 ,  2003 ,  2002 ,  2002 ,  2001 ,  2001 ,  2000 ,  2000 ,  1959 ,  1958 ,  1958 ,  1957 ,  1956 ,  1955 ,  1954 ,  1953 ,  1953 ,  1952 ,  1951 ,  1950 ,  1948 ,  1947 ,  1946 ,  1945 ,  1944 ,  1943 ,  
  1941 ,  1940 ,  1939 ,  1938 ,  1936 ,  1935 ,  1933 ,  1932 ,  1930 ,  1929 ,  1927 ,  1926 ,  1924 ,  1923 ,  1921 ,  1920 ,  1918 ,  1916 ,  1915 ,  1913 ,  1911 ,  1910 ,  1908 ,  1906 ,  1904 ,  1903 ,  1901 ,  1859 ,  1857 ,  1855 ,  1854 , 
  1852 ,  1850 ,  1848 ,  1846 ,  1844 ,  1842 ,  1840 ,  1839 ,  1837 ,  1835 ,  1833 ,  1831 ,  1829 ,  1827 ,  1825 ,  1823 ,  1821 ,  1819 ,  1817 ,  1815 ,  1813 ,  1811 ,  1810 ,  1808 ,  1806 ,  1804 ,  1802 ,  1800 ,  1758 ,  1756 ,  
  1754 ,  1752 ,  1750 ,  1748 ,  1746 ,  1745 ,  1743 ,  1741 ,  1739 ,  1737 ,  1735 ,  1733 ,  1732 ,  1730 ,  1728 ,  1726 ,  1724 ,  1723 ,  1721 ,  1719 ,  1717 ,  1716 ,  1714 ,  1712 ,  1711 ,  1709 ,  1708 ,  1706 ,  1704 ,  1703 ,  1701 , 
  1700 ,  1658 ,  1657 ,  1656 ,  1654 ,  1653 ,  1651 ,  1650 ,  1649 ,  1648 ,  1646 ,  1645 ,  1644 ,  1643 ,  1642 ,  1641 ,  1640 ,  1639 ,  1638 ,  1637 ,  1636 ,  1635 ,  1634 ,  1634 ,  1633 ,  1632 ,  1631 ,  1631 ,  1630 ,  1630 ,  
  1629 ,  1629 ,  1628 ,  1628 ,  1628 ,  1628 ,  1627 ,  1627 ,  1627 ,  1627 ,  1627 ,  1627 ,  1627 ,  1627 ,  1627 ,  1627 ,  1628 ,  1628 ,  1628 ,  1629 ,  1629 ,  1629 ,  1630 ,  1630 ,  1631 ,  1632 ,  1632 ,  1633 ,  1634 ,  1635 ,  1636  };
  
const int day[] PROGMEM = {0, 
  101 , 102 , 103 , 104 , 105 , 106 , 107 , 108 , 109 , 110 , 111 , 112 , 113 , 114 , 115 , 116 , 117 , 118 , 119 , 120 , 121 , 122 , 123 , 124 , 125 , 126 , 127 , 128 , 129 , 130 , 131 , 
  201 , 202 , 203 , 204 , 205 , 206 , 207 , 208 , 209 , 210 , 211 , 212 , 213 , 214 , 215 , 216 , 217 , 218 , 219 , 220 , 221 , 222 , 223 , 224 , 225 , 226 , 227 , 228 , 229 , 
  301 , 302 , 303 , 304 , 305 , 306 , 307 , 308 , 309 , 310 , 311 , 312 , 313 , 314 , 315 , 316 , 317 , 318 , 319 , 320 , 321 , 322 , 323 , 324 , 325 , 326 , 327 , 328 , 329 , 330 , 331 , 
  401 , 402 , 403 , 404 , 405 , 406 , 407 , 408 , 409 , 410 , 411 , 412 , 413 , 414 , 415 , 416 , 417 , 418 , 419 , 420 , 421 , 422 , 423 , 424 , 425 , 426 , 427 , 428 , 429 , 430 , 
  501 , 502 , 503 , 504 , 505 , 506 , 507 , 508 , 509 , 510 , 511 , 512 , 513 , 514 , 515 , 516 , 517 , 518 , 519 , 520 , 521 , 522 , 523 , 524 , 525 , 526 , 527 , 528 , 529 , 530 , 531 ,
  601 , 602 , 603 , 604 , 605 , 606 , 607 , 608 , 609 , 610 , 611 , 612 , 613 , 614 , 615 , 616 , 617 , 618 , 619 , 620 , 621 , 622 , 623 , 624 , 625 , 626 , 627 , 628 , 629 , 630 , 
  701 , 702 , 703 , 704 , 705 , 706 , 707 , 708 , 709 , 710 , 711 , 712 , 713 , 714 , 715 , 716 , 717 , 718 , 719 , 720 , 721 , 722 , 723 , 724 , 725 , 726 , 727 , 728 , 729 , 730 , 731 , 
  801 , 802 , 803 , 804 , 805 , 806 , 807 , 808 , 809 , 810 , 811 , 812 , 813 , 814 , 815 , 816 , 817 , 818 , 819 , 820 , 821 , 822 , 823 , 824 , 825 , 826 , 827 , 828 , 829 , 830 , 831 ,
  901 , 902 , 903 , 904 , 905 , 906 , 907 , 908 , 909 , 910 , 911 , 912 , 913 , 914 , 915 , 916 , 917 , 918 , 919 , 920 , 921 , 922 , 923 , 924 , 925 , 926 , 927 , 928 , 929 , 930 , 
  1001 ,  1002 ,  1003 ,  1004 ,  1005 ,  1006 ,  1007 ,  1008 ,  1009 ,  1010 ,  1011 ,  1012 ,  1013 ,  1014 ,  1015 ,  1016 ,  1017 ,  1018 ,  1019 ,  1020 ,  1021 ,  1022 ,  1023 ,  1024 ,  1025 ,  1026 ,  1027 ,  1028 ,  1029 ,  1030 ,  1031 ,  
  1101 ,  1102 ,  1103 ,  1104 ,  1105 ,  1106 ,  1107 ,  1108 ,  1109 ,  1110 ,  1111 ,  1112 ,  1113 ,  1114 ,  1115 ,  1116 ,  1117 ,  1118 ,  1119 ,  1120 ,  1121 ,  1122 ,  1123 ,  1124 ,  1125 ,  1126 ,  1127 ,  1128 ,  1129 ,  1130 ,  
  1201 ,  1202 ,  1203 ,  1204 ,  1205 ,  1206 ,  1207 ,  1208 ,  1209 ,  1210 ,  1211 ,  1212 ,  1213 ,  1214 ,  1215 ,  1216 ,  1217 ,  1218 ,  1219 ,  1220 ,  1221 ,  1222 ,  1223 ,  1224 ,  1225 ,  1226 ,  1227 ,  1228 ,  1229 ,  1230 ,  1231 };</p><p>int i;            // day of the year


int rise;         // array sunrise
int set;          // array sunset
int d;            // array day</p><p>int now;
int today;

int b = 5;        // blue pin
int r = 6;        // red pin
int l = 0;        // light brightness
int del = 30000;  // delay ---> del = 30000 2hours of fading turing on/off
int delS = 7500;
int fast = 50;    // fast delay for fading!
int c;      

      
void setup()  {
  Serial.begin(9600);
  pinMode(b, OUTPUT);
  pinMode(r, OUTPUT);
  setSyncProvider(RTC.get);   // get data from RTC    
}

void loop(){
  if (timeStatus() == timeSet) {
    setday();
    light();
    } 
  else {
    Serial.println("The time has not been set.  Please run the Time");
    Serial.println("TimeRTCSet example, or DS1307RTC SetTime example.");
    Serial.println();
    delay(400000);
  }
}

void setday(){
  today = 100*month()+day();
  for ( i = 0; i < 366 ; i++){
    d = pgm_read_word(day + i);    // recall array value saved in the flash memory --> pgm_read_word(array name + position)
    if (d == today){
      break;
    }
  }
}

void light(){
   now = 100*hour()+minute();
   rise = pgm_read_word(sunrise + i);
   set = pgm_read_word(sunset + i); 
   if ( now > rise + 200 && now < set - 200){
    iOn();
   }
   else if ( now > rise + 100 && now <= set + 200){
    sOn();
   }
   else if ( now > rise && now <= set + 100){
    on();
   }
   else{
    off();
   }
}


void on() {
  if(l < 25){
    analogWrite(b, l);
    analogWrite(r, l);
    delay(fast);
    l++;
  }
  else if(l >= 25 & l < 255){
    analogWrite(b, l);
    analogWrite(r, l);
    delay(del);
    l++;
  }
  else if(l==255){
    analogWrite(b, l);
    analogWrite(r, l);
    }
}

void sOn(){
  if(l < 25){
    analogWrite(b, l);
    analogWrite(r, l);
    delay(fast);
    l++;
  }
  else if(l >= 25 & l < 255){
    analogWrite(b, l);
    analogWrite(r, l);
    delay(delS);
    l++;
  }
  else if(l==255){
    analogWrite(b, l);
    analogWrite(r, l);
    }
}

void iOn() {
  if(l < 255){
    analogWrite(b, l);
    analogWrite(r, l);
    delay(fast);
    l++;
  }
  else if(l==255){
    analogWrite(b, l);
    analogWrite(r, l);
    }
}

void off() {
  if(l > 25){
    analogWrite(b, l);
    analogWrite(r, l);
    delay(del);
    l--;
  }
   else if(l > 0 & l <= 25){
    analogWrite(b, l);
    analogWrite(r, l);
    delay(fast);
    l--;
  }
  else if(l==0){
    analogWrite(b, l);
    analogWrite(r, l);
  }
}