[BH1750] ERROR: received NACK on transmit of address

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
chm9871
 
Posts: 7
Joined: Wed Jan 26, 2022 3:03 pm

[BH1750] ERROR: received NACK on transmit of address

Post by chm9871 »

Hi there,

I'm making a lot of the same data loggers. When I upload code to some of them (about 1/10) I get the following error :

[BH1750] ERROR: received NACK on transmit of address
[BH1750] ERROR: received NACK on transmit of address
[BH1750] Device is not configured!

As the wiring and code for each datalogger is identical, I have no idea what causes this error (obvs the BH1750) - any insight would be very much appreciated.

Thanks

CM

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by mikeysklar »

Can you show the connections on the boards that are having the error?

This thread indicates that the pins must be well soldered or you will see this error.

https://github.com/claws/BH1750/issues/36

User avatar
ajithk
 
Posts: 3
Joined: Sat Jul 09, 2022 10:28 am

Re: [BH1750] ERROR: received NACK on transmit of address

Post by ajithk »

IIRC, the BH1750 has 2 possible I2C addresses. Perhaps the ADDR pin has a bad solder and/or is seeing different voltages on the non-working units. One defensive option is to modify the code to try both addresses.

User avatar
chm9871
 
Posts: 7
Joined: Wed Jan 26, 2022 3:03 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by chm9871 »

The sensors are linked via STEMMA QT / Qwiic JST SH 4-pin Cable to a Qwiic Sheild, so I doubt its a bad solder, and other sensors are working fine with the same cable/shield set up.

Changing the address from 0x23 to 0x5c just yields a different flavor of error :

ERROR: Invalid mode
[BH1750] ERROR: undefined error
[BH1750] ERROR: received NACK on transmit of address

Any help would be grand

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by mikeysklar »

Thank you for confirming the connection is a known good STEMMA cable. Can you post a photo of your setup? I realize this is just 1 in 10 failure so before we move on to replacement I wanted to get an idea of what your setup looks like.

User avatar
chm9871
 
Posts: 7
Joined: Wed Jan 26, 2022 3:03 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by chm9871 »

Attached a photo >
IMG_7874.jpg
IMG_7874.jpg (832.02 KiB) Viewed 3981 times
For ref its an adalogger 32u4 https://www.adafruit.com/product/2795 soldered to a qt feather wing https://www.adafruit.com/product/4515 via GND, SCL and SDA, a wire coming off of the A3 pin to 3V3 to control power to the sensors :
BH1750 https://www.adafruit.com/product/4681
SHT40 https://www.adafruit.com/product/4885
PCF8523 https://www.adafruit.com/product/5189
JST PH https://www.adafruit.com/product/4026

w/ a 2500mAh lipo for power.

The code currently powers up, engages 12C, runs a set up for sensors, turns off 12C, powers down, then the loop: powers up, engages 12C, saves sensor data to SD card, turns off 12C and powers down, with a WatchDog loop for the duration of the 32u4 sleep cycle

So far the "failure" rate of the Bh1750s returning a NACK error is 1 in 7 ish

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by mikeysklar »

Thanks for the photo they always tell a story.

Can you solder the rest of the pins on the Sparkfun i2c breakout board?

The 3v3 red jumper wire looks pretty well connected, but maybe you can go over that with a soldering iron as I cannot tell if that is a "cold joint". Is the jumper necessary?

To further narrow the issue down it would be helpful to test a BH1750 sensor in isolation (no other devices on the i2c bus) after it has shown the NACK error to see if it continues or is related to the more complex setup.

User avatar
chm9871
 
Posts: 7
Joined: Wed Jan 26, 2022 3:03 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by chm9871 »

Sorry for the lateness of this reply.

I have soldered extra pins, and gone over 3v3 jumper solders (this wire is to make powering the entire 12c breakout on/off easier).

I largely solved the NACK issue by either daisy chaining the stemma through another sensor or changing the port side for the cable. So maybe faulty connections from the stemma port on the board.

Now my problem is about 85% of the sensors never record a light level when there's not an external power source (i.e. plugged in via USB). They seem to record lux levels fine during set-up and see through the terminal, but once they're deployed and running off a Lipo, just record 0s, whilst the LED lights up fine, showing they're receiving power.

Any suggestions? I'm just using the basic - lightMeter.readLightLevel(); in the code

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by mikeysklar »

Since the behavior is different using USB versus running off a LiPO I’m suspicious of a power issue. You had mentioned you were using a 2500 mAh LIPO which should easily provide all the current you need.

When you are running from USB what was the power source (computer USB port, or wall dumb wall plug)?

Do you have another LIPO you can swap out for the 2500 you are using?

How many sensors do you need to remove to get full readings from a LIPO?

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by adafruit2 »

you cannot power these sensors from A3, that pin can only provide 10mA or so.

User avatar
chm9871
 
Posts: 7
Joined: Wed Jan 26, 2022 3:03 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by chm9871 »

Is there an alternative pin that I should be using? A3 has been working fine for that so far - powers all sensors and enables data collection

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by adafruit2 »

a GPIO pin just cannot power 4 sensors, it does not have the current capability for so many sensors. maybe you could power one sensor per GPIO (maybe!) otherwise you are going to get flaky behavoir - you need to have a power circuit to enable/disable the power with at least 50-100mA of output capability

User avatar
chm9871
 
Posts: 7
Joined: Wed Jan 26, 2022 3:03 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by chm9871 »

Ah. Well, that might explain quite a lot. Thanks a bunch. But it's a tad troublesome as it potentially involves lots of additional wiring.

Is there another solution for powering the 3v3 pin on the Qwicc Shield? I.e. several GPIO pins to the single Qwicc Shield 3v3 pin? or ( I've never found anything on how to do this, but it's potentially obvious to everyone else..) control the 3v(3) pin on the adalogger to switch the output on/off high/low?

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by adafruit2 »

as you can tell there isnt a simple way of doing it, its a good idea for a product! some of our current boards have a 'switchable' I2C port, like the Feather ESP32 V2 but dont have a SD card so you'd have to wire that instead - bit of a tradeoff but maybe worth it

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: [BH1750] ERROR: received NACK on transmit of address

Post by mikeysklar »

Maybe this Pimoroni i2c breakout shield is worth stocking?

https://shop.pimoroni.com/products/i2c- ... 7772758099
2 different 3v3 power rails.

The first has 3v3 power always on.

The second has user controlled 3V3 power that is off by default, so when you put your ESP32 into deep sleep, the 3V3 power for the I2C devices on that i2C bus get shut down automatically.
Probably more ideal to have a Feather form factor wing with four more STEMMA plugs.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”