Advice 1: How to connect a light sensor BH1750 Arduino to

At this time, connect the digital 16-bit light sensor BH1750 (luxometer), implemented on the module GY-302, to Arduino.
Light sensor BH1750
You will need
  • - Arduino;
  • module GY-302 digital light sensor BH1750;
  • - a personal computer.
Instruction
1
Consider a module GY-302 BH1750 sensor. The BH1750 sensor is a digital 16-bit digital ambient light sensor that sets the range of measurements from 1 to 65535 Lux. The BH1750 sensor sensitive to visible light and virtually unaffected by infrared radiation, i.e. responds to the same spectral range as the human eye. As a consequence such sensors are widespread in today's electronic equipment, mobile devices, photo and video cameras, in systems of "smart house" and many others.
The connection module is two-wire I2C interface, while powered from +5 volts. The I2C interface is implemented in the Arduino analog pins A4 and A5, which are responsible for SDA (data bus) and SCL (bus clock), respectively. Output ADDR of module GY-302 can be left unconnected or connected to ground.
Wiring diagram for the BH1750 light sensor to Arduino
2
We will not delve into the details of the implementation of the interface sensor BH1750 Arduino, and use a ready-made library. You can download it here: https://github.com/claws/BH1750/archive/master.zip. The downloaded archive unpack it to the directory the IDE "Arduino IDE/libraries".
Write here is a sketch and upload it to your Arduino. In the sketch we every 100 milliseconds read out from the sensor BH1750 readings of illumination in the suites and bring this data to the serial port.
The sketch works with the light sensor BH1750
3
Connect the light sensor BH1750 Arduino according to the diagram above. Connect your Arduino Board the Arduino Board to the computer. Start the development environment the Arduino IDE and open the serial port monitor by "Ctrl+Shift+M" or via the menu "Tools". To monitor the serial port will run luminance values from our sensor BH1750. Aim the sensor at the light source, then close it from the light and you will see how changing the statement.
Light sensor BH1750 and Arduino to work

Advice 2: I2C interface and Arduino

In this article we will look at what I2C interface (AI-Tu-si, and two TSE), what are its characteristics and how to work with it.
I2c interface
You will need
  • - Arduino;
  • digital potentiometer AD5171;
  • led;
  • - resistor 220 Ohm,
  • - 2 resistor 4.7 kOhm;
  • - connecting wires.
Instruction
1
Serial communication Protocol IIC (also called I2C - Inter-Integrated Circuits, minicasino connection) used to transfer data for two bidirectional communication lines, which are called the serial data SDA (Serial Data) and the bus clock SCL (Serial Clock). There are also two lines for food. Bus SDA and SCL are pulled to the power bus through the resistors.
The network has at least one master device (Master) which initialisere data transfer and generates the synchronization signals. The network also has a slave device (Slave) that transmit data upon request of the presenter. Each slave has a unique address, which is a leading and turns to him. The device address specified in the passport (datasheet). To the same I2C bus can connect up to 127 devices, including several leading. The bus devices can be connected in the process, i.e. it supports "hot plugging".
Connection diagram for I2C interface
2
The Arduino uses the I2C interface two ports. For example, the Arduino UNO and Arduino Nano analog port A4 corresponds to SDA, analog port A5 corresponds to SCL.
For other models:
Arduino Pro and Pro Mini to A4 (SDA), A5 (SCL)
The Arduino Mega is 20 (SDA), 21 (SCL)
Arduino Leonardo - 2 (SDA), 3 (SCL)
Arduino Due - 20 (SDA), 21 (SCL), SDA1, SCL1
Compliance findings tyres Arduino SDA and SCL
3
To facilitate data exchange with devices on the I2C bus for Arduino is written standard library "Wire". It has the following functions:
begin(address) - initialize the library and connect to the I2C bus; if the address is not specified, the attached device is considered a leading; use 7-bit addressing;
requestFrom() - used by the master to request a certain number of bytes from the slave;
beginTransmission(address) - start data transfer to the slave at a particular address;
endTransmission() - end of the slave transmission;
write() - write data from the slave in response to the request;
available() - returns the number of bytes of information available for the reception from a slave;
read() - read bytes transferred from the host or the slave from the master to the slave;
onReceive() - specifies a function that should be called when the slave receives a transmission from the master;
onRequest() - specifies a function that should be called when the host device receives the transmission from the slave.
4
Let's see how to work with the I2C bus with Arduino.
First assemble the circuit as shown. Will control the brightness of the led using digital 64-position potentiometer AD5171, which is connected to the I2C bus. The address to which we will refer to the potentiometer - 0x2c (44 decimal).
Control scheme for the led using a digital potentiometer and an Arduino
5
Now open the examples library "Wire" sketch:
File -> examples -> Wire -> digital_potentiometer. Upload it into the Arduino memory. Turn on.
You see, the brightness of the led cycles increases, and then abruptly turns off. In this case we control the potentiometer with the Arduino using the I2C bus.
Sketch control a digital potentiometer via I2C bus
Is the advice useful?
Search