First, I’ve searched, if there’s another post that describes where, how to find the Wire.h library in the Particle Build Library search box point me in the right direction.
I’m trying to install a BH1750 light sensor so my first step would be to locate the HEX address for A5 to point the ADD too. The base BH1750 code requires Wire.h. I’ve tried to just type it in #include “Wire.h” but it doesn’t find it and errors out. I have the Wire.h library on my HD for Arduino IDE but PB isn’t able to find it.
Thanks for help on both.
Wire.h
does not need to be included for the Particle platform
OK, that makes it easier.
I’m getting errors on line 5 - BH1750 lightMeter; any guesses why? It says “does not name a type” .
// This #include statement was automatically added by the Particle IDE.
#include "BH1750Lib/BH1750Lib.h"
BH1750 lightMeter;
void setup(){
Serial.begin(9600);
lightMeter.begin();
Serial.println("Running...");
}
void loop() {
uint16_t lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
delay(1000);
}
You might want to paste the error code here instead so that we know exactly which line is causing the error.
i’m guessing that #include “BH1750Lib/BH1750Lib.h” might be the issue.
Are you compiling locally or using Particle Dev?
I’m sure this isn’t the correct format but this is what I’m getting.
Ok looks like you are using the Web IDE. Is the library included for your firmware?
Missed that. I’m doing it on Particle.io build site.
I added the library using Particle IDE's library search tool. I tried to add it again but the IDE came back and said the library was already in the file. Not sure what else you mean by
Sorry, still getting my footing with all this.
From the example, seems like you need to do
//initialize device
BH1750Lib lightmeter;
void setup() {
lightmeter.begin(BH1750LIB_MODE_CONTINUOUSHIGHRES);
}
Tried it with this response. Also it seems like the code was inconsistent with the capitalization of letters in lightMeter, so I tune those up…
Where did you get your code from? The example says .lightLevel();
and not .readLightLevel()
Honestly, i’ve been all over the net looking for the code to the BH1750 so I’m not sure where I actually copied it from. I wish I could tell you. I compiled it and it worked! I’ve got a few lines of bad numbers coming in ever 10 readings or so, I think I need to add a smaller resistors back in.
Thanks for all your help tonight !!!