Things used in this project

Hardware components:
Photon new
Particle Photon
×1
12002 04
Breadboard (generic)
×1
Sparkler
×1
Relay (generic)
Songle SRD 05VDC-SL-C
×1
Crocodile Wires
2 Pieces
×1
Nichrom 80
×1
Jumper Wires with a high resistance to transmit 220V
5 Pieces
×1
Underlay for your desk
optional: before you ruin your workplace
×1
Extinguisher
optional: to save yourself if available
×1

Code

myFanC/C++
v1.0: use a relay to control a second circuit
// MyFan v1.0 - Ingo Lohs - Stand: 06.12.2017 - works with Particle Firmware v0.7.0-rc.3
// mit einem Relay lassen sich weitere Lasten in einem unabhängigen Stromkreis schalten
// Blynk: 1x Button for 200 Energy Points mapped on V3

    /* 
             -----[    ]-----
  Relay VCC -|VIN        3V3|-    
  Relay GND -|GND        RST|-
            -|TX        VBAT|-
            -|RX         GND|- 
            -|WKP         D7|-
            -|DAC         D6|-
            -|A5          D5|-
            -|A4          D4|- Relay IN SIGNAL
            -|A3          D3|-     
            -|A2          D2|-     
            -|A1          D1|- SCL 
            -|A0          D0|- SDA
              \____________/
             
    */

#include <blynk.h>

// Relay is a HIGH LEVEL: action is on HIGH!!! connectet on 3,3V or 5V

    int baudrate = 9600;              // Serial Monitor 
    #define relayPin D4               // SIGNAL from Relay
    #define internalLED D7            // internal Device LED from Spark Core or Particle Photon
  
    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "<<< your blynk code here >>>";
    #define vRelayBtn V3
    unsigned int vRelayStatus; // global var
  
// *********    

    BLYNK_WRITE(vRelayBtn) {     // Blynk app WRITES button status to server
    vRelayStatus = param.asInt();
    if(vRelayStatus == 1){
    digitalWrite(relayPin, HIGH);
    digitalWrite(internalLED, HIGH); // internal LED on
    Serial.println("Relay is now ON");    
    }
    else {
    digitalWrite(relayPin, LOW); 
    digitalWrite(internalLED, LOW); 
    Serial.println("Relay is now OFF");   
    }
    }

// *********  

    void setup() 
    {
      Serial.begin(baudrate); // Serial Debug Console: CMD - particle serial monitor --follow on Windows or MAC: Terminal - ls /dev/tty.* - screen /dev/tty.usbmodem1411
      while(!Serial); //Waiting for Serial connection
      pinMode(relayPin, OUTPUT); //Set pin D4 as an OUTPUT
      pinMode(internalLED, OUTPUT); //Set pin D7 as an OUTPUT
      digitalWrite(relayPin, LOW); // Relay off - no pump at start
      digitalWrite(internalLED, LOW); // internal LED off
      Blynk.begin(auth); // Blynk magic starts here
    }

// *********    

    void loop() 
    {
    Blynk.run();    
    }

Credits

Img 6554 3ywwumwxbh
Ingo Lohs
17 projects • 39 followers
I am well over 40 years and come from the middle of Germany. You can contact me also in German. Donation for projects: paypal.me/ingolohs
Contact
Thanks to danionescu.

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login