Measure the light intensity using the light sensor


  • Analog Input
  • Light Sensor

The light sensor used is the BPW34. This is a high speed and high sensitive silicon PIN photodiode in a miniature flat plastic package. A photodiode is designed to be responsive to optical input. Due to its waterclear epoxy the device is sensitive to visible and infrared radiation. The large active area combined with a flat case gives a high sensitivity at a wide viewing angle.

Photodiodes can be used in either zero bias or reverse bias. Diodes have extremely high resistance when reverse biased. This resistance is reduced when light of an appropriate frequency shines on the junction. Hence, a reverse biased diode can be used as a light detector by monitoring the current running through it. Coupled to a 10Kohm resistor, and given the specification of the BPW34 a simple relationship between lux (light intensity) and voltage is given by

lux = 1333 * Vo

import emant m = emant.Emant300() m.Open("00:06:66:00:a1:f7") print m.HwId() volt, binval = m.ReadAnalog(emant.Emant300.AIN0,emant.Emant300.COM) lux = 1333 * volt print lux m.Close()

Code Explained

import emant

Imports the module emant, and creates a reference to that module in the current namespace.

m = emant.Emant300()

An instance of the Emant300 class (defined in the emant module) and assigning the newly created instance to the variable m.


Open is a method that instructs the program to connect to the EMANT380 DAQ module that is connected to the Android Smartphone / PC. Modify the value to your mac address shown on your EMANT380 module.

print m.HwId()

HwId is a property that shows the firmware version

volt, binval = m.ReadAnalog(emant.Emant300.AIN0,emant.Emant300.COM)

The analog voltage across AIN0 and GND (COM) is read. The 10K resistor reading the Photodiode current is connected to AIN0 and GND (COM). Emant300.AIN.AIN0 and Emant300.AIN.COM are the respective enumeration. The result is returned as a tuple voltage, 24 bit binary result

lux = 1333 * volt print lux

The voltage is converted to Lux and then displayed on the console output.


Finally the DAQ connection is closed. To ensure that your programs end correctly, always call the Close method before you exit your programs.

Python with EMANT380
| TOC | 1 | 2 | 3 | 4 | 5 | 6 |