The I2C interface, Inter-Integrated Circuit, was developed by Philips to connect devices within a single device. Now it is used everywhere for "communication" of the microcontroller and the periphery or equally equivalent controllers due to the small number of wires (2 in total) and relatively high speeds.
RTL8710 based on the PADI IoT Stamp also has as many as 3 interfaces that can be used for your purposes, and in this article, we will try to connect something useful with just two wires!
In the implementation of the gtalusan from the Arduino environment, you can use only one interface - I2C1 - its findings are signed on the official PADI pinout:
And even though these pins are not registered in its implementation, the built-in libraries can use them (perhaps because of such a conflict, they were not registered). Ironically, the Arduino UNO I2C is also located on the 4th and 5th legs of Port C.
The interface has 2 exchange lines, one of which is bidirectional data exchange, and the other provides synchronization. Because of this, data can not be exchanged simultaneously in both directions, but the specification allows connecting up to 127 devices to only 2 wires without using numerous SS signals.
For proper operation and protection against short circuits, data lines and clock signals must be pulled to + power supply via resistors from 4.7 to 10 K. Most modules are already built-in, but if you plug in a bare chip without binding, do not forget about resistors - without them, it will not work categorically!
For directly working with the interface, the Wire library is used - in this case, its fork from Realtek. It will need to be applied if you have to work with non-standard hardware for which no libraries have been written yet.
For the first time, we advise you to carefully treat the choice of goods, buying only proven, so as not to “wither” at the very start, steeped in incomprehensible low-level operations.
We will test the work of I2C on the popular OLED screen with a 0.96-inch SSD1306 controller. Usually, when working with it, we use the library from Adafruit, but, unfortunately, it is not compatible with PADI at the moment, so we had to use U8G2 - a more universal, but also a more “heavy” library.
To implement the project from this article, we need the following components:
- PADI IoT Stamp - WiFi module based on RTL8710AF
- PADI Breadboard Adapter - Breadboard Adapter
- OLED display 0.96 ′ 128x64px
- 400 point breadboard
- Connection wires kit
All you need is to install it. The easiest way to do this is through the Library Manager. It is located in Sketch-Connect Library-Manage Libraries:
In the search box, type U8G2 and install the library:
Since the library is universal, the most difficult thing is to initialize it for the desired display. Open any example - we will show by example page_buffer-FPS.
As you can see, there are many commented lines at the beginning of the sketch. These are the initialization functions of displays with different controllers and resolutions. We use a 128 × 64 display on the controller SSD1306, so we are looking for it in the list:
Please note - it is also indicated that the display is connected via I2C, and hardware (hw = hardware). Uncomment the required line and fill in the example:
The program starts successfully and runs the test at a high enough speed! Up to 32 FPS in screen refresh mode is quite good options for a few optimized libraries.
You can read about working directly with the Wire library on the official Arduino website!