No no, the problem is not the relay. The problem is the board power.
My waspmote has to receive a command in order to switch on or off the relay. This part of my code is running ok, Pin DIGITAL2 is changing its value from 0 to 3.3V.
Code:
comando=data[1];
if(comando==0x01)
{
SensorProto.setRelayMode(SENS_RELAY_ON);
XBee.println("Relay encencido");
}
else if(comando==0x00)
{
SensorProto.setRelayMode(SENS_RELAY_OFF);
XBee.println("Relay apagado.");
}
But I can't use the relay, because the wasppmote is resetting when I switch on the power of the board. When I write this sentence, the board is resetting. If not, all ZigBee comm and I/Os are running ok, but I cannot use the relay because it is not powered.
Code:
SensorProto.setBoardMode(SENS_ON);
I've tried it with other waspmote and the result is the same, so there should be some problem with my Prototype Board.
This is my initial code, and it is resetting after the print of "Unido a la red".
Code:
//SETUP code
//Start Xbee in Zigbee, 2.4GHz, 2mW
xbeeZB.init(ZIGBEE, FREQ2_4G, NORMAL);
//Xbee power on
xbeeZB.ON();
delay(2000);
xbeeZB.getAssociationIndication();
delay(2000);// Check if creating process success
while (xbeeZB.associationIndication)
{
XBee.println("Imposible unirse a la red");
xbeeZB.getAssociationIndication();
delay(200);
}
XBee.println("Unido a la red!");
SensorProto.setBoardMode(SENS_ON);
delay(1000);
Regards,
Iker.