4 Replies Latest reply on Nov 12, 2013 7:21 AM by lilsebastian

    PSoC 4 Pioneer Kit Community Project#096 – Light Sensor Project




      In today’s example project we will create a light sensor project that interfaces with the DFRobot Ambient Light Sensor (DFR0026). This example project uses an opamp interfaces to an ADC SAR to read in the value from the light sensor. The value from the light sensor is then transmitted over UART over the PSoC 5LP USB-UART bridge and displayed on the PC.


      003 - Hardware Image.png


      The key point of this example is that the PSoC 4 is put into a deep sleep mode and uses the Watch Dog Timer (WDT) to trigger an interrupt to sample the ADC and then move back into deep sleep mode. This is a common solution needed for devices that are power conscience or power limited.


      001 - Schematic Design 1.png


      Forum Post Attachments:


      At the bottom of this post we are including the following items:

      • Example Project Zip File
      • Project Images


      Components Used: 


      The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:

      • OpAmp
      • ADC SAR Seq
      • UART
      • WDT
      • CyPins


      Firmware Description:


      The main.c firmware is included in the example project. Please review the commented sections for more details.


      005 - DFRobot Light Sensor.png


      In this project the PSoC 4 device enters deepsleep mode after processing and transmitting the light sensor data. To reduce the power usage of the example we control the ground of the light sensor with a pin on the PSoC 4. Before entering deepsleep, the light sensor ground pin is set to high to disable the sensor. After wakeup, the pin is set to low, to enable the light sensor for ADC conversion. Once the device has powered the light sensor the SAR ADC samples and coverts the output voltage of the light sensor. The PSoC 4 then transmits the result to Hyperterminal via the UART and the PSoC 5LP bridge. The PSoC 4 then identifies if it is night or day through a range detection. The device then enters deepsleep to be awoken by the WDT on the next interrupt.


      002 - Firmware Flow.png


      Hardware Connections:


      This example project utilizes a number of external components that are details in the PSoC 4 schematic design. Additionally users will need to connect the light sensor to the specified connections.


      The UART lines from the PSoC 4 must be connected to the PSoC 5LP UART bridge (P12.6 and P12.7).


      001 - Schematic Design 1.png


      Test Your Project:


      Connect the hardware and then program this example project into the Pioneer board. Connect the Pioneer board to the PC and then launch the hyperterminal to view the output from the example.


      004 - PuTTY Output.png


      I hope this example can help you in your design.




        • Re: PSoC 4 Pioneer Kit Community Project#096 – Light Sensor Project

          Hello Matt.

          Thanks for this project.

          A light sensor, as its name suggests, is a device that is used to detect light. There are many different types of light sensors, each of which works in a slightly different way. A photocell or photoresistor, for example, is a small sensor that changes its resistance when light shines on it; they are used in many consumer products to determine the intensity of light. A charged coupled device (CCD) transports electrically charged signals, and is used as a light sensor in digital cameras and night-vision devices. Photomultipliers detect light and multiply it.


          great project.




          Jesus Antonio.

            • Re: PSoC 4 Pioneer Kit Community Project#096 – Light Sensor Project

              It seems, the DFRobot Ambient Light Sensor board, DFR0026 hasnot too much components:

              - the CDS Photoresistor

              - two resistors

              - and one capacitor.

              It seems, easy to substitute with another light detector, for experiments.

              Maybe the used CDS component has special specification, why they call it ambient light sensor. Do you know what is the ID of this component?

              If I know well, there arenot too popular nowewadays the  cadmium sulphid based photoresistor devices. Here is an interesting application of it: detect the moonlight with it. There is another note, that this devices have signiphicant variability in its parameters:

              " I am informed that the industry standard for specification tolerances of CDS photocells is typically 30% .... this amounts to a very wide latitude of variability in photo-conductive cells..."


              Another interesting field of the light sensors to trigger photo-camera, for example take pictures of lightening strikes. Usually this sensors need another stage, to produce a "well-formed" impuse for the camera trigger.


            • Re: PSoC 4 Pioneer Kit Community Project#096 – Light Sensor Project

              Hi Matt,


              A nice little project to show how you can control a process based upon day or night determination.


              You could also use the circuit in a dark room to determine if someone has entered and is using a flash light (or torch for the UK) to set off an intruder alarm.




              • Re: PSoC 4 Pioneer Kit Community Project#096 – Light Sensor Project

                Please could someone explain to me how the gain of the op amp works?


                It has no programmable gain so how do I know what voltage I am expecting at the output for a specific input? it doesn't make any sense to me..


                Like if I know my input signal is 10mV pk/pk what am I going to get at the output of the opamp component.. I know the 5LP has a PGA which makes more sense to me.


                Also what is the point of the voltage divider at the input of the ADC?