giorgio235
Published

Smart Voltage Unit for projects

Using an arduino uno to make a computer power supply your new best friend for your projects.

BeginnerWork in progress500
Smart Voltage Unit for projects

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Relay (generic)
×1
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
×2
Resistor 330 ohm
Resistor 330 ohm
×2
USB-A to B Cable
USB-A to B Cable
×1
Myka Alimentatore per Case ATX PW-B500 500W Ventola 12cm 3X Sata 1x IDE Tasto On/off Bulk
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×10

Software apps and online services

BLE scanner

Hand tools and fabrication machines

Soldering Station, 110 V
Soldering Station, 110 V
This is not mandatory but makes everything better

Story

Read more

Schematics

Schematic of the circuit

The computer power supply provides a wire (purple one) that is constantly at 5V. This channel, with a ground wire, can be soldered into a usb-b cable to power the arduino (solder purple from power supply to red of usb-b cable and then black to black).
In order to fire on the rest of the power supply channels the green wire from the power supply must be connected to a ground wire. This is done with a relay that is driven by the arduino.
The button on the left turns on the power supply while the one on the right turns it off.
If you are unsure what the wires from the power supply are: https://superuser.com/questions/590510/motherboard-will-not-boot

App made with MIT AppInventor 2 for commanding the device

Code

Buttons for power supply

Arduino
Just a simple code to turn on and off the power supply with a single button. It also uses the HM-10 BLE module interfaced with an app made via MIT AppInventor2.
//  Arduino, HM-10, App Inventor 2
//
//  Example Project Part 2: Turn an LED on and off 2 way control 01
//  By Martyn Currey. www.martyncurrey.com
//
//  Pins
//  BT VCC to Arduino 5V out. 
//  BT GND to GND
//  Arduino D8 (ASS RX) - BT TX no need voltage divider 
//  Arduino D9 (ASS TX) - BT RX through a voltage divider
//  Arduino D2 - Resistor + LED
//  Arduino D3 - 10K pull down resistor + button switch


// AltSoftSerial uses D9 for TX and D8 for RX. While using AltSoftSerial D10 cannot be used for PWM.
// Remember to use a voltage divider on the Arduino TX pin / Bluetooth RX pin
// Download from https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
#include <SoftwareSerial.h>
SoftwareSerial ASSserial(8,9);

// Constants for hardware
const byte Relay_Pin = 12;
const byte SwitchPin = 3;

// general variables
boolean Relay_State = false;
boolean switch_State = false;
boolean oldswitch_State = false;

bool first = true;

char c=' ';


void setup()  
{
    Serial.begin(9600);
    Serial.print("Sketch:   ");   Serial.println(__FILE__);
    Serial.print("Uploaded: ");   Serial.println(__DATE__);
    Serial.println(" ");
     
    ASSserial.begin(9600); 
    Serial.println("AltSoftSerial started at 9600"); 
    Serial.println(" ");

    pinMode(Relay_Pin, OUTPUT); 
    digitalWrite(Relay_Pin,LOW);

    pinMode(SwitchPin, INPUT); 
          
} // void setup()
 
 
void loop()  
{
  checkSwitch();
  checkRecievedData();
}


void checkSwitch()
{
     // Simple toggle switch function with even simpler debounce.
     boolean state1 = digitalRead(SwitchPin);
     delay(1);
     boolean state2 = digitalRead(SwitchPin);
     delay(1);
     boolean state3 = digitalRead(SwitchPin); 
     
     if ((state1 == state2) && (state1==state3)){ 
          switch_State = state1;  
         
          if ( (switch_State == HIGH) && (oldswitch_State == LOW) ){
               // toggle Relay_State.
               Relay_State = ! Relay_State;  
               // If Relay_State is HIGH then LED needs to be turned on.
               if ( Relay_State == HIGH) 
               {  
                    if(!first){
                      digitalWrite(Relay_Pin,HIGH);   // turn on the Relay
                      ASSserial.print("1");       // tell the app the Relay is now on
                      Serial.println("Sent - 1");
                    }else{
                      first=false;
                    }
               }
                                           
               else                     
               {  
                   digitalWrite(Relay_Pin,LOW);    // turn off the Relay
                   ASSserial.print("0");        // tell the app the Relay is now off
                   Serial.println("Sent - 0");    
               }    
          }          
          
          oldswitch_State = switch_State;
      }
}


void checkRecievedData()
{
     // Read from the Bluetooth module and turn the LED on and off
    if (ASSserial.available())
    {
        c = ASSserial.read();
        Serial.println(c);
 
        // The ascii code for 0 is dec 48
        // The ascii code for 1 is dec 49
        if ( c== '0') { digitalWrite(Relay_Pin, LOW);     Relay_State = LOW;}
        if ( c== '1') { digitalWrite(Relay_Pin, HIGH);    Relay_State = HIGH; first=false;}
    }
}

SMARTVOLTAGER.aia

Python
MIT AppInventor2 app for commanding the device
No preview (download only).

Credits

giorgio235
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.