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,
I2C 8 way relay board
-
- Freetronics Staff
- Posts: 978
- Joined: Sun Jul 14, 2013 7:06 am
- Location: Melbourne, Australia
- Contact:
Re: I2C 8 way relay board
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:
... and tell me what happened?
Thanks
John
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);
}
}
Thanks
John
Re: I2C 8 way relay board
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.
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.
-
- Freetronics Staff
- Posts: 978
- Joined: Sun Jul 14, 2013 7:06 am
- Location: Melbourne, Australia
- Contact:
Re: I2C 8 way relay board
No worries 

Re: I2C 8 way relay board
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
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
-
- Freetronics Staff
- Posts: 978
- Joined: Sun Jul 14, 2013 7:06 am
- Location: Melbourne, Australia
- Contact:
Re: I2C 8 way relay board
No worries, happens to us all now and again.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
