# Automation Hat Mini relay not working

**URL:** <https://forums.pimoroni.com/t/automation-hat-mini-relay-not-working/16750>\
**Category:** Support\
**Created:** [March 28, 2021, 1:59pm UTC](https://forums.pimoroni.com/t/automation-hat-mini-relay-not-working/16750 "2021-03-28T13:59:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimhill](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jimhill](https://forums.pimoroni.com/u/jimhill)\
**Post date:** [March 28, 2021, 1:59pm UTC](https://forums.pimoroni.com/t/automation-hat-mini-relay-not-working/16750/1 "2021-03-28T13:59:20Z")

</div>

I am trying to get my Automation Hat Mini to work and have installed all of the software. I can run the example scripts for the inputs, outputs and analog ionuts and these all seem to work. There wasn’t an example for the relay for the mini so created my own couple of versions to try and get the relay to work, but it doesn’t seem to be switching. Any suggestions?

**Test 1**  
import time

import automationhat

while True:  
automationhat.relay.on()  
print(“Relay on”)  
time.sleep(1)  
automationhat.relay.off()  
print(“Relay off”)  
time.sleep(1)

**Test 2**

import time

import automationhat

while True:  
automationhat.relay.on()  
print(“Relay on”)  
time.sleep(1)  
automationhat.relay.off()  
print(“Relay off”)  
time.sleep(1)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [March 28, 2021, 6:25pm UTC](https://forums.pimoroni.com/t/automation-hat-mini-relay-not-working/16750/2 "2021-03-28T18:25:50Z")

</div>

Try `automationhat.relay.one.on()` or `automationhat.relay.toggle()`  
[automation-hat/REFERENCE.md at master · pimoroni/automation-hat · GitHub](https://github.com/pimoroni/automation-hat/blob/master/documentation/REFERENCE.md)

---

<div class="post-metadata">

**Author:** ![jimhill](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jimhill](https://forums.pimoroni.com/u/jimhill)\
**Post date:** [March 28, 2021, 7:38pm UTC](https://forums.pimoroni.com/t/automation-hat-mini-relay-not-working/16750/3 "2021-03-28T19:38:04Z")

</div>

Tried this

```
import time

import automationhat

while True:
    automationhat.relay.one.toggle()
    print("Relay on")
    time.sleep(1)
    automationhat.relay.one.toggle()
    print("Relay off")
    time.sleep(1)

```

and also this

```
import time

import automationhat

while True:
    automationhat.relay.one.on()
    print("Relay on")
    time.sleep(1)
    automationhat.relay.one.off()
    print("Relay off")
    time.sleep(1)

```

But still no luck, any other suggestions?

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [March 28, 2021, 8:02pm UTC](https://forums.pimoroni.com/t/automation-hat-mini-relay-not-working/16750/4 "2021-03-28T20:02:05Z")

</div>

GPIO 16 is the relay pin, you could try setting it high or low?  
[Automation HAT Mini at Raspberry Pi GPIO Pinout](https://pinout.xyz/pinout/automation_hat_mini)

---

<div class="post-metadata">

**Author:** ![jimhill](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jimhill](https://forums.pimoroni.com/u/jimhill)\
**Post date:** [March 29, 2021, 6:49pm UTC](https://forums.pimoroni.com/t/automation-hat-mini-relay-not-working/16750/5 "2021-03-29T18:49:03Z")

</div>

Thanks for that, I’ve tried running it just by turning that pin on and still no luck. I tested it by putting an LED on the output to make sure it was working and the LED would turn on and off. This was the code I used, just to double check I haven’t missed something. I’m assuming the Relay doesn’t need a load on the output contacts to get it to switch?

```
from time import sleep

from gpiozero import OutputDevice

relay = OutputDevice(16)

relay.off()

while True:
    relay.on()
    print("Relay On")
    sleep(0.5)
    relay.off()
    print("Relay Off")
    sleep(0.5)
```

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [March 29, 2021, 8:01pm UTC](https://forums.pimoroni.com/t/automation-hat-mini-relay-not-working/16750/6 "2021-03-29T20:01:17Z")

</div>

Kind of sounds like a dud relay.  
Is the automation mini plugged directly into the Pi, no jumpers or ribbon cable?  
If it’s a Pi Zero, did you solder on the header?
