Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing the SDA/SCL pins #11

Closed
kaosbeat opened this issue Aug 14, 2015 · 11 comments
Closed

changing the SDA/SCL pins #11

kaosbeat opened this issue Aug 14, 2015 · 11 comments

Comments

@kaosbeat
Copy link

Trellistest compiles and uploads works for the RFduino, although I don't know where to set the SDA and SCL pins. So I added

int SCLpin = 3;
int SDApin = 4;

in the beginning and

Wire.beginOnPins(SCLpin, SDApin);

in void setup()

but still no light. 3.3V not enough to power the LEDS? my Trellis works on a regular arduino. Or is it a pinout problem? can I set the SCL/SDA pins somewhere in the trellissetup? The serial output shows the test code so that means the SCL/SDA is working right?

would it be safe for my rfduino to connect the 5V pin to a 5V power source or will the SDA/SCL pins be fried?

thanks

@ladyada
Copy link
Member

ladyada commented Aug 14, 2015

This sounds like a good question for RFDuino, they must have something 'different' that makes it not Arduino compatible :)

@ladyada ladyada closed this as completed Aug 14, 2015
@kaosbeat
Copy link
Author

not sure, I've been grinding through this all day now, As the I2C scanner works, trellis is discovered fine on the RFduino using arduino code, but I'm not getting any response from the trellis using the trellis library. I don't know where to check for the I2C pinout in trellis, how can I be sure it's using the SDA/SCL?

I tested the signal using using a scope ... and nothing's on the line, while signal clear on my other test.
image

so simple question is, how to force trellis to use predefined SDL/SCA pins?

wireless trellis you know :) would be cool!

EDIT: I started a parallel thread on the RFDuino forum

@tolson2000
Copy link

It works if you connect to the default pins for SCL and SDA which is pins 5 and 6 on the RFduino. If you want to change locations to 3 and 4 then you have to put the Wire.beginOnPins(SCLpin, SDApin); in the library, not the setup() since that is where Wire.begin is initiated.

@kaosbeat
Copy link
Author

@tolson2000 I can confirm it works now! I did use the default 5 SCL, 6 SDA pins

@SandroGrassia
Copy link

tolson2000 can you please explain where Wire.beginOnPins(SCLpin, SDApin) must be written in the library?
Thank you

@tolson2000
Copy link

tolson2000 commented Nov 10, 2018 via email

@bigoper
Copy link

bigoper commented May 14, 2020

Hi @tolson2000
I can't seem to find that in the Adafruit_SSD1306.h library.
Could you help me out here?

Thanks!

@tolson2000
Copy link

Hi @bigoper
It is done in the .h file. Look in the .cpp file.

I am curious. Are you still using the RFduino somehow?

@bigoper
Copy link

bigoper commented May 14, 2020

@tolson2000
Hi,

I'm was trying to get Mongoose-os (limited javascript) with ESP8266 (NodeMCu v1 Lolin) to work with the SSD1306 library.
I needed to change the default pins since they are diff for my board.

I gave up on Mongoose-os, and went back to Espressif :)
Everything just works and lots of support.

Avi.

@4r53N1ck
Copy link

4r53N1ck commented Nov 13, 2022

To those who want to change the default I2C connections using Adafruit_SSD1306.h lib, try the following:

Chinese displays only:
Change your display address to 0x3C (even if you have the 128x64).

Then, after this line on your setup function
Serial.begin(115200);
add this to use (IE) D3 (SDA) and D4 (SCL):
Wire.begin(D3,D4);

So, your code should look like this:
`#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library.
// On an arduino UNO: A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
....

....

void setup() {
Serial.begin(115200);
Wire.begin(D3,D4);

// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
...
...
`

@tauzn-clock
Copy link

Thank you @4r53N1ck, this worked for me.
To recap, you must do two things

  • Wire.begin() allows you to redefine the SDA and SDL pins
  • Change SCREEN_ADDRESS from 0x3D to 0x3C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants