Manfredk
Published © GPL3+

RF Socket by Phone!

Check the RF sockets with Blynk app!

IntermediateFull instructions provided604
RF Socket by Phone!

Things used in this project

Hardware components

ESP8266 ESP-01
Everything ESP ESP8266 ESP-01
×1
FT323RL FTDI USB 3.3v
×1
RF 433 Mhz module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
USB A to Mini-B Cable
Digilent USB A to Mini-B Cable
×1
RF Socket
I've used RF socket by avidsen (Italy), but any brand should work!
×1

Software apps and online services

Blynk
Blynk

Story

Read more

Code

Untitled file

C/C++
/**********************************************************
  Download latest Blynk library here:
  https://github.com/blynkkk/blynk-library/releases/latest
  
  
       Created: 4th Dec 2017 by Manfredk
     Last Modified: 12th Jan 2018 by Manfredk
*********************************************************
FT232RL to ESP8266:       IMPORTANT: set to 3.3v!!
DTR -> -
RX -> TX
TX -> RX
Vcc -> Vcc & CH_PD & RST
CTS -> - 
GND -> GND & GPIO0
**************************
 Module RF to ESP8266:
 DATA -> GPIO2
 Vcc -> Vcc
 GND -> GND
**********************************************************/

#include <RCSwitch.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial

char auth[] = "tokenByApp"; //token
char ssid[] = "NameWifi";  // Wifi
char pass[] = "Password";  
RCSwitch mySwitch = RCSwitch();
WidgetTerminal terminal(V0); // Virtual Pin  0

void setup() {
  WiFi.persistent(false); // Debug console
  //Serial.begin(9600);   // Baud Rate 9600 (NL)
  mySwitch.enableTransmit(2); //RF on GPIO2
  Blynk.begin(auth, ssid, pass);
  Blynk.connect();
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  terminal.flush(); 
  terminal.println(F("Blynk v" BLYNK_VERSION ": Ready!")); // Version Blynk (v0.5.0)
  terminal.println(F("-------------"));
  terminal.println(F("Hi"));   //Say hi!
  terminal.println(F("What shall we do today?"));
  terminal.flush();
}

BLYNK_WRITE(V0) {
   if (String("Turn on A") == param.asStr()) {    //A ON
    mySwitch.setPulseLength(312); // my wavelength 
    mySwitch.send("000101000100010101010001"); // binary for my A ON socket
    terminal.println("A is ON!");   // 
  } 
  else if (String("Turn off A") == param.asStr()) {      // A OFF
   mySwitch.setPulseLength(313); //optional
   mySwitch.send("000101000100010101010100"); // binary for my A OFF
   terminal.println("A is OFF!");
  }
  else if (String("Turn on B") == param.asStr()) {     // B ON
   mySwitch.setPulseLength(314); //optional
   mySwitch.send("000101000101000101010001"); //B ON
   terminal.println("B is ON!");
 }
  else if (String("Turn off B") == param.asStr()) {     // B OFF
    mySwitch.setPulseLength(313); //optional
    mySwitch.send("000101000101000101010100"); //B OFF
    terminal.println("B is OFF!");
 }
  else if (String("All on") == param.asStr()) {     // A &B ON
    mySwitch.setPulseLength(312); //optional
    mySwitch.send("000101000100010101010001"); // A ON
    mySwitch.setPulseLength(314); //optional
    mySwitch.send("000101000101000101010001"); // B ON
    terminal.println("All is ON!");
 }
 else if (String("All off") == param.asStr()) {     // AB OFF
   mySwitch.setPulseLength(313); //optional
   mySwitch.send("000101000100010101010100"); // A OFF
   mySwitch.send("000101000101000101010100"); // B OFF
   terminal.println("All is turn OFF!");
 }
  else if (String("Hi") == param.asStr()) {
    terminal.println(" Hi lozzi'!");
 }
 else {
    // Risposta 
    terminal.print("You said:");
    terminal.write(param.getBuffer(), param.getLength());
    terminal.println();
    terminal.println("unrecognized command");
  }
  terminal.flush(); //Sta senz pensiè
}

BLYNK_WRITE(1) {  //Pin V1
  if (param.asInt() == 1 ) {    // Button on -> socket on
     mySwitch.setPulseLength(312); //optional
     mySwitch.send("000101000100010101010001"); // Binary A ON
     // or mySwitch.sendTriState("0FF0F0FFFF0F");
     // or mySwitch.switchOn("10010", "10000");
     }
if (param.asInt() == 0) { 
    mySwitch.setPulseLength(313); //optional
    mySwitch.send("000101000100010101010100"); //Button off -> socket OFF (same button)
    }
}
  BLYNK_WRITE(3) {
    if (param.asInt() == 1 ) { //Pin V3
       mySwitch.setPulseLength(314); //optional
       mySwitch.send("000101000101000101010001"); //Binary B ON 
    }
    if (param.asInt() == 0 ) {
       mySwitch.setPulseLength(313); //optional
       mySwitch.send("000101000101000101010100");   //B OFF
    }
}

void loop()
{
  Blynk.run();
  /* You can inject your own code or combine it with other sketches.
     Check other examples on how to communicate with Blynk.
     to avoid delay() function!*/
}

Credits

Manfredk

Manfredk

1 project • 0 followers
Contact

Comments

Add projectSign up / Login