Arduino Code and Video for Omron G3MB Solid-State Relay

Arduino Code and Video for Omron G3MB Solid-State Relay

In this tutorial, we will learn how to use the Omron G3MB solid-state relay to control an AC load, such as a light bulb, with and without an Arduino. This relay module can handle AC loads of up to 240 volts and is compatible with a 5-volt input, making it ideal for Arduino projects. By the end of this tutorial, you will understand how to wire the relay and write the Arduino code to control it effectively.

We will first cover the hardware components involved in this project, followed by wiring instructions and a detailed explanation of the code. You can also refer to the video for visual guidance and clarification on specific steps (in video at 00:00).

Hardware Explained

The main component of this project is the Omron G3MB solid-state relay. This relay allows you to control high-voltage AC loads with a low-voltage DC signal from the Arduino. The relay operates by using an optoisolator to switch the AC load on and off without a mechanical switch, providing greater reliability and longer life.

In addition to the relay, you will need an Arduino board to send control signals. The Arduino will output a low or high signal to the relay, which will then activate or deactivate the connected AC load. Make sure to follow safety precautions when working with high voltage.

Datasheet Details

ManufacturerOmron
Part numberG3MB-202P
Logic/IO voltage5 V
Supply voltage5–24 VDC
Output current (per channel)2 A max
Peak current (per channel)4 A max
PWM frequency guidanceN/A
Input logic thresholds0.5 V (low), 2.5 V (high)
Voltage drop / RDS(on) / saturation1.5 V max
Thermal limits−30 °C to +100 °C
Package4-pin DIP
Notes / variantsAvailable in 5V, 12V, and 24V versions

  • Ensure the AC load does not exceed the relay's ratings (2 A max).
  • Use proper heat sinking if operating near maximum ratings.
  • Always isolate the control circuit from the AC load circuit.
  • Double-check connections before powering the circuit.
  • Use a fuse for safety in the AC load circuit.

Wiring Instructions

Arduino wriing for G3MB-202P solid state relay
Arduino wriing for G3MB-202P solid state relay

To wire the Omron G3MB solid-state relay, start by connecting the relay's negative pin (Pin 1) to the ground of the Arduino. Next, connect the positive pin (Pin 2) to digital pin 8 on the Arduino, which will be used to control the relay. The two pins on the other side of the relay (Pin 3 and Pin 4) will be connected to the AC load. Make sure to connect one wire of the AC load to Pin 3 and the other to Pin 4. This setup will allow the relay to control the flow of electricity to the AC load based on the signal from the Arduino.

When wiring, ensure that all connections are secure and insulated, especially those involving the AC load. If you are using a breadboard for testing, be aware that the relay pins may require some force to fit into the breadboard holes (in video at 01:30). Always prioritize safety when working with AC components.

Code Examples & Walkthrough

In the Arduino code, we define relayPin as pin 8, which is used to control the solid-state relay. In the setup() function, we set this pin as an output to allow the Arduino to control the relay.

int relayPin = 8; // define output pin

void setup() {
  pinMode(relayPin, OUTPUT); // set pin 8 (relayPin) as output
}

Within the loop() function, we toggle the relay state every two seconds. The relay is turned off by setting the relayPin to LOW, and after a delay, it is turned on by setting it to HIGH. This creates a simple on/off cycle for the AC load.

void loop() {
  digitalWrite(relayPin, LOW); // Turn the Relay OFF
  delay(2000); // Wait for 2000 milliseconds (2 seconds)
  digitalWrite(relayPin, HIGH); // Turn the Relay ON
  delay(2000); // Wait for 2000 milliseconds (2 seconds)
}

In your application, you can modify the conditions under which the relay activates based on your specific requirements, such as monitoring temperature or other sensor inputs. This flexibility allows for various automation tasks.

Demonstration / What to Expect

When the code is uploaded to the Arduino, you should see the AC load (light bulb) turn on and off every two seconds. If you experience any issues, double-check your wiring connections to ensure they are correct and secure. Common pitfalls include reversed polarity and floating inputs, which can lead to unexpected behavior (in video at 02:15).

Video Timestamps

  • 00:00 - Introduction to the project
  • 01:30 - Wiring the relay
  • 02:15 - Demonstration of the relay control

Images

G3MB-202P_SSR-2
G3MB-202P_SSR-2
G3MB-202P_SSR-3
G3MB-202P_SSR-3
G3MB-202P_SSR-1
G3MB-202P_SSR-1
Arduino wriing for G3MB-202P solid state relay
Arduino wriing for G3MB-202P solid state relay
90-Arduino code and video for Omron G3MB solid-state relay
Language: C++
Copied!

Things you might need

Resources & references

No resources yet.

Files📁

Fritzing File