Light Meter Using I2C Level Converter, LCD, and TSL2561

I recently needed to measure how different materials affect light transmission for a gardening project.  I decided this was the perfect opportunity to try out the new logic level converter to run both a 5v LCD and a 3.3v light sensor on a single i2c bus.  I used the following parts in this project:

Optional (but definitely helps keep everything tidy):


First up is wiring power to the breadboard from the Arduino.  I decided to keep the left side for 3.3v and the right side for 5v.

  • Breadboard right ground bus – black wire – Arduino ground pin
  • Breadboard right positive bus (5v bus) – red wire – Arduino 5v pin
  • Breadboard left ground bus – black wire – Breadboard right ground bus
  • Breadboard left positive bus (3.3v bus) – yellow wire – Arduino 3.3v pin
Connecting the breadboard to the Arduino


The next step is adding the logic level converter to the breadboard. It straddles the center notch like a DIP (but takes one additional column). I placed it toward the top of the breadboard to leave plenty of space for the light sensor to be added later.

  • Level converter LV pin – yellow wire – Breadboard 3.3v bus
  • Level converter HV pin – red wire – Breadboard 5v bus
  • Level converter left GND pin – black wire – Breadboard left ground bus
  • Level converter right GND pin – black wire – Breadboard right ground bus
  • Level converter B1 pin – green wire – Arduino analog pin 5 (i2c clock line)
  • Level converter B2 pin – blue wire – Arduino analog pin 4 (i2c data line)
Adding the level converter to the breadboard


The light sensor can now be added to the breadboard.  I placed it on the left side of the breadboard with the pins in the rightmost column.

  • Light sensor GND pin – black wire – Breadboard left ground bus
  • Light sensor SCL pin – green wire – Level converter A1 pin
  • Light sensor SDA pin – blue wire – Level converter A2 pin
  • Light sensor VCC pin – yellow wire – Breadboard 3.3v bus
Adding the light sensor to the breadboard


Finally, the LCD is added to the circuit.

  • LCD DAT terminal – blue wire – Level converter B2 pin
  • LCD CLK terminal – green wire – Level converter B1 pin
  • LCD 5v terminal – red wire – Breadboard 5v bus
  • LCD GND terminal – black wire – Breadboard ground bus
Adding the LCD to the breadboard


With all components added, the block diagram of the circuit looks like this:

Light meter circuit diagram

Arduino Uno image courtesy of Fritzing

And the resulting display:

Light meter display


For my project, I’m gathering data at reasonably high light levels; so, I went with the following settings:


If you are measuring low light levels, you may want to adjust these two lines accordingly:


An additional area to highlight is how the sketch is printing the light level values:

  snprintf_P(output_buffer, 6, PSTR("%5d"), (full_spectrum - ir_spectrum));

snprintf_P is a variant of sprintf that adds a couple of nice features.  The ‘n’ indicates that you can specify a maximum number of bytes to write into the buffer; this helps protect against accidental buffer overruns.  The ‘_P’ indicates that the format string is read from program memory; this helps conserve RAM.  In the invocation above, I’m using the companion macro PSTR() to keep the format string parameter in program memory.

Full source is available on github.

How will you be using the logic level converter in your projects?

Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here:

Join Adafruit on Mastodon

Adafruit is on Mastodon, join in!

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 36,000+ makers on Adafruit’s Discord channels and be part of the community!

CircuitPython – The easiest way to program microcontrollers –

Maker Business — “Packaging” chips in the US

Wearables — Enclosures help fight body humidity in costumes

Electronics — Transformers: More than meets the eye!

Python for Microcontrollers — Python on Microcontrollers Newsletter: Silicon Labs introduces CircuitPython support, and more! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

Adafruit IoT Monthly — Guardian Robot, Weather-wise Umbrella Stand, and more!

Microsoft MakeCode — MakeCode Thank You!

EYE on NPI — Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — #NewProds 7/19/23 Feat. Adafruit Matrix Portal S3 CircuitPython Powered Internet Display!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at !

No Comments

No comments yet.

Sorry, the comment form is closed at this time.