I2C 8 way relay board

Just want to hang out with other Makers and chat about stuff? This is the place to do it.
Post Reply
Justscary
Posts: 3
Joined: Thu Jul 25, 2013 5:19 am

I2C 8 way relay board

Post by Justscary » Fri Jul 26, 2013 6:05 am

Hi guys, I am very new to arduino and need a little help. I cant seem to get the relay board to communicate with I2C. I have tried the example sketch and can't seem to get it to work, I have even cut and pasted the example to ensure no mistakes on my behalf.

Firstly, I am using an Eleven and the relay shield. Later I may use another shield on top (LCD), but will do that later. The relay shield is on a seperate power supply of 13V, and has no jumper pins connected on the addr panel. The I2C_ADDR is defined as 0x20. The Eleven is powered through the USB (for now). I have no relay's connected as yet and am only trying to get the LED lights on each channel to light up for testing.

The problem is that the serial seems to be working fine, and it sends and recieves data to the eleven, and prints it as programmed. The shield just sits there, no lights light up (except the power LED near the input, Its as green as grass). The other thing is that if i include the lines

Wire.beginTransmission(I2C_ADDR);
Wire.write(0x00); //IODIRA register
Wire.write(0x00); //Set all of bank A to outputs
Wire.endTransmission();

I end up with an error, "call of overloaded 'write(int)' is ambiguous"

Any ideas?? I like to try and understand and learn, but I am at a loss and I am sure it is something very simple. Thanks guys,

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: I2C 8 way relay board

Post by andrew » Fri Jul 26, 2013 6:26 am

Hello

Could you please put the power jumper back onto the RELAY8 shield, leave the other jumper pins empty, fit the shield to your Eleven then upload the following sketch:

Code: Select all

#include "Wire.h"

#define I2C_ADDR  0x20  // 0x20 is the address with all jumpers removed

void setup()
{
  Wire.begin(); // Wake up I2C bus
  // Set I/O bank A to outputs
  Wire.beginTransmission(I2C_ADDR);
  Wire.write(0x00); // IODIRA register
  Wire.write(0x00); // Set all of bank A to outputs
  Wire.endTransmission();
}

void sendValueToLatch(int latchValue)
{
  Wire.beginTransmission(I2C_ADDR);
  Wire.write(0x12);        // Select GPIOA
  Wire.write(latchValue);  // Send value to bank A
  Wire.endTransmission();
}

void loop()
{
  for (int i=1; i<256; i*=2)
  {
    sendValueToLatch(i);
  delay(100);
  }
}
... and tell me what happened?
Thanks
John

Justscary
Posts: 3
Joined: Thu Jul 25, 2013 5:19 am

Re: I2C 8 way relay board

Post by Justscary » Fri Jul 26, 2013 7:04 am

Hi johnb,
I will try to do that tonight pending what time I get home as I'm out on the road again and don't have the unit with me, if not it will be first thing in the morning, aprox 6am QLD time, sorry about the delay. Thanks mate, Scary.

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: I2C 8 way relay board

Post by andrew » Fri Jul 26, 2013 7:16 am

No worries :)

Justscary
Posts: 3
Joined: Thu Jul 25, 2013 5:19 am

Re: I2C 8 way relay board

Post by Justscary » Fri Jul 26, 2013 11:21 am

Hi Johnb,
I have uploaded your code,works perfect, uploaded the sample code, works perfect, even the code I had written and it works. Buggered if I know what was going on, I had tried everything!!
The worst part is that I feel that I have not learned anything, oh well.

Thanks heaps for your help anyways.
Scary

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: I2C 8 way relay board

Post by andrew » Sat Jul 27, 2013 6:58 am

Justscary wrote:Hi Johnb,
I have uploaded your code,works perfect, uploaded the sample code, works perfect, even the code I had written and it works. Buggered if I know what was going on, I had tried everything!!
The worst part is that I feel that I have not learned anything, oh well.

Thanks heaps for your help anyways.
Scary
No worries, happens to us all now and again. :)



Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests