Relay Logic Wrong Positive vs Negative
Your relay behaves opposite to what the dashboard shows ON when it should be OFF, or OFF when it should be ON. This is a logic configuration issue, not a hardware failure. This guide explains Positive Logic vs Negative Logic and how to fix the setting.
Last updated: April 22, 2026 | 8 min read
Symptoms
- Dashboard shows relay ON but device is OFF
- Relay clicks when you turn it OFF
- Relay works correctly but inverted from dashboard
- Same relay module worked with different platform but not OceanRemote
- LED indicator on relay module shows opposite of dashboard state
- Multiple relays all behave inverted
What is Relay Logic?
Relay logic determines what voltage level on the GPIO pin activates the relay. Different relay modules use different logic types.
Positive Logic
GPIO HIGH = Relay ON (click)
GPIO LOW = Relay OFF
Less common. Used in industrial PLCs and some premium relay modules.
Negative Logic
GPIO LOW = Relay ON (click)
GPIO HIGH = Relay OFF
Most common. Used by 90% of cheap 5V relay modules .
Positive vs Negative Logic Comparison
| State | Positive Logic | Negative Logic | Your Module? |
|---|---|---|---|
| Relay ON (click) | GPIO = 3.3V | GPIO = 0V | Test with multimeter/Manual: Touch IN to GND should click if Negative; Touch IN to 5V should click if Positive. Use that to determine your module's logic. Then set dashboard accordingly. Negative: IN to GND clicks set dashboard to "Negative". Positive: IN to 5V clicks set dashboard to "Positive". If no click, check power/coil first. |
| Relay OFF | GPIO = 0V | GPIO = 3.3V | |
| Dashboard "ON" button | Sends HIGH to GPIO | Sends LOW to GPIO | |
| Dashboard "OFF" button | Sends LOW to GPIO | Sends HIGH to GPIO |
If your relay clicks when dashboard shows OFF, you have the wrong logic setting.
How to Determine Your Relay Logic
Method 1: Manual Test
// Manual relay logic test:
// 1. Connect relay VCC to 5V power supply
// 2. Connect relay GND to power supply GND
// 3. Leave IN wire disconnected initially
//
// For Negative Logic :
// Touch IN wire to GND Relay should click ON
// Remove from GND Relay should click OFF
//
// For Positive Logic :
// Touch IN wire to 5V Relay should click ON
// Remove from 5V Relay should click OFF
//
// Result determines your logic type
Method 2: Multimeter Measurement
- Set multimeter to DC voltage
- Power relay module with 5V
- Measure voltage between IN pin and GND
- When dashboard shows OFF: Note voltage
- When dashboard shows ON: Note voltage
- If ON voltage is 3.3V Positive Logic
- If ON voltage is 0V Negative Logic
Method 3: Common Module Reference
- Songle Relay Module : Negative Logic
- SainSmart Relay Module: Negative Logic
- HiLetgo Relay Module: Negative Logic
- Advanced PLC relay boards: Usually Positive Logic
- Optocoupler-isolated modules: Usually Negative Logic
- If unsure: Use Method 1 above to test
Step-by-Step Fixes
1. Change Logic Setting in OceanRemote Dashboard
The fastest fix no firmware re-flash required:
- Log into OceanRemote dashboard
- Click on your device card "DETAILS" button
- Scroll to relay configuration section
- For each relay, find "Logic" setting
- Change from "Positive" to "Negative"
- Click "Save" button
- Test relay from dashboard immediately
- Relay should now behave correctly
// What happens in firmware when you change logic:
// Positive Logic:
// if digitalWrite;
// else digitalWrite;
//
// Negative Logic:
// if digitalWrite;
// else digitalWrite;
//
// The dashboard setting updates this behavior instantly
2. Regenerate Firmware with Correct Logic
If dashboard setting doesn't persist, regenerate firmware:
- Go to "Your Device" page in OceanRemote
- Re-enter your relay names and settings
- Select correct logic for each relay
- Click "Generate Firmware Code"
- Copy the new code
- Flash to your ESP32/ESP8266/Pico W
- Test relay operation
3. Test with Simple Blink Sketch
Verify relay works with known logic:
// Test sketch for Negative Logic
const int relayPin = 2;
void setup() {
pinMode;
digitalWrite; // Start with relay OFF
}
void loop() {
digitalWrite; // Relay ON
delay;
digitalWrite; // Relay OFF
delay;
}
// For Positive Logic, swap LOW/HIGH:
// digitalWrite; // Relay ON
// digitalWrite; // Relay OFF
4. Check Physical Relay Module Label
Some modules indicate logic on PCB:
- Look for "Active High" or "Active Low" text on PCB
- "Active High" = Positive Logic
- "Active Low" = Negative Logic
- If no label, use manual test method above
5. Verify with LED Indicator
Most relay modules have an LED near each relay:
- LED ON when relay coil is powered
- If LED ON when dashboard shows ON Logic is correct
- If LED ON when dashboard shows OFF Logic is inverted
- Change logic setting in dashboard until LED matches dashboard state
Common Relay Module Logic Types
| Module Brand/Type | Logic Type | Notes |
|---|---|---|
| Songle | Negative Logic | Most common, tested with multimeter IN to GND clicks, LED on at LOW. Set dashboard to Negative. |
| SainSmart 5V relay module | Negative Logic | Common on Amazon |
| HiLetgo 5V relay module | Negative Logic | Common on AliExpress |
| Omron G5LE-14 | Positive Logic | Advanced grade, less common |
| TCRT5000 relay module | Negative Logic | Optocoupler isolated |
| No-name generic | Negative Logic | Test first to confirm |
Prevention Tips
- Test relay logic before final installation
- Document logic type for each relay module in your notes
- Use consistent relay modules across your project to avoid confusion
- Label relay modules with their logic type
- When buying new relays, check product description for logic type
- Save OceanRemote device configuration after setting correct logic
Related Issues
- Relay Not Clicking No sound when toggling
- Relay Clicking But No Power Click but load not powered
- Relay Stuck OFF Won't turn ON at all
- Relay Stuck ON Won't turn OFF
Frequently Asked Questions
Q: Why do most cheap relay modules use Negative Logic?
A: Cost and compatibility. Negative Logic allows the optocoupler LED to be driven directly from GPIO pin to GND. It's simpler and cheaper to manufacture. Most microcontrollers can sink current better than they can source it.
Q: Can I change the logic physically on the relay module?
A: Not easily. Some modules have a jumper to change between Active High/Low, but most do not. Use the dashboard setting instead it's the correct way to fix logic inversion.
Q: My relay works correctly but the dashboard button shows opposite state. What's wrong?
A: The dashboard button state matches what the server sent, not what the relay actually did. If the relay clicked but the dashboard didn't update, check your internet connection. If the problem persists, it's a logic issue change the logic setting.
Still having logic issues? Contact Support or return to the Troubleshooting Hub.