Annex UNO 4 Channel Relay

Place your projects here
Post Reply
User avatar
Posts: 946
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 310 times
Been thanked: 352 times

Annex UNO 4 Channel Relay

Post by Electroguard »

I thought my UNO days were long gone... until I stumbled on this ESP32-S3 N16R8 UNO while looking for SD shields.
An obvious advantage is that it's a powerful ESP32 with 16Mb flash and 8Mb PSRAM, resulting in Annex having > 13MB file storage and > 8Mb System RAM.
And for anyone interested in the onboard neo-pixel, it is already connected wih gpio48


It also has the advantage of onboard DC skt and regulator allowing it to be conveniently powered by mains adapters from 7v to 12v.
But perhaps the most obvious advantage is the UNO footprint, which allows simple plug-in access to a wide range of UNO shields.
For instance: UNO proto shields offer a big stable platform for mounting sensors, or mini breadboard, or perhaps AnnexVGA resistors and VGA connector.


But I am starting this thread with a very practical example of an Annex 4 relay USB switcher for controlling up to 4 other usb items.
The N16R8 may be overkill for this, so you can save a couple of quid by using the black D1 R32 4Mb esp32 UNO clone for use with the relay shield.
Both esp32 UNO clones run Annex perfectly, but they operate with 3.3v gpio's instead of the arduinos 5v, although the 4 relay shield operates ok from 3.3v.


ESP 3.3v pins are 5v tolerant anyway, so receiving 5v logic levels from a shield should not be a problem.
But for any shields that only operate from 5v inputs, the esp 3.3v outputs may be too low, requiring use of cheap logic voltage level converters.
They can conveniently be mounted on a protoshield, but be aware that not all shields are stackable, and some may use long-pins headers going straight through from top to bottom, therefore how and where to insert input and output of level converters may need a bit of thought. For instance, the blue protoshield has UNO footprint lower pins for plugging on top of an UNO, but the top female headers are narrower, and just for plugging in dupont cables.
Whereas the red screw protoshield uses staggered bottom pins and top headers, making it stackable on top also. And because the left and right side by side pins and female headers are offset, it is possible to carefully cut the required track joining pin and header to insert logic level converters.

This is not necessary for the 4 channel relay shield shown below, because the relays are already suitable for operating directly from 3.3v gpio's.


I would not feel comfortable switching mains voltage with the relay shield, so I would probably use 3v input SSD relays to control mains devices.

ssd relay.jpg

But a lot of things nowadays are powered by 5v USB, so the relay shield and a single 5v 3a to 5a supply could be used to control up to 4 USB devices.


Here is a simple script with individual relay controls plus all on and all off controls.

Code: [Local Link Removed for Guests]

'ESP UNO 4 Relay shield
title$="Annex ESP UNO 4 Relay shield"
'uncomment your Esp UNO type
select case uno$
case "8266": a=7: b=6: c=5: d=4
case "esp32": a=14: b=27: c=16: d=17
case "s3": a=14: b=3: c=20: d=19 
case else: wlog "esp UNO type not recognised"
end select
pin.mode a,output: pin(a)=0
pin.mode b,output: pin(b)=0
pin.mode c,output: pin(c)=0
pin.mode d,output: pin(d)=0
ledA=1: ledB=1: ledC=1: ledD=1
onhtmlreload webpage
gosub webpage

autorefresh 1000
a$ = ""
a$ = a$ + "<br><br>"
a$ = a$ + "<div id='div' style='display: table; margin-right:auto;margin-left:auto;text-align:center; '>"
a$ = a$ + cssid$("div", "xfont-sizex:1.5em; xtransform: scale(1.3);")
a$ = a$ + "<h2>" + title$ + "</h2>" + "<br>"
a$ = a$ + led$(ledA) + string$(gap,"&nbsp;") + button$("A",toggleA) +"<br>" 
a$ = a$ + led$(ledB) + string$(gap,"&nbsp;") + button$("B",toggleB) +"<br>" 
a$ = a$ + led$(ledC) + string$(gap,"&nbsp;") + button$("C",toggleC) +"<br>" 
a$ = a$ + led$(ledD) + string$(gap,"&nbsp;") + button$("D",toggleD) +"<br>" 
a$ = a$ + "<br><br>"
a$ = a$ + button$("All ON", allON) + string$(gap,"&nbsp;") + button$("All OFF",allOff) +"<br><br>" 
html a$
a$ = ""

if pin(a)=0 then ledA=0: pin(a)=1: else ledA=1: pin(a)=0 

if pin(b)=0 then ledB=0: pin(b)=1: else ledB=1: pin(b)=0 

if pin(c)=0 then ledC=0: pin(c)=1: else ledC=1: pin(c)=0 

if pin(d)=0 then ledD=0: pin(d)=1: else ledD=1: pin(d)=0 

pin(a)=1: pin(b)=1: pin(c)=1: pin(d)=1
ledA=0: ledB=0: ledC=0: ledD=0

pin(a)=0: pin(b)=0: pin(c)=0: pin(d)=0
ledA=1: ledB=1: ledC=1: ledD=1

end '------ END --------
You do not have the required permissions to view the files attached to this post.
Posts: 361
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 197 times
Been thanked: 115 times

Re: Annex UNO 4 Channel Relay

Post by BeanieBots »

Nice find. Looks like it has a switching regulator in which case I would expect it to work down to <5v (possibly use an 18650 battery) and also supply a decent amount of current without getting hot. Do you have a spec for it?
I know you mentioned you were after an SD shield but I have used this before. ... ts_id=2947
Good price, reputable supplier and short delivery times.
User avatar
Posts: 946
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 310 times
Been thanked: 352 times

Re: Annex UNO 4 Channel Relay

Post by Electroguard »

I have one of those SD modules somewhere, but it got rusty when the hanger roof was smashed in during a storm, and anyway it's awkward to mount.
That is the beauty of the UNO clones and shields, they just plug together into a sturdy self-contained package which is easily housed in some sort of box... and although they don't come with any info, a quick online search of any arduino shields brings up loads of info about them.
No shortcuts for using them with Annex though, cos like the 4 channel relay which I needed for a stepper motor project, it's all a first.
Have already used both analog joysticks and all the buttons on the UNO joystick shield via dupont wires, but I want to try it plugged in as a stack, next.
I also have a couple of different UNO data logger SD shields which I need time to explore, and will be a bonus if the battery-backed-up RTC can work.
Got quite a few other shields to try, including a quad A4988 stepper driver, and something with buzzer and buttons and 4 digit 7-segment display.
It's just a matter of finding time to catch the moving target... and Francesco will be messing up my priorities list when he releases his S3 USB update.
Post Reply