Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

11
votes
3answers
28k 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 ...
10
votes
2answers
1k 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 ...
9
votes
1answer
2k 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?
8
votes
4answers
39k 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 ...
8
votes
7answers
46k 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 ...
8
votes
2answers
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 ...
7
votes
3answers
9k 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 ...
6
votes
1answer
8k 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: ...
6
votes
3answers
26k 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(...
6
votes
2answers
821 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?
6
votes
1answer
343 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 (...
6
votes
2answers
12k 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 ...
5
votes
5answers
9k 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 ...
5
votes
2answers
4k 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 ...
5
votes
2answers
271 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
2answers
933 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
4answers
3k 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
1answer
12k 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,...
5
votes
1answer
656 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 ...
4
votes
3answers
7k 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
2answers
4k 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(...
4
votes
3answers
5k 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 ...
4
votes
5answers
9k views

Weird problem with LCD 16*02 I2C shield

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 ...
4
votes
2answers
608 views

Two-wire communication (I2C) between Arduino Micros

I am attempting to communicate data via I2C between two Arduino Micros, but can't seem to get the "slave" device to detect a Wire.onRecieve() event. Per the specification on this site [http://www....
4
votes
3answers
3k 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, ...
4
votes
3answers
4k 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:...
4
votes
2answers
552 views

Does an I²C IO Expander needs additional resistors for outputs?

I have following setup (see also schematic in the end) Arduino Nano is connected via I²C to the PCF8575C (link) IO Expander. Both, SCL and SDA have 10kOhm pull-ups to 5V. The Expander pins are ...
4
votes
3answers
5k 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 ...
4
votes
2answers
1k 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 ...
4
votes
2answers
43k 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 ...
4
votes
1answer
457 views

Three or more Arduino slaves sending bytes to 2 different I2C devices

I'm trying to connect 3 Arduinos with this scheme: Arduino1 Master, Arduino2 Slave, Arduino3 Slave. The slave devices need to communicate with each other and I'm trying to programming Arduino2 and ...
4
votes
2answers
4k 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
1answer
235 views

Alternative to UART/I2C LCD displays?

I'm building a MIDI synthesizer on Arduino Uno, and am considering user interface options. I see on Adafruit and Sparkfun there are 16x2 LCD panels available that interface via I2C serial or by UART,...
4
votes
2answers
5k 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) ...
4
votes
2answers
2k 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
1answer
769 views

Using SCL and SDA of ESP8266-01 with GY-30 BH1750FVI for lux measurement

I followed this tutorial to get lux measurement from GY-30 BH1750 with Arduino. It's working fine. But now I want to use it with ESP8266-01. I read Pin 4 is SDA and 5 is SCL for it. But it's not ...
4
votes
2answers
600 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 ...
4
votes
1answer
5k 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' ...
3
votes
3answers
1k views

Calling I2C functions inside an ISR

I have an Adafruit 2.8" cap touch display, which has an interrupt pin (IRQ). I tried to use this with my Arduino Nano, but encountered a problem: When trying to get the touched point from the display ...
3
votes
1answer
15k 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 <...
3
votes
2answers
9k 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 ...
3
votes
3answers
1k views

I2C Wire.write function doesn't seem to work

Using the simplest code possible to test the library: #include <Wire.h> void setup() { Wire.begin(); // join i2c bus Wire.beginTransmission(44); // transmit to device #44 (0x2c) ...
3
votes
1answer
162 views

Sensor TSL2591 with Arduino Mega

I have three light sensors TSL2591, of signal I2C, that I need to connect (together) to an Arduino Mega. However, I'm not very sure of how share the SDA and SCL pins of the three sensors and I don't ...
3
votes
2answers
27k views

How to display variables on 0.96" OLED with u8glib library?

I have Arduino Uno and 0.96" I2C Oled 4 Pinned display. These are my Arduino codes: #include "U8glib.h" U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // VDD=5V SCL=A5 SDA=A4 int a = 10; void ...
3
votes
2answers
491 views

Arduino Master-Slave Pins

Can I change the pins on the communication for a Master-Slave arduino Wire transmission? I want to communicate between 2 arduinos, but on one of them A4&A5 are taken
3
votes
2answers
521 views

Could I Connect many Arduino Nano boards together?

I want to know if I could connect many Arduino Nano boards together (Example : 10 boards ) , Also i want to know if there is any problem in Communication between them using I2C , could this affects ...
3
votes
1answer
1k views

Performing multiple Wire.writes() - does endtransmission slow things down?

Here's a question for anyone knowledgeable of the ways of I2C. I'm curious about sending multiple writes to a device and was looking at the code for a MPU9250 module. There is a nice library that ...
3
votes
3answers
937 views

How to properly use interruptions with twi (I2C)

I would like to reprogram Wire.h, or a part, to use interruptions, in order to not waste time to wait. I'm using an Arduino Mega with an Adafruit motor shield v2.3. In the datasheet, page 262, 24.9.2,...
3
votes
5answers
5k 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 ...
3
votes
3answers
470 views

I2C Temperature Sensor Communication Issue

I'm currently learning I2C and having some issues displaying the correct temperature in the serial monitor. I am using an Arduino Uno and an SI7021 temperature sensor from Sparkfun; here's the ...