pollos
December 5, 2023, 7:00am
1
I keep on getting this error
sketch_dec05a.ino:8:20: fatal error: BH1750.h: No such file or directory
compilation terminated.
I've gone to sketch > Import Library and BH1750 is listed.
Is there anything I can do to fix this?
This is the code:
[quote]
[color=#7E7E7E]/*[/color]
[color=#7E7E7E] keyestudio sun_follower[/color]
[color=#7E7E7E] lesson 8[/color]
[color=#7E7E7E] BH1750[/color]
[color=#7E7E7E] http://www.keyestudio.com[/color]
[color=#7E7E7E]*/[/color]
#include <[color=#CC6600]Wire[/color].h>
#include <[color=#CC6600]BH1750[/color].h>
[color=#CC6600]BH1750[/color] lightMeter;
[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
[color=#CC6600][b]Serial[/b][/color].[color=#CC6600]begin[/color](9600);
[color=#7E7E7E]// Initialize the I2C bus (BH1750 library doesn't do this automatically)[/color]
[color=#CC6600]Wire[/color].[color=#CC6600]begin[/color]();
[color=#7E7E7E]// On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);[/color]
[color=#7E7E7E]// For Wemos / Lolin D1 Mini Pro and the Ambient Light shield use Wire.begin(D2, D1);[/color]
lightMeter.[color=#CC6600]begin[/color]();
[color=#CC6600][b]Serial[/b][/color].[color=#CC6600]println[/color](F([color=#006699]"BH1750 Test begin"[/color]));
}
[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {
[color=#CC6600]float[/color] lux = lightMeter.[color=#CC6600]readLightLevel[/color]();
[color=#CC6600][b]Serial[/b][/color].[color=#CC6600]print[/color]([color=#006699]"Light: "[/color]);
[color=#CC6600][b]Serial[/b][/color].[color=#CC6600]print[/color](lux);
[color=#CC6600][b]Serial[/b][/color].[color=#CC6600]println[/color]([color=#006699]" lx"[/color]);
[color=#CC6600]delay[/color](1000);
}
[/quote]
Where exactly is BH1750.h located on your PC ?
pollos
December 5, 2023, 7:41am
3
It's located in Arduino libraries folder and another folder
please RE -edit your posting to present your code as a code-section
click on the pencil-icon below your posting and then re-edit your posting following this short tutorial
Hi newcomer,
This thread wants to show you how you can speed-up getting helpful answers with small effort.
If you manage at least to post this way. You have the sympathy of the experienced users.
If you are willing to invest another 20 minutes these 20 minutes extra-time will save you a minimum of 200 minutes to finish your project.
always
post your full sketch. As a
code-section
from the very first to the very last line
A code-section has a small height => keeps your posting "short" but…
best regards Stefan
None of those locations look correct.
The .h and associated library file should be in a folder in the libraries folder of your Sketchbook folder. By convention the name of the folder would be BH1750
How did you install the library
pollos
December 5, 2023, 8:16am
6
I do have a folder called BH1750 in my home/user/Arduino/libraries folder.
I downloaded it as a ZIP file from onedrive then on Arduino IDE I went to Sketch > Import Library > Add Library and then imported the ZIP file.
That folder does not seem to be in your screenshot
pollos
December 5, 2023, 8:41am
8
Sorry, that's because I looked up with the .h specifically
Here is a screen shot of just BH1750
Then why did the home/user/Arduino/libraries/BH1750 folder not appear in the search results ?
Please post a screenshot of the contents of the home/user/Arduino/libraries/BH1750 folder
pollos
December 5, 2023, 8:58am
10
I don't know why that could be.
These are the contents of the home/user/Arduino/libraries/BH1750 folder
What is in the src folder ?
pollos
December 5, 2023, 9:56am
12
A .cpp and .h of the Bh1750
We have to check where your arduino-IDE is looking for the file.
There might be still something wrong with the place where the library is stored.
To find out if this is the case
You are working with a MAC but I think the same steps can be used to maximise the compiler-log-info.
Hi newcomer,
the Arduino-Forum community can be of great help.
If the community is able to support you in a way that helps solving your problems depends on
detailed information that you should provide.
trying to be quick by posting a too short posting is just
slowing down
finding the solution. Because all that happends is that you are asked for the detailed information and have to provide it anyway. Only difference the answer and the solution comes later
The most important thing is to pos…
If you got the aborted compiling
post the compiler-log as a code-section as described in this tutorial.
system
Closed
June 2, 2024, 10:49am
14
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.