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 ...
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 ...
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?
  • 2,125
10 votes
1 answer
19k 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: ...
  • 1,085
9 votes
4 answers
48k 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 ...
  • 235
9 votes
3 answers
61k 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 ...
  • 397
8 votes
2 answers
22k 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 ...
  • 263
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 ...
  • 243
7 votes
3 answers
19k 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 ...
7 votes
5 answers
16k 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 ...
7 votes
2 answers
9k 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....
7 votes
3 answers
30k 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(...
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?
  • 175
7 votes
3 answers
8k 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) ...
  • 422
7 votes
3 answers
62k 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 ...
  • 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
12k 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(...
  • 113
6 votes
2 answers
2k 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 ...
  • 1,578
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 ...
6 votes
1 answer
480 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 (...
5 votes
6 answers
13k 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 ...
  • 193
5 votes
1 answer
27k 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 <...
  • 747
5 votes
2 answers
5k 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 ...
  • 125
5 votes
3 answers
8k 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 ...
  • 2,883
5 votes
2 answers
5k 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 ...
  • 2,883
5 votes
1 answer
10k 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 ...
5 votes
2 answers
319 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 ...
5 votes
2 answers
1k 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 ...
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 ...
  • 709
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 ...
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, ...
  • 61
5 votes
3 answers
7k 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:...
5 votes
1 answer
14k 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,...
  • 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 ...
  • 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 ...
  • 1,370
5 votes
0 answers
217 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 ...
  • 151
4 votes
3 answers
14k 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 ...
4 votes
3 answers
718 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 ...
  • 193
4 votes
2 answers
11k 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 ...
4 votes
2 answers
123 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 ...
4 votes
4 answers
14k 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 ...
  • 63
4 votes
3 answers
10k 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 ...
4 votes
1 answer
517 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()&...
4 votes
2 answers
10k views

I2C and SPI at the same time?

I would like to ask a question relating to the following communication setup: STM32 -- Arduino Pro Mini -- ADNS3080 sensor The interface between STM32 -- Arduino is I2C and the interface between ...
4 votes
1 answer
297 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 ...
  • 829
4 votes
2 answers
144 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 ...
  • 51
4 votes
1 answer
7k 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 ...
  • 328
4 votes
2 answers
3k views

Arduino I2C long string

I am trying to get 2-Arduinos passing data. The Master will request the data and the Slave send it. But, the length of the string the Slave will send is unknown each cycle. I found some things here ...
4 votes
0 answers
6k 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 ...
4 votes
1 answer
6k views

I²C between ATTiny85 (8MHz) and Arduino Uno

I keep receiving the following error in myATTiny85-Slave code below: sketch_mar12a.ino: In function 'void setup()': sketch_mar12a:19: error: 'class USI_TWI_S' has no member named 'onRequest' I have ...
  • 233

1
2 3 4 5
15