Relay8 Working, but dropping out

Got comments, questions, or tips about any of the shields listed on ShieldList.org? Post them here!
Post Reply
Big_Valven
Posts: 2
Joined: Tue Dec 09, 2014 11:35 am

Relay8 Working, but dropping out

Post by Big_Valven » Tue Dec 09, 2014 12:08 pm

Hi all. I have a Relay8 board *almost* successfully running in my simple project. I am using a DFrobot Bluno board (Uno compatible) with this shield. My program activates relay outputs upon received data from the bluetooth connection and an Ipad app. At this stage only one output is activated at a time.

The whole shebang works perfectly, except that after a period of time, the activated relay output turns off without my instruction. It seems arbitrary, but is usually after about 5 minutes. If I re-activate the output from the app before the issue occurs, the output will stay on longer.
As a process of elimination, I have even activated an output from the app, then disconnected bluetooth so it's not actually possible for the app to send any instructions to the Arduino or relay board.

The system will be active 8 - 10 hours a day so obviously the relay outputs need to stay put unless instructed. Any help would be appreciated.

Code is more or less as per the demo sketch:


//
// DFRobot - Bluno - Hello World
// version: 0.2 - 2014-12-01
//

#include "Wire.h"

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

void setup() {
Serial.begin(115200);

pinMode(2, OUTPUT);
pinMode(A0, INPUT);

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();

sendValueToLatch(255);
delay(800);
sendValueToLatch(0);

}

void loop() {

int command = 0;
if (Serial.available()) {
command = Serial.read();
if( command == 0x00)
{
sendValueToLatch(0);
}
if( command == 0x01)
{
sendValueToLatch(1);
}
if( command == 0x02)
{
sendValueToLatch(2);
}
if( command == 0x03)
{
sendValueToLatch(4);
}
if( command == 0x04)
{
sendValueToLatch(8);
}
if( command == 0x05)
{
sendValueToLatch(16);
}
if( command == 0x06)
{
sendValueToLatch(32);
}
if( command == 0x07)
{
sendValueToLatch(64);
}
if( command == 0x08)
{
sendValueToLatch(128);
}
}

delay(200);
}

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

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Relay8 Working, but dropping out

Post by angusgr » Tue Dec 09, 2014 8:55 pm

Hi Big_Valven,

The code looks correct to me. If I had to guess I'd say the Bluetooth module on the BLUNO board is sending a null byte (0) to the Arduino processor now and then, maybe on a timeout or something, which causes the sketch to see the "0" and turn the outputs off.

An easy way to try and confirm this would be to comment the "sendValueToLatch(0);" line and see if the problem goes away.

Another way would be to echo each character that the sketch sees, something like:

Code: Select all

command = Serial.read();
Serial.println(command, HEX)
... and then use the Serial Monitor plugged into the Bluno directly (or a Bluetooth option if you have one) to watch the output and see when characters are received by the sketch.

If you confirm this is happening, you could remove the 0-byte command from the commands that the sketch recognises (maybe rearrange which command value triggers what) and this might solve the problem, as then the 0s get ignored.

The only other possibility I can think of is that the Bluno is resetting for some reason.

Good luck tracking the problem down, please let us know what you find.


Angus

Big_Valven
Posts: 2
Joined: Tue Dec 09, 2014 11:35 am

Re: Relay8 Working, but dropping out

Post by Big_Valven » Wed Dec 10, 2014 11:36 am

Thanks Angus for your ideas so far.

I've tried changing the app and program to avoid any potential false triggers, and resorted to commenting out any code for the Arduino that would result in a 0 being sent to the Relay8, but exactly the same thing is happening.

For what it's worth, the Arduino hasn't been resetting, as the bluetooth connection would drop out.

Also important to note, that I didn't include in the original post - when the Relay8 drops out, it's not possible to re-instate operation without cycling power to the whole setup. After it drops out, commands are still being received by the Arduino, as the acknowledge light on the board blinks with each command. So a lot of the evidence is pointing to the Relay8 being odd.

I can think of a (messy) workaround to periodically re-send the command to the Relay8, but it's a fix for a problem that shouldn't really be there... :(

Post Reply