Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master branch wash up #72

Closed
wants to merge 17 commits into from
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: cpp
env:
global:
- ARDUINO_PACKAGE_VERSION=1.8.5
- DISPLAY=:1.0

before_install:
# arduino requires an X server even with command line
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_$TRAVIS_JOB_NUMBER.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16

install:
- wget -q -O- http://downloads.arduino.cc/arduino-$ARDUINO_PACKAGE_VERSION-linux64.tar.xz | tar -Jxf -
- sudo mv arduino-$ARDUINO_PACKAGE_VERSION /usr/local/share/arduino
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
# Add esp8266 board support
# - arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs
# - arduino --install-boards esp8266:esp8266
- arduino --pref "compiler.warning_level=all" --save-prefs
# link project directory into Arduino libraries area.
- ln -s $PWD /usr/local/share/arduino/libraries/BH1750

script:
# uno
- arduino --verify --board arduino:avr:uno $PWD/examples/BH1750test/BH1750test.ino
- arduino --verify --board arduino:avr:uno $PWD/examples/BH1750advanced/BH1750advanced.ino
- arduino --verify --board arduino:avr:uno $PWD/examples/BH1750onetime/BH1750onetime.ino
- arduino --verify --board arduino:avr:uno $PWD/examples/BH1750autoadjust/BH1750autoadjust.ino
- arduino --verify --board arduino:avr:uno $PWD/examples/BH1750differentI2Caddress/BH1750differentI2Caddress.ino
# esp8266
# - arduino --verify --board esp8266:esp8266:generic $PWD/examples/BH1570test/BH1750test.ino
# - arduino --verify --board esp8266:esp8266:generic $PWD/examples/BH1570advanced/BH1750advanced.ino
# - arduino --verify --board esp8266:esp8266:generic $PWD/examples/BH1750onetime/BH1750onetime.ino
# - arduino --verify --board esp8266:esp8266:generic $PWD/examples/BH1750autoadjust/BH1750autoadjust.ino
11 changes: 1 addition & 10 deletions examples/BH1750advanced/BH1750advanced.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@ will be 0x23 (by default).
#include <BH1750.h>
#include <Wire.h>

/*
BH1750 can be physically configured to use two I2C addresses:
- 0x23 (most common) (if ADD pin had < 0.7VCC voltage)
- 0x5C (if ADD pin had > 0.7VCC voltage)

Library uses 0x23 address as default, but you can define any other address.
If you had troubles with default value - try to change it to 0x5C.

*/
BH1750 lightMeter(0x23);
BH1750 lightMeter;

void setup() {

Expand Down
59 changes: 59 additions & 0 deletions examples/BH1750differentI2Caddress/BH1750differentI2Caddress.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*

Different I2C address BH1750 library usage example

This example has some comments about advanced usage features.

Connection:

VCC -> 3V3 or 5V
GND -> GND
SCL -> SCL (A5 on Arduino Uno, Leonardo, etc or 21 on Mega and Due, on
esp8266 free selectable) SDA -> SDA (A4 on Arduino Uno, Leonardo, etc or 20 on
Mega and Due, on esp8266 free selectable) ADD -> VCC

ADD pin is used to set sensor I2C address. If it has voltage greater or equal
to 0.7VCC voltage (e.g. you've connected it to VCC) the sensor address will be
0x5C. In other case (if ADD voltage less than 0.7 * VCC) the sensor address
will be 0x23 (by default).

*/

#include <BH1750.h>
#include <Wire.h>

/*
BH1750 can be physically configured to use two I2C addresses:
- 0x23 (most common) (if ADD pin had < 0.7VCC voltage)
- 0x5C (if ADD pin had > 0.7VCC voltage)

Library uses 0x23 address as default, but you can define any other address.
If you had troubles with default value - try to change it to 0x5C.

*/
BH1750 lightMeter;

void setup() {

Serial.begin(9600);

// Initialize the I2C bus (BH1750 library doesn't do this automatically)
Wire.begin();
// On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);

// begin returns a boolean that can be used to detect setup problems.
if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x5c)) {
Serial.println(F("BH1750 different I2C address begin"));
} else {
Serial.println(F("Error initialising BH1750"));
}
}

void loop() {

float lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
delay(1000);
}