1 / 5
Case for 4-channel USB relay and USB power connections — zdjęcie 1
1 / 5

Case for 4-channel USB relay and USB power connections

Zamów wydruk tego modelu

Obliczymy ostateczną cenę na podstawie wybranego pliku. Sprawdzisz ją i zaakceptujesz przed płatnością.

Zapisane na tym urządzeniu.

Case for 4-channel USB relay and USB power connections to control my 3d printer enclosure fans/lights.

Ocena
0 / 5
Polubienia
5
Pobrania
48
Wydruki
1
Wyświetlenia
478
Oceny
0

Aktualizacja u źródła:

Informacje o modelu

Źródło
Printables
Kategoria
Electronics
Licencja
Creative Commons — Attribution — Noncommercial — Share Alike

This is my solution to controlling the lighting and fans in my enclosure.  My parts:

The relay board fits snugly into the bottom of the case.  The 4 USB ports are screwed into the top (I used just one 3mm screw/connector).  I then wired in a power step-down converter and adjusted it's output to 5V (need a small Philips screwdriver and a multimeter).

Run the ground (negative/black) from the power step-down module to the ground on all four of the USB boards.  Run the positive (red) from the power step-down module to the input (COM1/2/3/4) on each of the relays and then another wire from the relay “on” (NO1/2/3/4 - “normally open”) port to the positive on each USB board.

The front USB cable connects to my Raspberry Pi running Octoprint.

Then I installed Jan Dittberner's “usbrelay” program by simply running:
# sudo apt install usbrelay

Running “usbrelay” will display any USB relay boards it finds and the values to turn each port on and off (the “QAAMZ_” at the end):
 

$ usbrelay
Device Found
 type: 16c0 05df
 path: /dev/hidraw0
 serial_number: 
 Manufacturer: www.dcttech.com
 Product:      USBRelay4
 Release:      100
 Interface:    0
 Number of Relays = 4
QAAMZ_1=0
QAAMZ_2=0
QAAMZ_3=0
QAAMZ_4=0
 

Using this, I've written scripts like “light_1_on” and “fan_1_off” etc. to turn the ports on and off.  In my case, light_1_on is simply:

#!/bin/bash
usbrelay QAAMZ_3=1 2>/dev/null
 

I also wrote “toggle" scripts that are just slightly more complicated - here's “toggle_light_1”:
 

#!/bin/bash
export PATH=$PATH:$HOME/bin

STATE=usbrelay 2>/dev/null | grep QAAMZ_3 | sed 's/.*=//'
if [[ "$STATE" == "1" ]] ; then
       light_1_off
else
       light_1_on
fi

Using these scripts along with event triggers in Octoprint, the lights in my enclosure automatically turn on at the start of a print.  At the end, the fan turns on.  After 10 minutes the fan turns off and 5 minutes after that the lights turn off.
 

Tagi