AB01 with relay 5V

Hello, we are trying to use a AB01 Cubecell board to drive a simple 2 channel 5V relay, but we are getting strange behaviors: the relay seems like to stay “always on” and sometimes we are able to power it off.
We are using a really simple sketch with GPIO1 and GPIO2 in OUTPUT mode.

Is there something you can advice?

Thanks

Hi, can you share some of your code ?

Sure here is the two interesting part:

void setup() {
  if (ENABLE_SERIAL) {
    Serial.begin(115200);
  }

  delay(5000 + randr(0, APP_TX_DUTYCYCLE_RND));
  pinMode(PIN_STEPPER_CLOSE, OUTPUT);
  pinMode(PIN_STEPPER_OPEN, OUTPUT);
  digitalWrite(PIN_STEPPER_CLOSE, HIGH);
  digitalWrite(PIN_STEPPER_OPEN, HIGH);

  deviceState = DEVICE_STATE_INIT;
  LoRaWAN.ifskipjoin();
}

And when I actually made the change:

#define PIN_STEPPER_OPEN GPIO1
#define PIN_STEPPER_CLOSE GPIO2

void makeStepAction(int seconds, int pin) {
  pinMode(pin, OUTPUT);
  digitalWrite(pin, LOW);
  delay(seconds * 1000);
  digitalWrite(pin, HIGH);
}

void handleChangeStep(const uint8_t *payload) {
  int newStep = payload[0];
  int seconds = 0;

  EEPROM.begin(512);
  delay(1000);
  latestStepValue = (int) EEPROM.read(eepromAddress);

  if (ENABLE_SERIAL) {
    Serial.println();
    Serial.print("New step saving:");
    Serial.println(newStep);
  }

  EEPROM.write(eepromAddress, newStep);
  EEPROM.commit();
  EEPROM.end();

  // Do close/open
  if (newStep == 0 || newStep == 5) {
    makeStepAction(STEPPER_FULL_RANGE_SEC, newStep == 0 ? PIN_STEPPER_CLOSE : PIN_STEPPER_OPEN);
    return;
  }

  // Do partial close
  if (newStep < latestStepValue) {
    if (ENABLE_SERIAL) {
      Serial.print("New step seconds CLOSE:");
      Serial.println(seconds);
    }

    makeStepAction(StepperSecTable[latestStepValue] - StepperSecTable[newStep], PIN_STEPPER_CLOSE);
    return;
  }

  // Do partial open
  if (newStep > latestStepValue) {
    if (ENABLE_SERIAL) {
      Serial.print("New step seconds OPEN:");
      Serial.println(seconds);
    }

    makeStepAction(StepperSecTable[newStep] - StepperSecTable[latestStepValue], PIN_STEPPER_OPEN);
    return;
  }
}

I want to point out that I can make the relay work with one diode in between the Cubecell PIN and the relay input.

I’ve got also another problem:
when in JOINING mode seems like the GPIO1 and GPIO2 are powered with voltage and that just triggers the relay to turn on and off when the board sends the join message.

For what I can see the GPIOx pins of the Cubecell are NEVER with voltage at 0 and that is causing problems with the relay handling.

hi,

I think the problem may be here. The output voltage of the CUBECELL pin is 3.3V. Both output current and output voltage should be insufficient.

Maybe you can replace a 3.3V relay.

Or Use GPIO to control a MOS tube to switch off the 5V voltage. please refer this link:
https://heltec-automation-docs.readthedocs.io/en/latest/cubecell/frequently_asked_questions.html#vext-control

Please measure these GPIO pin voltage before and after you connect the relay board.
Also, please check the GND connection.

I think your relay board has a pull-up resistor to 5V which may damage the pin or affect the correct output (high=3.3V/ low=0V).

1 Like

You just triggered a new idea: I have attached the VIN of the relay board to the 3.3v of the Cubecell and it started to work kinda “normally”.

I’m wondering if this is correct or I’m just forcing the relay to work.

The GPIO now measures correctly almost 4V when in HIGH state (the Cubecell is 5V powered through the VIN) and 0.05V on LOW state.

Yes, the answer is Yes

4V does not a correct IO voltage of CUBECELL. It should be the same as 3.3V on the board.
If you measure 4V on IO pin, which means your relay board has a high voltage source and current flow into the IO pin. It may damage your CUBECELL.

I have solved the issue completely with an HIGH level trigger relay board.

Everything is powered through USB (so 5V) and the relay now correctly responds to the command sent: HIGH will trigger the relay and LOW will turn off it.
I think the real problem was an induction on the circuit that influenced the work of the LOW level trigger relay board.

Thanks for the support.

1 Like