Fatal error: BH1750.h: No such file or directory

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 ?

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

best regards Stefan

image
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

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

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

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 ?

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.

If you got the aborted compiling
post the compiler-log as a code-section as described in this tutorial.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.