other:other

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
other:other [2024/07/08 07:43] – [Info] formlabother:other [2025/04/18 03:23] (current) – [Products] formlab
Line 174: Line 174:
   * [[https://www.bol.com/be/nl/p/mini-nano-v3-0-atmega328p-microcontroller-bord-voor-arduino/9200000112027528/|Arduino nano]]   * [[https://www.bol.com/be/nl/p/mini-nano-v3-0-atmega328p-microcontroller-bord-voor-arduino/9200000112027528/|Arduino nano]]
   * Radio receiver & transmitter set (433,92Mhz)   * Radio receiver & transmitter set (433,92Mhz)
 +    * Search on Amazon for something like '433MHz RF Wireless Transmitter & Receiver Module Kit for Arduino'
  
 ==== Info ====  ==== Info ==== 
   * [[https://www.instructables.com/Using-an-ESP8266-to-Control-Mains-Sockets-Using-43/|This guide]] used a socket with a different chipset, so this didn't work directly, but it was a good start.   * [[https://www.instructables.com/Using-an-ESP8266-to-Control-Mains-Sockets-Using-43/|This guide]] used a socket with a different chipset, so this didn't work directly, but it was a good start.
 +  * [[https://github.com/vdloo/homelabmanager/blob/master/Documentation/my_power_management.md|This guide]] pointed me to the right library that is compatible with the remote power plug
   * Components   * Components
     * Arduino Nano     * Arduino Nano
Line 198: Line 200:
  
 ==== Steps ==== ==== Steps ====
 +
 +
 +  * Populate breadboard
 +    * Put the **Arduino nano** on a breadboard
 +    * Plug in the **radio receiver** board (the longer one with 4 pins), so that no pins overlap with the Arduino
 +      * Add jumper cables for GND and VCC (use the 5V from the Arduino nano)
 +      * There's 2 pins left in the middle on the receiver board, but I think they're the same. Add a jumper from one of the middle pins to pin 2 on the Arduino
 +    * Plug in the **radio transmitter** board (the square one), so that no pins overlap with other pins
 +      * Connect VCC and Ground
 +      * Add a jumper cable from the middle pin to pin 11 on the Arduino
 +      * Add a cable from the 2 screw terminals of the relay output port of the OpenBuilds Blackbox to the breadboard and connect one lead to +5V and the other to pin 3. From there, also go to GND via a 10Kohm resistor. This is basically a setup for a button / switch
 +  * Pair up the remote to a socket
 +    * Plug in the socket to a power strip
 +    * With the remote, click "on" 4 times to pair. Now the on - off pair on the remote works with the remote socket.
 +  * Install the [[https://github.com/1technophile/NewRemoteSwitch|NewRemoteSwitch]] library
 +  * Run the example project 'showreceived Code' on the Arduino
 +  * Open the Arduino Terminal and press On and Off on the remote
 +  * I got back the following info
 +    * ON-signal:
 +      * Code: 30980307 Period: 250
 +      * unit: 0
 +      * groupBit: 0
 +      * switchType: 1
 +    * OFF-signal
 +      * Code: 30980307 Period: 250
 +      * unit: 0
 +      * groupBit: 0
 +      * switchType: 0
 +  * Open now the example sketch 'Lightshow'
 +    * Change the line: NewRemoteTransmitter transmitter(**123**, 11, 260, 3);\\ to: NewRemoteTransmitter transmitter(**30980307**, 11, 260, 3); <nowiki>// (address, pin, period_microseconds, repeats)</nowiki>
 +      * The big number is the received 'code' data from the remote.
 +    * Also change the lines in the loop to use only these:
 +      * Switch off with: transmitter.sendUnit(0, false);
 +      * Switch on  with: transmitter.sendUnit(0, true);
 +    * Then upload the sketch to the Arduino and try it out. The remote socket should switch every 5 seconds.
 +
 +  * Open the Openbuilds Blackbox and change the Relay Jumper from the M3/M5 command config to the M8 M9 config. The M3 command is already used for setting the servo. See the docs [[https://docs.openbuilds.com/doku.php?id=docs:blackbox-4x:jumper-relay|here]].
 +    * Tested successfully: M8 closes the Relay, M9 opens it. The plotter starts with the relay opened.
 +
 +This is the code I'm using now: 
 +<code c++>
 +/*
 +Plotter auto shutdown 01
 +
 +For the Openbuilds Acro pen plotter.
 +The Gcode sender (Openbuilds Control) will send the following Gcode sequence after finishing a plot:
 +  M8 ; close the relay
 +  G4 P0.2 ; wait 20 MS
 +  M9 ; open the relay
 +
 +The relay is connected with the arduino nano with a cable. This signal can be detected as if it were a button press
 +When the arduino received the 'button press', it transmits a code so the remote power socket will switch off.
 +I'm using the Bounce2 library for debouncing and the NewRemoteTransmitter library for receiving and transmitting the 433Mhz radio remote signals.
 +
 +Formlab
 +08/07/24
 +*/
 +
 +#define BUTTON_PIN 3
 +#define LED_PIN 13
 +
 +// https://github.com/thomasfredericks/Bounce2
 +#include <Bounce2.h>
 +
 +// Create a debouncer instance
 +Bounce2::Button button = Bounce2::Button();
 +
 +// https://github.com/1technophile/NewRemoteSwitch/tree/master
 +#include <NewRemoteTransmitter.h>
 +
 +// Create a transmitter instance
 +NewRemoteTransmitter transmitter(30980307, 11, 260, 3);  // address, pin, period_microseconds, repeats
 +
 +void setup() {
 +  // Button setup
 +  button.attach(BUTTON_PIN, INPUT);  // USE EXTERNAL PULL-UP
 +  button.interval(5);                // (ms)
 +  button.setPressedState(LOW);
 +
 +  // LED setup
 +  pinMode(LED_PIN, OUTPUT);
 +}
 +
 +void loop() {
 +  button.update();
 +  if (button.pressed()) {
 +
 +    shutdown();
 +  }
 +}
 +
 +
 +void shutdown() {
 +  digitalWrite(LED_PIN, HIGH);
 +  delay(100);
 +  digitalWrite(LED_PIN, LOW);
 +  delay(100);
 +  digitalWrite(LED_PIN, HIGH);
 +  delay(100);
 +  digitalWrite(LED_PIN, LOW);
 +  delay(100);
 +  digitalWrite(LED_PIN, HIGH);
 +  delay(100);
 +  digitalWrite(LED_PIN, LOW);
 +  delay(100);
 +
 +  transmitter.sendUnit(0, false); // switch off unit 0
 +}
 +
 +</code>
 +
 +
 +
 +  
  
 ===== Docuwiki troubleshooting ===== ===== Docuwiki troubleshooting =====
  • other/other.1720449824.txt.gz
  • Last modified: 2024/07/08 07:43
  • by formlab