Project tutorial
Flashing LED Light and Temperature Data Logger

Flashing LED Light and Temperature Data Logger © GPL3+

A super-fast and super-bright flashing LED light, perfect for growing plants (and you can record the temperature too)!

  • 3,729 views
  • 2 comments
  • 8 respects

Components and supplies

Solid and/or stranded core wire (assorted colors)
×1
Chanzon LED light chips (full spectrum)
×1
Chanzon 1W 3W 5W LED heat spreaders
×1
heat sink for MOSFET
This is screwed on to the MOSFET on the SSR module. It is optional, as my MOSFET did not get too hot.
×1
SparkFun MOSFET Power Control Kit
×1
aluminum heat sink
×1
microSD card
For your computer to read the chip, you may need a microSD card adapter.
×1
LPV60-36 constant voltage controller
×1
DS3231 AT24C32 11C real time clock module
×1
2-prong power cord
Any old 2-prong power cord will do-- just cut it and solder it to the constant voltage controller.
×1
heat shrink tubing
For soldering wires together.
×1
microSD card module
×1
thermal adhesive
×1
11026 02
Jumper wires (generic)
×1
Uno buzvvptrvs
Arduino UNO Rev3
×1

About this project

I built this light for a research project that required me to test the effect of different frequencies of flashing light on the growth of algae. It turns out that algae is more photosynthetically efficient at certain light frequencies (this paper outlines an example of the phenomenon and its importance, if you're interested!). You could test this light out on your own house plants, or use it in your own science experiment. If there are any other uses, I'd love to know! Also, I had pretty much zero experience with electronics before starting this project, so if anyone has any suggestions for improving the project, or any mistakes I may have made, please let me know! The light is up and running now, so I can verify that it works! I'll upload a video soon.

The complete LED light configuration consists of two strands of high-powered LEDs, wired in parallel and mounted on an aluminum heat sink. Power is supplied to the light through a 36 V constant-voltage controller. The frequency of the flashing is directed by an Arduino Uno microcontroller, through a solid-state relay (SSR). A temperature data logger is included in the apparatus—it reads the temperature within the growing area and logs it to an SD card via the Arduino. It can flash at over 100 hertz.

Begin by measuring the approximate resistance of each LED bulb. This can be done by wiring each bulb to a 6-volt power source and measuring the ohms of the bulb with a standard multimeter. Wait approximately 15 minutes until the LED’s temperature stabilizes, record the resistance, and label the LEDs. Then, organize the 12 LED bulbs into 2 groups of 6. The cumulative resistance of the LEDs in each group should be roughly equivalent, which will help prevent thermal runaway.

After the LED groups are sorted, begin the assembly of the light. First, sand the surface of the aluminum heat sink to remove surface oxidation that could compromise the strength of the thermal adhesive. Mix the thermal adhesive and spread it in two rows across the heat sink. Then, place the heat spreaders firmly onto the adhesive in the pattern shown below.

Solder the LED bulbs onto the heat spreaders, ensuring that the direction of the diode is aligned with the flow of current through the spreaders. Test the direction of the diode by wiring the LED to a 5-volt power source. Try attaching the positive and negative ends of the power source to different ends of the diode. If the diode lights up, the side of the diode wired to the positive end of the power supply is the positive side, and the side wired to the negative end of the power supply is the negative end. Solder the LEDs as seen below.

Then, cut and strip 12 segments of connector wire. Use these to wire the LEDs in series, as seen below.

Cut 4 additional 12-inch lengths of connector wire (2 red and two black). Strip either end of each segment, and wire to the LED array as seen below.

Then, use a wire nut to connect the two positive (red) wires with a longer wire. This lead will be connected to the relay, which will in turn be connected to the constant voltage controller. The length of this wire is as-needed, depending on the area where the light is set up.

The next step is assembling the SSR (AKA the SparkFun MOSFET Power Control Kit). Solder the pins into the correct places on the breadboard, in the configuration seen below. Next, connect the positive and negative DC leads of the constant voltage power supply to the positive and negative inputs on the SSR, as seen below. Also solder the two-pronged power cable to the AC ends of the constant voltage power supply. Finally, screw the MOSFET heat sink onto the MOSFET soldered to the breadboard (optional-- my MOSFET didn't end up getting very hot).

At this point, also attach the positive and negative leads attached to the light apparatus to the remaining positive and negative ports on the SSR. All wire lengths can be cut as needed. Also connect the positive and negative leads of the DC voltage controller to the SSR, as seen below. The voltage controller serves to keep at least one aspect of the electricity powering the light constant, to reduce any variations in light intensity.

Then, connect the SD card modules and DS3231 real-time clock module to the Arduino Uno. This can be done with jumper wires. A breadboard could also be used to organize the circuit components. The pin connections are outlined in the tables below and illustrated in the following diagram. In addition, connect pin 4 to the gate pin off the SSR. This is also illustrated in the diagram.

Then, download the DS3231 module library from the following link. Upload the code to the Arduino Uno via the USB port. Enter the date, and the hertz at which the light will flash. The flash is set at a 10 percent duty cycle, but this can also be adjusted.

After uploading the code, insert a micro SD card into the SD card module. Then, connect the Arduino power supply to the Arduino Uno, and the main power cord to an AC outlet.

Then It's all ready to go! The light should begin flashing at the designated frequency. I wouldn't run the light for too long though -- the LEDs are seriously powerful, and heat up quickly.

Code

Flashing Light CodeC/C++
In order to change to frequency of the flashing light, adjust the variable hertz (line 31). The start date and time can be adjusted in lines 27 and 28. The code controls the flashing light, and directs the writing of temperature data to the SD card (in CSV format). This code was derived from a how-to post on the HowToMechatronics website.
#include <Wire.h>

#include <DS3231.h> //this library includes functions to be used for the DS3231 module
#include <SD.h> //this library includes functions to be used for the SD card module
#include <SPI.h> //this library includes functions that allow for the communication between the microcontroller and external devices

File tempData; //[defines the variable tempData as a file-type object]
DS3231 rtc(SDA, SCL); //[]
int pinCS = 10; //assigns pin 10 as the Chip Select pin
int gatePin = 4; //assigns pin 4 as the gate pin

void setup(){ //code within setup will only be carried out once

  pinMode(gatePin, OUTPUT); //defines gatePin as output
  
  Serial.begin(9600); //sets the rate of data transmission to the Serial Monitor (Tools > Serial Monitor) at 9600 bits per second
  pinMode(pinCS, OUTPUT); //defines pinCS as output

  if (SD.begin()){ //initializes the SD card and library and begins use of the SPI bus and CS pin
    Serial.println("ready"); //if the SD card and library are initialized successfully, the begin function will return True, and "ready" will be printed to the Serial Monitor
  }
  else{ 
    Serial.println("failed"); //if the SD card and library are not initialized successfully, the begin function will return False, and "failed" will be printed to the Serial Monitor
    return; //the return function will stop the rest of the code from running if the SD card and library fail to initialize
  }
  rtc.begin(); //initializes the microcontroller's internal real time clock and RTC library
  rtc.setTime(0,0,0); //sets the time (hour, minute, second)
  rtc.setDate(30,6,2018); //sets the date [(day, month, year)]
}

int hertz = 1; //creates the variable hertz, which can be altered
float delay_HIGH = (1000/hertz)*0.1; //creates the variable delay_HIGH, which is dependent on hertz and provides for a 10 percent duty cycle
float delay_LOW = (1000/hertz)*0.9; //creates the variable delay_LOW, which is dependent on hertz and provides for a 10 percent duty cycle
int max_count = 600*hertz; //creates the variable max_count, which is dependent on hertz and gives the number of flash cycles that can be repeated in a 10 minute period

void loop(){
  int count = 0;
  while (count <= max_count){ //continues the flash cycle for 10 minutes, or repeats the cycle while the cycle count is less than the number of cycles in 10 minutes   
    digitalWrite(gatePin, HIGH); //sends a HIGH signal to the gate of the MOSFET, powering on the LEDs
    delay(delay_HIGH); //keeps the LEDs on for time delay_HIGH
    digitalWrite(gatePin, LOW); //sends a LOW signal to the gate of the MOSFET, powering off the LEDs
    delay(delay_LOW); //keeps the LEDs off for time delay_low
    count ++; //increments the variable count by one
  }
  Serial.print(rtc.getDateStr()); //prints the date to the Serial Monitor, [imported from the internal RTC]
  Serial.print(",");
  Serial.print(rtc.getTimeStr()); //prints the time to the Serial Monitor, [imported from the internal RTC]
  Serial.print(",");
  Serial.println(float(rtc.getTemp())); //prints the temperature to the Serial Monitor, imported from the DS3231 module

  tempData = SD.open("data.txt", FILE_WRITE); //creates the variable tempData, [which opens/creates the file "data.txt" from the SD card and allows writing]
  if(tempData){ //if the "data.txt" file on the SD card is successfully opened/created, the following data is written to the file in CSV format
    tempData.print(rtc.getDateStr()); //writes the date to "data.txt"
    tempData.print(",");
    tempData.print(rtc.getTimeStr()); //writes the time to "data.txt"
    tempData.print(",");
    tempData.println(float(rtc.getTemp())); //writes the temperature to "data.txt"
    tempData.close(); //closes the file "data.txt"
  }
  else{
    Serial.println("error opening file"); //if the "data.txt" file is not successfully opened/created, "error opening file" is printed to the Serial Monitor
  }
}

Schematics

Overview of Wiring Schematics
This is just a diagram showing which pins connect to which. It is not drawn to scale, and wire lengths will have to be adjusted as-needed.
Led diagram 06 hc4tr99fvi

Comments

Author

Pipparichter
pipparichter
  • 1 project
  • 3 followers

Additional contributors

  • I derived my code from this source, and figured out how to connect the rtc and sd card module to the arduino with this tutorial! by HowToMechatronics
  • This is where i got the ds3231 rtc library. the link to the license for the library can be found below! by Rinky-Dink Electronics

Published on

September 1, 2018

Members who respect this project

ErospeterDefaultOweningramPhoto15171057 10206517574452307 2647265571948351861 n

and 3 others

See similar projects
you might like

Similar projects you might like

Arduino Bluetooth Basic Tutorial

by Mayoogh Girish

  • 454,630 views
  • 42 comments
  • 236 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 285,509 views
  • 95 comments
  • 671 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 229,416 views
  • 38 comments
  • 237 respects

OpenCat

Project in progress by Team Petoi

  • 195,958 views
  • 154 comments
  • 1,362 respects
Add projectSign up / Login