problem with codec-adaptive wireless relay

Hello.

Another question on these:

seeedstudio.com/depot/codeca … th=139_140

After getting the samples available on the wiki, I’m turning the relay on/off with the following piece of code (with an Arduino 2009):

void turnSwitchOnOff(byte sw)
{
digitalWrite(sw,HIGH);
digitalWrite(enablePin,HIGH);
delay(1000);
digitalWrite(sw,LOW);
digitalWrite(enablePin,LOW);
delay(1000);
}

I have some weird behaviours:

  • sometimes it just work fine
  • sometimes the signal is completely ignored (i.e. the switch does not do anything)
  • sometimes it process two signals, so it turns on and then immediately off (or the opposite if the relay is alredy on)

I’d like to ask you if the code listed above is the correct way to handle this, and if you can suggest me how to investigate this issue.

Thanks a lot!

hi, sir , the enable pin need pulse rising edge to enable the setting, so , you need to first digitalwrite low to the enable , and then digitalwrite HIGH to this pin.
for example:
void turnSwitchOnOff(byte sw)
{
digitalWrite(sw,HIGH); // set the relay state.
/// gives a rising edge to enable pin
digitalWrite(enablePin,LOW);
delay(100);
digitalWrite(enablePin,HIGH);
////
delay(1000);
}

Thanks a lot.

I had to increase a little bit the delay between the two digitalWrite to make it more reliable, but now it works like a charm. Thanks. Here the code for reference

void turnSwitchOnOff(byte sw)
{
digitalWrite(sw,HIGH); // set the relay state.

// Gives a rising edge to enable pin
digitalWrite(enablePin,LOW);
delay(200);
digitalWrite(enablePin,HIGH);
//
delay(1000);
}

mmmm I was too optimistic…

The new code worked correctly for a couple of days, but now it started to have the same original behaviour: sometimes signal are ignored, sometimes doubled.

Any further suggestion?

Thanks,

OK, I found the problem: it was just an issue of underpowering the Arduino board.

With the USB power, the 5v PIN can be unstable. I externally powered the Arduino board with 12v, and now the signal is stable and reliable.

Thanks,

cips