Skip to content

11. Networking and Communications

Group Assignment

Individual assignment

Blynk Examples

/*************************************************************

  Blynk using a LED widget on your phone!

  App dashboard setup:
    LED widget on V1
 *************************************************************/

/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_NAME "ESP32c3"
#define BLYNK_AUTH_TOKEN "ngAjSe5CRlp_grjzXjpsi3K2hjnofWXf"
#define BLYNK_TEMPLATE_ID "TMPL6eNc4GzN2"

#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "staff";
char pass[] = "SRGB2020";
int pinValue = 0;

WidgetLED led1(V0);
const int ledPin = 8; // gpio8 pin on the board 

BLYNK_WRITE(V0)
{
  pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable

  // process received value
}

void setup()
{
  // Debug console
  Serial.begin(115200);
  pinMode(8, OUTPUT);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

}

void loop()
{
  Blynk.run();
  //delay(500);
  //Serial.println(pinValue);
  if (pinValue == 1) {
    digitalWrite (ledPin, HIGH);
  }
  else {
    digitalWrite (ledPin, LOW);
  }
}