adafruit / Adafruit_Trellis_Library

Arduino library for controlling Adafruit Trellis
45 stars 24 forks source link

changing the SDA/SCL pins #11

Closed kaosbeat closed 9 years ago

kaosbeat commented 9 years ago

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 commented 9 years ago

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

kaosbeat commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

SandroGrassia commented 6 years ago

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

tolson2000 commented 6 years ago

Replace the Wire.begin() with Wire.beginOnPins(SCLpin, SDApin).

void Adafruit_Trellis::begin(uint8_t_addr = 0x70) {   i2c_addr = _addr;

Wire.begin();

Wire.beginOnPins(3,4); #for example

  Wire.beginTransmission(i2c_addr);

  *

On 11/9/18 1:49 PM, Visergrass wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adafruit/Adafruit_Trellis_Library/issues/11#issuecomment-437490901, or mute the thread https://github.com/notifications/unsubscribe-auth/AIrlX4CuS97ox9_aV0q1HFuAUoVkrkClks5utepygaJpZM4FrlJp.

bigoper commented 4 years ago

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

Thanks!

tolson2000 commented 4 years ago

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 commented 4 years ago

@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 commented 2 years ago

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

include

include

include

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 commented 1 year ago

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