I2C With the ESP8266-01 !? || Exploring ESP8266:Part 1
Introduction: I2C With the ESP8266-01 !? || Exploring ESP8266:Part 1
Hello all ! With this instructable I will be writing and documenting a series of projects mentioning and exploring the various hidden ( rather unexplored ) features of the tiny ESP8266-01 WiFi Module.
Did you know that the ESP8266-01 supports I2C communication? Yes it is true, this little module lying unattended in one corner of your electronics bench has the capability to support this amazing communication protocol. This module is mainly used to connect and provide WiFi connectivity to a project using the serial communication involving Tx and Rx pins of the module. But in reality this cheap module is in itself a very capable microcontroller that can be used as standalone projects as well.
In this instructable we will be exploring the I2C communication protocol and interfacing an OLED display to show some animations and custom data as well.
So without any further delay let's jump into some theory and finally a practical application showing the hidden talents of this little buddy!
Step 1: First: Checking the Datasheet
The main microcontroller of the ESP8266-01 module is Espressif's ESP8266EX which is pretty powerful as compared to the more popular microcontrollers on the arduino.
This little thing has the following specifications:
1. CPU : Tensilica L106 32-bit processor
2. 1 MB of programmable memory!
3. A good range of communication protocols like: I2S,I2C, UART and SPI
4. It also has a PWM feature and interestingly also an ADC!
Okay so enough of good talks.Does this acually support I2C? Yes,and a quick look through the data sheet confirms this feature as well.
In this step I have attached the snapshots of the sections of datasheet that clearly mentions the communication capability and the pins required for I2C connections.
I2C is a very powerful communication protocol and used just 2 pins to communicate:
1. The SDA (this is the data pin)
2. The SCL (or SCK in some cases, this is the clock pin)
Systems connected via I2C have a master slave kind of communication topology. Here we can have multiple masters and multiple slave devices as well. 382
But how does a master device specifically communicate with a particular slave? Well here each device has a unique address of itself that can be used to access(or communicate) with that particular device. The device can be a output device, like the very popular OLED screens or it can also be an input device like the MPU6050 or a BMP180 sensor.
So coming back to the ESP8266, I have attached snapshots of the part of datasheet that mention I2C details. Here the main thing is that the SDA or the data pin is actually the GPIO2 pin which is available in the pinout of the WiFi module. What about the the SCL pin? Well, we only have the GPIO 0 pin left as an available pin so we can assign it as a SCL pin-more on this during the coding process.
I have also attached the datasheet for your reference
Step 2: Connecting Up the Modules
We now have a basic understanding of how I2C works and it's possible to implement the same in our ESP8266 module. In this step you can see a basic connection overview for the ESP8266 and the OLED display. As you can see that both module have a common power supply which ideally should be 3.3volts to 2.7volts at max as the ESP is a 3.3V compatible device and any higher voltage may potentially damage the board. But I have tested this board and does work at 5 volts logic though it gets more heated up, so let's not take any risk and stick to 3.3volts supply. here the GPIO2 is tied to SDA and the GOIP0 to SCK. The CH_PD is tied to Vcc to enable the module's functionality.
Step 3: Breadboard Setup
Now to test this setup, I have previously made a few mods and adapters so that I can easily program and fix the ESP8266 on to the breadboard. You know that ESP8266 is not a breadboard friendly module so I made a tiny little adapter that lets me plug the most important pins on to a bread board and access it conveniently.
I do have a instructable for that:
Breadboard Friendly Breakout Board for ESP8266-01: https://www.instructables.com/Breadboard-Friendly-...
You can go through this instructable to make your own little adapter in very less time. 382