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
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 ...
11
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
4answers
41k 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 ...
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?
9
votes
7answers
49k 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
1answer
9k 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: ...
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
27k 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
2answers
869 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?
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
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 ...
6
votes
1answer
357 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
13k 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
2answers
10k 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 ...
5
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(...
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
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 ...
5
votes
2answers
276 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
996 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
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, ...
5
votes
3answers
5k 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
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 ...
5
votes
2answers
46k 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 ...
5
votes
1answer
13k 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
696 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
319 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 ...
4
votes
3answers
6k 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
1answer
6k 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 ...
4
votes
2answers
2k 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 ...
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
3answers
694 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
2answers
8k views

Reading I2C sensors with a timer interrupt

I would like to read a sensor connected via I2C using Timer3 and Arduino Mega. Values are read from the sensor in the interrupt service routine and timer3 is set to trigger an interrupt at 200Hz. ...
3
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 ...
3
votes
1answer
16k 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
3answers
2k 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
206 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
4answers
6k 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 ...
3
votes
2answers
29k 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
4k views

arduino I2C maximum number of writes per Transmisson

Is there any limit on the number of Wire.write() commands consecutively in between the Wire.beginTransmission() command and the Wire.endTransmission() command for the Arduino Wire library?
3
votes
2answers
511 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
800 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
3answers
1k 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
2answers
4k 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....
3
votes
2answers
628 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....
3
votes
5answers
6k 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
258 views

Solution for simple multi-Arduino communication network (or alternative?)

I know similar question has already been discussed here but I could not get clear answer. Here is the thing: I have one master device - Mega2560, and multiple (about 9 but could be expandedin future) ...
3
votes
2answers
430 views

ATtiny85 LM75 I2C

I would like to read temperature from a LM75 using the ATtiny85 running a core by SpenceKonde and utilizing the TinyWireM library. My Logic Analyzer does not pick up any I2C communication, when I ...