Skip to main content

Questions tagged [i2c]

Inter-Integrated Circuit (I²C) is a bus for low speed peripherals. Use this tag for questions regarding how to use I²C with an Arduino, or for problems with I²C and your Arduino.

Filter by
Sorted by
Tagged with
12 votes
3 answers
29k views

How do I use I2C devices with Arduino?

I have a few useful I2C components, such as a 16-bit port expander (MCP23017), which I'd like to use in various projects. What do I need to do to make these work with Arduino? Will it work with any ...
Peter Bloomfield's user avatar
11 votes
2 answers
2k views

Cheap Wired Multipoint Mesh Network

I'm looking to make a 15 x 15 grid of load sensors and RGB LEDs for an interactive dance floor. Each node will be driven by an arduino and the entire floor will be managed by a RaspberryPi. I'm trying ...
Jeremy Gillick's user avatar
10 votes
1 answer
3k views

How to design and debug a custom I2C master-slave system?

How to proceed, when in need of a custom I2C master-slave system? What are the design criteria to apply? What are the debugging tools one can use to troubleshoot problems?
Igor Stoppa's user avatar
  • 2,125
10 votes
1 answer
22k views

What does it mean in I2C, "NACK received"?

I am reading about I2C. On this site: http://playground.arduino.cc/Main/WireLibraryDetailedReference#endTransmission It says that endTransmission() can return one of the following status codes: 0: ...
Mads Skjern's user avatar
  • 1,125
9 votes
4 answers
49k views

How do functions outside of void loop work?

I am used to Arduino sketches with a void setup() part that runs once, and a void loop() part that keeps looping. What happens when you have void functions outside of the main void loop()? Will these ...
Blue7's user avatar
  • 245
9 votes
3 answers
62k views

I2C LCD Serial Interface Board not displaying text (wrong pins?)

I have a 1602 LCD screen that works fine on its own. However I wanted to free some pins by using an I2C / IIC LCD controller I purchased separately. While the controller seems to be communicating ...
Bort's user avatar
  • 397
8 votes
2 answers
27k views

How to choose alternate I2C pins on ESP32?

I'm a begginer with Arduino and this may be a basic question but I'm facing an issue. I'm using a HTU21D sensor with an ESP32. This sensor use I2C communication. Inside the Arduino library, there is ...
Gazouu's user avatar
  • 273
8 votes
2 answers
2k views

Burning sketch with I2C

Not a pure Arduino question really. I'm actually using a standalone ATmega168. So far I've been using AVR-ISP programmer (working from AVR Studio) to program the chip. After everything is done, the ...
tsf144's user avatar
  • 243
7 votes
3 answers
20k views

Multiple I2C sensors with the same address

I am trying to find the simplest way to connect multiple (preferably around 10-20) IMU sensors to one controller. There are two constraints: sampling at 60Hz and reasonably simple wiring as I want to ...
Łukasz Kidziński's user avatar
7 votes
5 answers
17k views

Alternatives to Wire library for I2C

I am looking for (reasonably easy to use and well tested) alternatives to the Wire library. Wire works very well, but: I only need the Arduino to act as I2C master and the Wire library seems to be a ...
fuenfundachtzig's user avatar
7 votes
2 answers
10k views

Difference between Wire.setClock() method and TWBR method for changing I2C Frequency

I want to change the I2C frequency of my Arduino Mega 2560. I did find two methods. One method is to change the TWBR variable after Wire.begin(). The other one is to use Wire.setClock() after Wire....
William Roy's user avatar
7 votes
3 answers
31k views

I2C 2 way communication between Arduino Uno and Arduino Mega

If I remove the transmission code from slave this works properly but I need to transmit from slave. Here is my master code #include <Wire.h> void setup() { Wire.begin(3); Wire.onReceive(...
srinivas's user avatar
7 votes
2 answers
2k views

Is there a pullup on I2C?

I am using an Arduino Uno R3. It is not clear on the schematic whether there are pullups on the A4 and A5 I2C pins. Are there hardwired pullups or do I have to add them myself?
harry_p_6's user avatar
  • 175
7 votes
3 answers
9k views

ATTiny85 I2C LCD

My setup is as follows: Arduino IDE 1.6.11 Arduino Pro Mini as ISP ATTiny85 1602A LCD with I2C board The libraries I use are: TinyWireM (source: https://github.com/adafruit/TinyWireM) ...
Thijs's user avatar
  • 432
7 votes
3 answers
67k views

Sending and receiving different types of data via I2C in Arduino

I have found a few good tutorials on how to send and receive data via I2C in connected arduinos. My limitation is now how to transmit different types of data like for instance, long, float, etc. Right ...
Camilo's user avatar
  • 359
7 votes
3 answers
10k views

Sainsmart LCD 2004 - LiquidCrytal_I2C library issue unable to compile

I bought a Sainsmart LCD2004 from Amazon to use with my Arduino Uno. I understand that since this LCD uses I2C a new library needs to be downloaded. From the sainsmart website I dowloaded the LCD ...
user avatar
6 votes
2 answers
13k views

What does this notation stands for? Wire.read() <<8 | Wire.read()

I'm using the Arduino's site test code for getting raw values from a MPU-6050 accelerometer + gyro. In the loop, there are this lines for getting the next data from its registers: Wire.requestFrom(...
Julio's user avatar
  • 113
6 votes
2 answers
3k views

Sending uint16_t over I2C

How do you transmit and read a uint16_t over I2C? I'm trying to read two uint16_t values from a slave device, and I'm seeing nonsensical readings. This is the code on my slave Arduino Uno: #include ...
Cerin's user avatar
  • 1,648
6 votes
3 answers
1k views

Crash when datalogging MPU-6050 to SD card

On an Arduino Pro Mini, I'm using Jeff Rowberg's stuff in i2cdevlib to read from the MPU6050, and using SdFat to write data to an SD card. Each part in isolation is fine, but when both DAQ and logging ...
Craig Graham's user avatar
6 votes
1 answer
509 views

Arduino as a custom I2C slave device

I'm trying to interface with a master I2C device that doesn't exactly follow the normal I2C protocol. The only difference really is in the read request. A "normal" I2C read operation looks like this (...
user2827019's user avatar
6 votes
0 answers
306 views

Handling non-standard I2C read response lengths with Wire library

I'm trying to read from a Sam&Wing XW12A 12 channel touch sensor IC using I²C. The IC responds to an address read packet with 16 uninterrupted bits representing its state. However, since I²C ...
Jim's user avatar
  • 161
5 votes
6 answers
15k views

LCD 16*02 I2C shield only shows first character printed

I have an I2C LCD screen provided with a Sunfounder kit and certainly built by DFRobot or such a constructor (there is nothing written on the LCD), and an Arduino Uno R3 copy. My issue is when I use ...
AFract's user avatar
  • 193
5 votes
1 answer
29k views

How do I send a string to master using i2c

I want to write an Arduino program that simply recieves a string (via the I2C wire library) from a master Arduino, then waits for a request, and sends that string back. Here is my code: #include <...
Hoytman's user avatar
  • 747
5 votes
2 answers
6k views

Wire.h library works on Uno but won't compile for ATtiny85

TL;DR: Arduinos are current hungry so I want to switch my microcontroller code works on Uno, I change upload to ATtiny85, code doesn't compile Wire.h breaks at the TWBR input Should I keep trying to ...
auphynne's user avatar
  • 125
5 votes
3 answers
9k views

Soldering Arduino Pro Mini's disaligned pins

I have a couples of Arduino Pro Minis (original from sparkfun) that have those 4 disaligned pin. Unfortunetely, I need to use 2 of them, A4 and A5, because they are the I2C pins and I want to solder ...
Dat Ha's user avatar
  • 2,913
5 votes
2 answers
6k views

Which library to choose? <Wire.h> or "Wire.h"?

I know that in C++, to include a library, you either put the library name in <x> or "x". Now, I believe that this was because of a major change in the C++ language a some time ago. Now, in ...
Dat Ha's user avatar
  • 2,913
5 votes
1 answer
11k views

Wire.endTransmission() Hangs

I have written a code that transmits data over the I2C channel, The device ID and every other stuff is working fine. The only issue being that my code gets stuck at Wire.endTrasnmission(). I found ...
ArunMKumar's user avatar
5 votes
2 answers
356 views

Ideas for setting I2C device IDs

I am using I2C to communicate between a collection of ATtiny85s that are acting as controllers for various parts of a system and the "Main Brain" -- a RaspberryPi. Most of the ATtiny85s only have a ...
ThatAintWorking's user avatar
5 votes
2 answers
2k views

RTC MCP7940M not counting up

I'm able to set a time and to read it back without any problems but it doesn’t tick up. It stays the same. Even if I restart the serial monitor and thereby resets the buffer(?). So it seems to me that ...
Victor Vikström's user avatar
5 votes
1 answer
1k views

Arduino Uno freezes for unknown reason during code execution

I am struggeling with a behaviour of my Arduino I do not fully understand. Long story short: When starting the communication over I2C the Arduino freezes. In my opinion during the "Wire.write()&...
IceCreamToast's user avatar
5 votes
2 answers
3k views

Protocol options for data exchange between Arduino and ESP8266

I have a device built with an Arduino uno: Arduino software installed on an Arduino uno can be controlled via serial commands can be controlled via physical buttons and sensors on any button/sensor ...
vlad b.'s user avatar
  • 719
5 votes
4 answers
5k views

How to setup an I2C bus which stays valid if a slave is powered down or fails?

I have setup an I2C bus between 3 Arduinos (Master, Slave1 and Slave2) by connecting all 3 A4 pins together, all 3 A5 pins together and one GND pin of each Arduino to a common ground line. The 3 ...
Jolas Marginópolis's user avatar
5 votes
3 answers
4k views

Arduino Due and BNO055 address in i2c mode

I have a project where I need to have several IMUs, the BNO055 shuttle board (I explained my project here), I manage to get the Euler angles from one BNO055 sensor, which have the address 0x29, ...
BunkSB's user avatar
  • 61
5 votes
3 answers
8k views

How do I use two I2C LCDs with 4 pins?

I have two I2C LCD screens: one with 2 lines one with 4 lines. Both have 4 pins each: GND, VCC, SDA, SDL. I connect SDA and SDL to A4 and A5 respectively, and I display text on each one of them with:...
Konstantinos's user avatar
5 votes
2 answers
566 views

Arduino Freezes (probably because of I2C) - Need help to write robust script

Arduino Pro mini 3.3V stucks few hours after startup. After repowered, it begins to stuck within a few seconds. If I wait long enough before turning it on it stucks little later for example now it ...
CaveScientist's user avatar
5 votes
1 answer
15k views

How to connect new OV7670 FIFO to Arduino?

I bought a new OV7670 FIFO camera to connect to my Arduino UNO a few days ago. The picture of the cam board: I found this forum, it is nice try but it looks chaotic and confusing with about 50 pages,...
zokit's user avatar
  • 53
5 votes
1 answer
1k views

I2C RTC returning bad times - sometimes

I have a TinyRTC I2C clock in one of my Arduino projects, and it works most of the time. But occasionally, it will report the time as 165 hours, 85 minutes and 25 seconds (165:85:25) for a couple of ...
David's user avatar
  • 51
5 votes
2 answers
15k views

I²C with ATTiny85 at 8MHz using TinyWireM library

Hello fellow Arduino enthusiasts, I am trying to make the ATTiny85 talk I²C with a MMA7660 breakout board I have (it's an accelerometer, this is a follow up question to my previous one). I would ...
Omer's user avatar
  • 1,380
5 votes
0 answers
7k views

Why is Wire.onReceive() called during requests?

I'm building a complex I2C-based networking protocol and have noticed that the Wire.onReceive() handler is called both for I2C read and write operations. When the master writes to the slave, it is ...
Jeremy Gilbert's user avatar
4 votes
3 answers
16k views

I2C LCD displaying weird characters

I have connected an LCD with an I2C backpack to my Arduino Uno but it prints the wrong characters. The weird thing is that it worked fine for a while and when I updated the code (but didn't change ...
Wouter van Dijke's user avatar
4 votes
3 answers
894 views

Is there any limitation with Arduino Nano serial communication distance?

I am trying to build Project which communicate multiple Arduino Nanos. I wanted to understand if Arudino Nano is capable of doing that, while doing research I came across post where it says ...
Akshay's user avatar
  • 193
4 votes
2 answers
14k views

Confused between SPI and I2C for SSD1306 OLED

I recently got myself an SSD1306 OLED display: I haven't been able to successfully wire it to an Arduino (Mega 2560) however. I have been reading up on I2C and SPI and checked some libraries from ...
Bart Van Loon's user avatar
4 votes
2 answers
386 views

I2C sensors not working when I connect to LCD 20X04

I am making a hydroponic nutrient monitoring system using Arduino Uno, Atlas Scientific EC sensor, pH sensor, and RTD (temperature) sensor in I2C mode. I also want to use LCD 20x04 to display the ...
Angela Radityatama's user avatar
4 votes
4 answers
15k views

I2C connection freezes Master if Slave disconnects

I am using I2C to successfully request critical data from a Slave device (I have to use requestFrom() in the Master) but if, for some reason, the power disconnects from the Slave device then the ...
Daryl's user avatar
  • 63
4 votes
2 answers
579 views

How to change the I2C address of the AS5048B?

I saw this video from James Bruton. See the links to the GitHub repos in the video description. I bought a few AS5048B boards from AMS, so I can measure the position of my stepper motors. In the ...
John Doe's user avatar
  • 151
4 votes
3 answers
11k views

Can't detect I2C displays with Arduino Nano

All cables tested and work: SCL - A5 SDA - A4 VCC - 5V GND - GND I'm using an Arduino Nano board and an I2C display - I've tried everything to get it to work and I'm now convinced it's a hardware ...
Baddog22's user avatar
4 votes
1 answer
118 views

How do you take the simplest continuous reading from a Garmin Lidar Lite V4 using I2C on a Particle Boron v4.1.0?

Hey there Stack community. I'm working with the Particle Boron v4.1.0. I'm connecting a Garmin Lidar Lite V4 on I2C. I'm using the LIDARLite_v4LED.h header file found in the library given for this ...
Katie Neeley's user avatar
4 votes
1 answer
432 views

Problems with green TWI (I2C) port on Arduino Braccio Shield

Summary: The green TWI/I2C port on my Braccio shield I2C port hasn't worked for me so far. Looking for advice or information please. Detail: I'm using the Arduino (Tinkerkit) Braccio robot arm for ...
RowanP's user avatar
  • 869
4 votes
2 answers
153 views

Need little bit of help on testing I2C sketch

I have this code I got from YouTube for communicating between two Arduinos. By typing 'R' manually into the serial monitor of the 'master' Arduino, the 'slave' will print "Success". I'm trying all ...
Josh's user avatar
  • 51
4 votes
1 answer
8k views

I2C to UART bridge as breakout or in DIP package

For a project, I need to connect more than one device to an Arduino through a serial port with hardware flow control (RTS/CTS). Sparkfun used to make breakout boards for the SC16IS750, but this ...
jarnbjo's user avatar
  • 328

1
2 3 4 5
16