

A workaround will be for the master to make multiple requestFrom() calls, and for the slave to keep track of which block of 15 bytes to send out in requestEvent(). That could be increased to 32, or 64 (powers of 2 up to 256, as noted in the comment). I found that the maximum number of bytes that can be sent by each requestEvent() is 15 (one less the default value of TWI_RX_BUFFER_SIZE in Wire\src\USI_TWI_Slave\USI_TWI_Slave.h. This library and its examples were tested on with common Arduino boards.
#TINY WIRE LIBRARY CODE#
As recommended by the instructions, I bumped up the Arduino version to 1.8.6.įinally, happy to see reliable I2C communication between the 2 components! The communication has been going non-stop for 2 days now, with 1-minute interval between the send/receiving of messages.įrom the D1 mini end, the I2C master code is:įor ( int i = 1 i < sizeof(out) i ++) out = msg įor testing purposes, the D1 mini sends out 5 random bytes, and the ATtiny85 basically copies the received message into the outgoing buffer, with the first byte being the length of the received message (should be always '5'). Library Code Modification The ADS1115 library was designed to work with the Arduino Wire Library, but we need to modify it to work with the TinyWire Library.
#TINY WIRE LIBRARY MANUAL#
I did a manual upgrade to the latest git version as some I2C issues have been fixed in the V1.1.6 milestone but have not been officially released.

It has integrated I2C support that manifests as the familiar "Wire" library. Then I found "ATtin圜ore" by Spence Konde (V1.1.5), which appears to be a more mature ATtiny core compared to the "attiny" core by David Mellis (V1.0.2). It will start off well, but a few hours later, something will break and the D1 mini will start getting 0xFFs from the ATtiny85. I would send out 5 bytes from the D1 mini, then try to get 16 bytes back. In the setup, the LCD is initiated with lcd.init() and the backlight is turned on with lcd.backlight().I was not getting reliable I2C communication between the D1 mini and the ATtiny85, starting with TinyWireS, then moving on to the more developed TinyWire. Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered) You will need to change ‘lcd’ to the new name in the rest of the sketch. You can give it a different name if you want like ‘menu_display’. Note that we have called the display ‘lcd’. When using a 20×4 LCD, change this line to LiquidCrystal_I2C(0x27,20,4) This is where you will need to change the default address to the address you found earlier if it happens to be different. The next step is to create an LCD object with the LiquidCrystal_I2C class and specify the address and dimensions.įor this, we use the function LiquidCrystal_I2C(address, columns, rows). #include // Library for I2C communication The other library imports wire.h automatically. *When using the latest version of the LiquidCrystal_I2C library it is no longer needed to include the wire.h library in your sketch. In the rest of this tutorial, I will cover more of the built-in functions of this library.

As mentioned earlier we need both the wire.h* and the LiquidCrystal_I2C library. First, the required libraries are included.
