I'm trying to connect a no name brand 128X64 OLED. to my Arduino Uno R3 board via I2C. Using this I2c scanner:
Once I can confirm the correct wiring for the OLED, I think I can program the UNO to read BMP280 sensor data and then display the Temp and Barometric Pressure on the OLED.
// I2C scanner by Nick Gammon. Thanks Nick.
#include <Wire.h>
void setup() {
Serial.begin (115200); // make sure the serial monitor baud rate matches
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 1; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
} // end of setup
void loop() {}
WHAT WIRES GO WHERE FROM UNO TO OLED?
Oled from left to right has GND VCC D0 D1 RES DC CS
This answer is totally without guarantee! There's no way to answer the question without knowing exactly what module you are using. "a no name brand 128X64 OLED" provides no such Information.
However, I will at least attempt to assist. These modules are often Hardware configured for either SPI or I2C (also known as IIC). Before you go any further, make sure the module is even configured for I2C. This may require adding/removing bridges or solder bridges or even cutting traces. Like I said, without knowing what module...
Refer to the following link.
That module has the same pinout as yours. As stated in the article, by Default it appears to NOT be configured for I2C and to do so would require adding SMD resistors or possibly solder bridges.
For that module, according to info in the link, you would Need to connect as follows:
I did Comment out for the Leonardo. Thanks for pointing that out. Zooming in on the back side; correct me if I'm wrong.. I need to Move R3 over to R8 for I2C?
TomGeorge:
Hi,
Before you do the scan, you need to do the edit that is noted in the code.
You are using a UNO not a Leonardo.
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
That code does not need to be changed or altered.
That code depends on a bool operator in the class. If the class didn't support it then the code would not compile.
On Leonardo it is set to true when the serial port is ready to communicate.
And while not necessary on something like HardwareSerial or SoftSerial, I had the Arduino boys add support for it so that the code would be portable across all serial interface.
This is the code in the HardwareSerial class:
operator bool() { return true; }
This will always return true as the h/w is always ready to talk; there is no need to remove the code that checks to see if the serial port is ready.
marine_hm,
I'm not very familiar with that display but from the photo, it appears that the display is jumpered for 4SPI (whatever that means) not I2C.
Notice that r2 and r1 are not strapped.
I certainly appreciate the help. I scavenged the Oled from another project that was collecting dust. Hoping I could use it for prototyping my new project. I thought I would try out some new skills (I2C). I did purchase an oled that is I2C specific. With only 4 pinouts. I'll just have to be patient and wait until it arrives.
I'll post back when it arrives. In the meantime..... I'm going to monkey with this oled, see if I can convert it to I2C. Worse case scenario. I burn myself with the soldering iron and chuck the oled in the trash, let the smoke out of something.