Light on/Off

Hello to everyone. Can somebody point me in the right direction. I have 4 Prusa printers (2xMK3s, 1xMK2.5s and 1xMK2.5sMMU2s), each running it's own instance of Repetier server on Raspberry Pi3 B+ with touch screen. Everything is working flawlessly but I can't get light to work. What i am trying to achieve is that i can remotely turn light on and off via raspberry. The available GPIO pin that i am trying to use are GPIO 21 (pin 40) and GPIO 39 (pin 39 as ground) using mos module and white LED strip. The problem is that i don't know how to tell the repetier server witch pins to activate when i send M355 command. I am new in all of this. The information that have found on this forum are:
1. That it can't be done and that i need to do it via Einsy board directly (don't like that solution)
2. That it can be done via externalcommands.xml and some scripts (don't know how to do it, founded externalcommands.xml but don't know what to write in it and don't know how to write scripts for that commands and how to tell the server on what pin is light connected.
I hope it makes sense what i am trying to ask.
Thank you in advance.

Comments

  • Problem solved :D
  • @Patuljasta Do mind sharing what you did to get it to work?  I have just a single MK3s and a MMU2s (to be installed), but trying to do the same with the lights.
  • My solution is to power led strips form external power supply and connect them to raspberry pi trough mos module to free pins ( in my case pin 39 for GND and pin 40/GPIO21 for sending on off signal on raspberry pi 3 b+). Then wrote two scripts, one for turning on lights and one for turning off lights. In extcommands add a two command to execute scripts. From web interface it is working perfect and that is was i needed. I can explain in detail if you want.
  • My solution is to power led strips form external power supply and connect them to raspberry pi trough mos module to free pins ( in my case pin 39 for GND and pin 40/GPIO21 for sending on off signal on raspberry pi 3 b+). Then wrote two scripts, one for turning on lights and one for turning off lights. In extcommands add a two command to execute scripts. From web interface it is working perfect and that is was i needed. I can explain in detail if you want.
    Yes please, loocking to do the same! Thanks

  • @Patuljasta Yea, I could use some more info as well.  I've been searching around so I wouldn't have to ask you absolutely everything, but having trouble figuring out where to start.  I bought a handful of Mos Modules.  I could understand the wiring.  I'm pretty sure I could create and put together functional extcommands.xml files from what others have posted on the forums here, but I cant find where to place the files.  Whether I have to SSH, or edit the sd card in the pi, or if it's online on the repetier-server.local page, etc.

    And i'm guessing once I DO put the extcommands.xml file in the right place, I still have to add something for my particular printer on the repetier server page to call for it?
  • For pi the file is always at /var/lib/Reepetier-Server/database/extcommands.xml

    Login using ssh (W10 has it as well out of the box) and use
    sudo nano /var/lib/Reepetier-Server/database/extcommands.xml
    to edit it. Afterwards server needs to be restarted to read the new file which is hopefully still xml compliant.
  • Sorry for the late answer.
    So, after instaling Repetier server on Raspberry Pi, updating everything and installing display drivers reboot Pi. Once the Pi has booted up, login via Putty or whatever you use to connect via SSH. You need to create two scripts. One for lights on and one for lights off.

    Create script folder:

    sudo mkdir scripts

    Open scripts folder:

    cd scripts

    Create new script file

    sudo nano lights_on.sh

    Write in that file:

    #!/bin/bash
    gpio -g mode 21 out
    gpio -g write 21 1

    Hold ctrl + x, y to save file

    Create second script:

    sudo nano lights_off.sh

    Write in that file:

    #!/bin/bash
    gpio -g mode 21 out
    gpio -g write 21 0

    Hold ctrl + x, y to save file

    Now you need to add command in the extcommands.xml

    Open Repetier database with:

    cd /var/lib/Repetier-Server/database/

    Open extcommands.xml :

    sudo nano extcommands.xml

    After the last command already writen in file add this:

    <command>
            <name>Lights ON</name>
            <execute>bash /home/pi/scripts/lights_on.sh </execute>
        </command>
        <command>
            <name>Lights OFF</name>
            <execute>bash /home/pi/scripts/lights_off.sh </execute>
        </command>

    Hold ctrl + x, when prompted to save hit y and enter.

    Now, about wiring. Pin 39 from Raspberry is going to ground header (-) on MOS module and pin 40/GPIO21 is going on header (+) on MOS module. External 12V is going to terminal connector in and wires from LED strip are going to terminal connector out.Plus on plus and ground on ground.

    If you have the right MOS module that should be it.
    From web interface now you can turn lights on/off.

    If you have situation like me when the MOS module has big voltage drop from 12V power to 8V and the LED strip is working with the half of intensity, my solution is adding a relay to all that. If your LED strip is not working or is working with low intenisty, check the output + and - with the multimeter to see if you have 12V on output. If not, then you need to add a relay.

    Please note, from electronic point of view this solution is far from optimal, but I had these two modules handy, just laying around and I decided to use them for a quick fix rather than solder another board with just the components needed. It works, it was done in 5 minutes and I moved on.

    The mos module i am using is:
    https://www.aliexpress.com/item/4000727363333.html?spm=a2g0o.productlist.0.0.4df8326ajw6mg5&algo_pvid=01499d17-b276-40c4-a4a2-b12995c630b9&algo_expid=01499d17-b276-40c4-a4a2-b12995c630b9-7&btsid=0ab6f83115868495703684016e29e1&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

    And the 12V relay module added is:
    https://www.aliexpress.com/item/4000356150750.html?spm=a2g0o.productlist.0.0.c7d73e7eqhX7nz&algo_pvid=37587626-3fcc-44c8-b142-1483b5a212b3&algo_expid=37587626-3fcc-44c8-b142-1483b5a212b3-0&btsid=0ab6f82315868492426854222e1cab&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

    The wiring is simple.
    First, make a small modification on a relay module, with a piece of wire, connect DC+ and COM terminal connector.
    12V from external power supply is going to DC+ and DC- IN on relay module. Also from DC+ on relay module wire goes to +IN on MOS module terminal connector and from DC- on relay module to -IN on MOS module terminal connector. The signal wire is going from MOS module +OUT to relay module IN. The LED strip is going on relay module NO for +12V power and DC- for ground.

    If everything is connected properly the relay module LED is green and when you click on Lights ON in web interface the LED on MOS module should be also green and LED strip should be working.

    Hope it helps.
  • @Patuljasta
    Thank you so much for taking the time to type this up.  I accidentally put the <command> lines outside of the <config> the first time, but once I corrected that I was able to get power to the LED strip.  I have the same problem as you.  Mine is a 24v LED strip though I originally had hard wired with a switch to the 24v PSU lines at the Einsy board.  Now, going through the mos module it drops down to about 18V on the output, which barely lights the LEDs.  I ordered a 3.3v relay module to use instead.

    Thank you again for the help!
  • edited April 16
    Rwings39 said:
    @Patuljasta
    Thank you so much for taking the time to type this up.  I accidentally put the <command> lines outside of the <config> the first time, but once I corrected that I was able to get power to the LED strip.  I have the same problem as you.  Mine is a 24v LED strip though I originally had hard wired with a switch to the 24v PSU lines at the Einsy board.  Now, going through the mos module it drops down to about 18V on the output, which barely lights the LEDs.  I ordered a 3.3v relay module to use instead.

    Thank you again for the help!

    You are welcome. Happy to help :)
  • И мне поможет спасибо
  • Thank you very much for the help you have described to us because it is also what I am trying to do on my MK3S but I am a beginner on the Pi.
    I regret that the developers of Repetier do not make a simple video of the orders to be placed via Putty SSH and a little more explanation on this subject.
    Your instructions are pretty clear, I hope I can do the same as the one chosen on my MK3S.
    Could you tell us which LED strip you chose and how you attached it to your MK3?
    thank you so much  :)
  • I'll have my own Website (php bc javascript is used -.-) to control 8 relays.
    (Only 4 in Use right now)
    Do you see any chance i can add 8 buttons to your webinterface? Is it opensource?
Sign In or Register to comment.