Seeeduino XIAO and I2C Oled Display based Light meter, Seeeduino XIAO I2C

(Last Updated On: October 23, 2020)

Seeeduino Xiao and I2C

Seeeduino XIAO and I2C Oled Display, Description:

Seeeduino XIAO and I2C Oled Display based Light meter– Seeeduino XIAO due to its very small size is becoming very popular. Using the smallest Arduino Seeeduino XIAO amazing wearable projects can be designed. In this tutorial, you will learn how to make a light meter using Seeeduino XIAO, 128×64 I2C supported Oled display Module, and LDR “Light Dependent Resistor”.

About the Sponsor, ALLPCB:

ALLPCB LOGO

 

 

 

24-Hours Lead Time

ALLPCB is the World’s Fastest PCB Manufacturing Company. Feel free to visit their website Allpcb.com to not only find out what awesome PCB and assembly services they offer but also to easily upload your Gerber files and thus order affordable and High-quality PCBs quickly. Besides this, you will also get a 30 Dollars Coupon balance, which you can use to get your first prototype order for free.

The main purpose of this tutorial is to explain how to use Seeeduino XIAO with I2C supported devices. Just like the Arduino boards Seeeduino XIAO also has the I2C pins. Once you learn the very basics of how to use the I2C communication using Seeeduino XIAO, then you can design your own cool projects using multiple I2C supported devices. You can make a patient monitoring system, a digital clock, a range finder, and thousands of other projects.

In my previous tutorial, I have already covered the extreme basics including the

Seeeduino XIAO Pinout and Technical specification.

Seeeduino XIAO board installation using the Arduino IDE.

And I also explained how to write your very first program to control an LED.

So, I highly recommend reading my previous getting started tutorial on the Seeeduino XIAO, because in this tutorial I will not explain the things which I have already covered in my previous tutorial.

In this tutorial, we will cover

  1. LDR and the Oled Display interfacing with Seeeduino
  2. Light meter program explanation, and finally
  3. Testing

Without any further delay, let’s get started!!!


Amazon Purchase Links:

Seeeduino XIAO from Amazon:

Seeeduino XIAO from Seeedstudio:

I2C 128×64 Oled Display Module:

Other Tools and Components:

Super Starter kit for Beginners

Two Channel / 200 MHz Digital Oscilloscope

Variable Supply:

Digital Multimeter:

Soldering iron kit: “best”

PCB small portable drill machine:

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Seeeduino XIAO I2C:

Seeeduino Xiao and I2C

Just like the Arduino boards, Seeeduino XIAO also has the I2C pins. A4 is the SDA and A5 is the SCL. Using these two pins of the Seeeduino XIAO multiple I2C supported devices can be connected without any problem. Every I2C supported device has a unique I2C address which is usually printed on the device. If the I2C address printed on the device doesn’t work for you, then you can use the following I2C scanner code to find the I2C address of the connected device.

Download the wire.h library.



I2C Scanner Code:

While the I2C supported Oled display module is connected with the Seeeduino XIAO, simply upload the above code. Open the Serial monitor and then you will be able to see the I2C address of the Oled display module.

I2C Oled display and LDR interfacing with Seeeduino XIAO:

Seeeduino Xiao and I2C

A light dependent resistor “LDR” and a 10K ohm resistor are connected in series; this makes the voltage divider circuit. A wire from the middle is connected with the Analog pin A0 of the Seeeduino XIAO.

The I2C supported 128×64 Oled Display Module SCL and SDA pins are connected with the Seeeduino analog pins A5 and A4. A5 is the SCL and A4 is the SDA. The Oled display module VCC and GND pins are connected with the Seeeduino 3.3V and GND pins.


Connections on the Breadboard:

Seeeduino Xiao and I2C

I completed the connections as per the circuit diagram; now let’s take a look at the program.

Before, you start the programming; first you will need to install the Seeeduino XIAO board.

Seeeduino XIAO Light Meter Programming:


Seeeduino XIAO based Light Meter Code Explanation:

As usual, before you start the programming, first of all, make sure you download all the necessary libraries.

You will need the Wire.h library for the I2C supported devices. The Adafruit_GFX and Adafruit_SSD1306 libraries are used with the Oled display module. The Oled display module I am using has the screen width 128 and screen height 64.

An LDR is connected with the Analog pin A0 of the Seeeduino XIAO. The LDR values are stored in the variable LDR_DATA, which is of the type integer. While the F_value variable is used to stored the final mapped value.

0x3c is the I2C address of the Oled display module. You can find this address by using the I2C scanner code, which you can find in the article.

The value returned by the readSensor() function is stored in the variable F_value and is then printed on the Oled display. If you have never used the Oled display module then you can watch my video on the Oled display module in which I covered all of these functions, and also fixed the most common issues that you might face while using the Oled display module. Anyhow, the readSensor() function is a user-defined function and its return type is integer. The purpose of this function is to read the analog pin A0 to which an LDR is connected. The LDR value is then mapped to limit the values between 0 and 100. Finally, we return this value.

Final Testing:

Seeeduino Xiao and I2C

After uploading the program, I powered up the Seeeduino XIAO using a Power bank. You can also use your laptop for the testing. Anyhow, by changing the light intensity falling on the LDR, I was able to see a change in the value.



Watch Video Tutorial:

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply