{"id":52259,"date":"2026-11-01T10:50:47","date_gmt":"2026-11-01T10:50:47","guid":{"rendered":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/"},"modified":"2026-11-01T10:50:47","modified_gmt":"2026-11-01T10:50:47","slug":"i2c-explained","status":"publish","type":"siratek_tutorial","link":"https:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/","title":{"rendered":"I2C, Two Wires and Many Devices"},"content":{"rendered":"<body><p><\/p>\n<h2>What this covers<\/h2>\n<p>An Uno has fourteen digital pins. A character display can want six of them, and that is before you add a clock, a sensor and a display driver.<\/p>\n<p>I2C solves that. One pair of wires carries as many devices as you like, each answering to its own address. This explains how to wire it, how to find out what is on the bus, and the four things that go wrong.<\/p>\n<p>Most of the modules Siratek sells that do anything complicated use it: the LCD backpack, the OLED display, the real-time clock, the pressure sensor, the accelerometer.<\/p>\n<h2>Before you begin<\/h2>\n<p>Any I2C module and an Uno. The scanner sketch below works with whatever you have and is worth running before any device-specific tutorial.<\/p>\n<h2>How it works<\/h2>\n<p>Two wires, plus a shared ground.<\/p>\n<ul>\n<li><strong>SDA<\/strong>, the data line.<\/li>\n<li><strong>SCL<\/strong>, the clock line, which the Arduino drives to pace the conversation.<\/li>\n<\/ul>\n<p>The Arduino is the controller. It starts every exchange by putting an <strong>address<\/strong> on the bus. Every device hears it; the one whose address matches answers, and the rest stay quiet.<\/p>\n<p>Addresses are seven bits, so <code>0x00<\/code> to <code>0x7F<\/code>, and in practice <code>0x08<\/code> to <code>0x77<\/code>. The address is set by the manufacturer, sometimes with solder pads or jumpers to change a bit or two so you can run several identical devices together.<\/p>\n<h3>On an Uno<\/h3>\n<table>\n<thead>\n<tr>\n<th>Signal<\/th>\n<th>Uno pin<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>SDA<\/code><\/td>\n<td><code>A4<\/code><\/td>\n<td>Also available on the dedicated SDA pin near AREF<\/td>\n<\/tr>\n<tr>\n<td><code>SCL<\/code><\/td>\n<td><code>A5<\/code><\/td>\n<td>Also available on the dedicated SCL pin<\/td>\n<\/tr>\n<tr>\n<td><code>GND<\/code><\/td>\n<td><code>GND<\/code><\/td>\n<td>Required. Both ends need the same reference<\/td>\n<\/tr>\n<tr>\n<td><code>VCC<\/code><\/td>\n<td><code>5V<\/code> or <code>3.3V<\/code><\/td>\n<td>Whatever the module wants, not whatever is nearest<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><code>A4<\/code> and <code>A5<\/code> are the same physical pins as the ones beside AREF, not extra ones. Using I2C costs you those two analog inputs.<\/p>\n<h3>Devices share the wires<\/h3>\n<p>Every device connects to the same <code>SDA<\/code> and the same <code>SCL<\/code>. You do not need a pin per device, and you do not need a hub. Wire the second module to the same two lines as the first.<\/p>\n<figure class=\"siratek-tutorial-figure\"><img decoding=\"async\" src=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/i2c-explained-bus.svg\" alt=\"Two modules sharing one SDA line, one SCL line and a common ground, each with its own address\" loading=\"lazy\"><figcaption>A third module joins the same two wires and costs no extra pins.<\/figcaption><\/figure>\n<h2>Pull-up resistors<\/h2>\n<p>Both lines need pull-up resistors to work. Almost every breakout module Siratek sells has them fitted, so for one or two modules you do nothing.<\/p>\n<p>The catch arrives with several modules at once. Each one adds its own pull-ups in parallel, and the combined pull-up gets stronger until the bus stops working reliably. Four or five modules on one bus is where this starts to show, as intermittent failures that look like bad wiring.<\/p>\n<p>The fix is to remove or cut the pull-ups on all but one module. Most boards mark them.<\/p>\n<h2>Finding what is on the bus<\/h2>\n<p>This is the first thing to run with any new I2C device. It answers \u201cis it wired correctly and what address is it at\u201d in one step, before any library is involved.<\/p>\n<pre><code>\/\/ Siratek: list every device answering on the I2C bus.\n\n#include &lt;Wire.h&gt;\n\nvoid setup() {\n  Wire.begin();\n  Serial.begin(9600);\n  while (!Serial) {\n    ;   \/\/ Wait for the Serial Monitor on boards that need it.\n  }\n  Serial.println(\"Siratek: scanning the I2C bus.\");\n}\n\nvoid loop() {\n  int found = 0;\n\n  for (byte address = 8; address &lt; 120; address++) {\n    Wire.beginTransmission(address);\n\n    \/\/ 0 means the device acknowledged its address.\n    if (Wire.endTransmission() == 0) {\n      found++;\n      Serial.print(\"device at 0x\");\n      if (address &lt; 16) {\n        Serial.print(\"0\");\n      }\n      Serial.println(address, HEX);\n    }\n  }\n\n  if (found == 0) {\n    Serial.println(\"nothing found: check SDA, SCL, power and ground\");\n  } else {\n    Serial.print(\"devices found: \");\n    Serial.println(found);\n  }\n\n  Serial.println();\n  delay(5000);\n}<\/code><\/pre>\n<p><code>Wire<\/code> is part of the Arduino core, so there is nothing to install.<\/p>\n<h2>Expected result<\/h2>\n<p>With one module wired, you should see a single address, repeating every five seconds:<\/p>\n<pre><code>Siratek: scanning the I2C bus.\ndevice at 0x27\ndevices found: 1<\/code><\/pre>\n<p><code>0x27<\/code> and <code>0x3F<\/code> are the usual addresses for the LCD backpack, <code>0x3C<\/code> for a small OLED, <code>0x68<\/code> for a real-time clock or accelerometer. Yours may differ, which is exactly why you scan rather than assume.<\/p>\n<p>An address appearing here means the wiring and power are right. If a device-specific sketch then fails, the problem is the library or its configuration, not the bus. That is worth a great deal when something is not working.<\/p>\n<h2>The four things that go wrong<\/h2>\n<p><strong>Nothing found at all.<\/strong> Nearly always <code>SDA<\/code> and <code>SCL<\/code> swapped, or a missing ground. Check those two before anything else.<\/p>\n<p><strong>Wrong voltage.<\/strong> A 3.3 V device on an Uno\u2019s 5 V bus may work, may read unreliably, or may be damaged. Check what the module wants. Some have a regulator and level shifting and are happy on 5 V; some are not.<\/p>\n<p><strong>Two devices, one address.<\/strong> Identical modules often share a fixed address, and two on one bus will conflict. The scanner shows one device where you expected two. Look for address-select pads on the board.<\/p>\n<p><strong>Long wires.<\/strong> I2C was designed for signals travelling across a circuit board. Past about 50 cm, or near a motor, it becomes unreliable. Keep the runs short, keep them away from motor leads, and make sure the ground is solid.<\/p>\n<h2>Check yourself<\/h2>\n<ol>\n<li>You add a second I2C module. How many more Arduino pins does it use?<\/li>\n<li>The scanner finds nothing. What are the first two things to check?<\/li>\n<li>Two identical sensors on one bus. What will the scanner show?<\/li>\n<li>A device appears in the scanner but its library fails. Where is the fault?<\/li>\n<\/ol>\n<p>Answers in order: none, it shares the same two wires. <code>SDA<\/code> and <code>SCL<\/code> swapped, and the ground connection. One address, because they conflict. In the library or its configuration, since the bus and wiring are proven.<\/p>\n<h2>Troubleshooting<\/h2>\n<table>\n<thead>\n<tr>\n<th>Symptom<\/th>\n<th>Likely cause<\/th>\n<th>Check or fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Nothing found<\/td>\n<td><code>SDA<\/code> and <code>SCL<\/code> swapped<\/td>\n<td><code>SDA<\/code> to <code>A4<\/code>, <code>SCL<\/code> to <code>A5<\/code><\/td>\n<\/tr>\n<tr>\n<td>Nothing found, wiring confirmed<\/td>\n<td>Missing ground, or module unpowered<\/td>\n<td>Join the grounds, check <code>VCC<\/code><\/td>\n<\/tr>\n<tr>\n<td>Address differs from the tutorial<\/td>\n<td>Different board revision<\/td>\n<td>Use the address the scanner reports<\/td>\n<\/tr>\n<tr>\n<td>Found, then intermittent<\/td>\n<td>Too many pull-ups, or long wires<\/td>\n<td>Remove pull-ups on extra modules, shorten the run<\/td>\n<\/tr>\n<tr>\n<td>One device where two are wired<\/td>\n<td>Address conflict<\/td>\n<td>Change one with its address pads<\/td>\n<\/tr>\n<tr>\n<td>Works alone, fails with a motor running<\/td>\n<td>Electrical noise<\/td>\n<td>Route away from motor leads, improve the ground<\/td>\n<\/tr>\n<tr>\n<td>Analog reads stopped working<\/td>\n<td>I2C uses <code>A4<\/code> and <code>A5<\/code><\/td>\n<td>Move the analog input to <code>A0<\/code> to <code>A3<\/code><\/td>\n<\/tr>\n<tr>\n<td>Scanner hangs<\/td>\n<td><code>SDA<\/code> shorted to ground<\/td>\n<td>Unplug and check for a wiring short<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Next steps<\/h2>\n<ul>\n<li><strong>Easier first:<\/strong> <em>Seeing What Your Program Is Doing<\/em>, since the scanner reports through it.<\/li>\n<li><strong>Next:<\/strong> the 16\u00d72 LCD over I2C, which is the usual first I2C device.<\/li>\n<li><strong>Related products:<\/strong> the 0.96 inch OLED display, the DS3231 real-time clock and the BMP280 pressure sensor all share this bus.<\/li>\n<\/ul>\n<h2>Sources and attribution<\/h2>\n<p>All text and code in this tutorial are original Siratek work.<\/p>\n<ul>\n<li>Arduino <code>Wire<\/code> library documentation for the function names and return values.<\/li>\n<li>I2C addressing and the role of the pull-up resistors are described from the published bus specification.<\/li>\n<\/ul>\n<p>Device addresses are given as the common ones for these module types and vary between revisions, which is why the tutorial directs you to scan rather than assume. No third-party tutorial text, diagrams, photographs or code has been reproduced here.<\/p>\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>An Uno has fourteen digital pins. A character display can want six of them, and that is before you add a clock, a sensor and a display driver.<\/p>\n","protected":false},"featured_media":0,"template":"","siratek_tutorial_level":[],"class_list":["post-52259","siratek_tutorial","type-siratek_tutorial","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>I2C, Two Wires and Many Devices - siratek<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"I2C, Two Wires and Many Devices - siratek\" \/>\n<meta property=\"og:description\" content=\"An Uno has fourteen digital pins. A character display can want six of them, and that is before you add a clock, a sensor and a display driver.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/\" \/>\n<meta property=\"og:site_name\" content=\"siratek\" \/>\n<meta property=\"og:image\" content=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/i2c-explained-bus.svg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/i2c-explained\\\/\",\"url\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/i2c-explained\\\/\",\"name\":\"I2C, Two Wires and Many Devices - siratek\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/i2c-explained\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/i2c-explained\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/i2c-explained-bus.svg\",\"datePublished\":\"2026-11-01T10:50:47+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/i2c-explained\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/i2c-explained\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/i2c-explained\\\/#primaryimage\",\"url\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/i2c-explained-bus.svg\",\"contentUrl\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/i2c-explained-bus.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/i2c-explained\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/siratek.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials\",\"item\":\"https:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"I2C, Two Wires and Many Devices\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\",\"url\":\"https:\\\/\\\/siratek.net\\\/\",\"name\":\"siratek\",\"description\":\"Your Best Electronic Retail Shop\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/siratek.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"I2C, Two Wires and Many Devices - siratek","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/","og_locale":"en_US","og_type":"article","og_title":"I2C, Two Wires and Many Devices - siratek","og_description":"An Uno has fourteen digital pins. A character display can want six of them, and that is before you add a clock, a sensor and a display driver.","og_url":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/","og_site_name":"siratek","og_image":[{"url":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/i2c-explained-bus.svg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/","url":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/","name":"I2C, Two Wires and Many Devices - siratek","isPartOf":{"@id":"https:\/\/siratek.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/#primaryimage"},"image":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/#primaryimage"},"thumbnailUrl":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/i2c-explained-bus.svg","datePublished":"2026-11-01T10:50:47+00:00","breadcrumb":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/#primaryimage","url":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/i2c-explained-bus.svg","contentUrl":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/i2c-explained-bus.svg"},{"@type":"BreadcrumbList","@id":"http:\/\/siratek.net\/index.php\/tutorials\/i2c-explained\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/siratek.net\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"https:\/\/siratek.net\/index.php\/tutorials\/"},{"@type":"ListItem","position":3,"name":"I2C, Two Wires and Many Devices"}]},{"@type":"WebSite","@id":"https:\/\/siratek.net\/#website","url":"https:\/\/siratek.net\/","name":"siratek","description":"Your Best Electronic Retail Shop","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/siratek.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial"}],"about":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/types\/siratek_tutorial"}],"version-history":[{"count":0,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52259\/revisions"}],"wp:attachment":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/media?parent=52259"}],"wp:term":[{"taxonomy":"siratek_tutorial_level","embeddable":true,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial_level?post=52259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}