Created
December 7, 2021 15:03
-
-
Save shivasiddharth/2ba2d510891f77547ae9b242f7076c04 to your computer and use it in GitHub Desktop.
Sample sketch for demonstrating ESP connection to Blynk local server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************* | |
Download latest Blynk library here: | |
https://github.com/blynkkk/blynk-library/releases/latest | |
Blynk is a platform with iOS and Android apps to control | |
Arduino, Raspberry Pi and the likes over the Internet. | |
You can easily build graphic interfaces for all your | |
projects by simply dragging and dropping widgets. | |
Downloads, docs, tutorials: http://www.blynk.cc | |
Sketch generator: http://examples.blynk.cc | |
Blynk community: http://community.blynk.cc | |
Follow us: http://www.fb.com/blynkapp | |
http://twitter.com/blynk_app | |
Blynk library is licensed under MIT license | |
This example code is in public domain. | |
************************************************************* | |
Sample sketch to connect ESP device to Local Server | |
*************************************************************/ | |
/* Comment this out to disable prints and save space */ | |
#define BLYNK_PRINT Serial | |
/* Fill-in your Template ID (only if using Blynk.Cloud) */ | |
//#define BLYNK_TEMPLATE_ID "YourTemplateID" | |
#include <ESP8266WiFi.h> | |
#include <BlynkSimpleEsp8266.h> | |
// You should get Auth Token in the Blynk App. | |
// Go to the Project Settings (nut icon). | |
char auth[] = "ENTER YOUR AUTHENTICATION TOKEN HERE"; | |
// Your WiFi credentials. | |
// Set password to "" for open networks. | |
char ssid[] = "ENTER YOUR WIFI SSID HERE"; | |
char pass[] = "ENTER YOUR WIFI PASSWORD HERE"; | |
// This function will be called every time Slider Widget | |
// in Blynk app writes values to the Virtual Pin V1 | |
BLYNK_WRITE(V1) | |
{ | |
// assigning incoming value from pin V1 to a variable | |
int pinValue = param.asInt(); | |
digitalWrite(LED_BUILTIN, pinValue); | |
// process received value | |
} | |
void setup() | |
{ | |
pinMode(LED_BUILTIN, OUTPUT); | |
// Debug console | |
Serial.begin(115200); | |
// Blynk.begin(auth, ssid, pass); | |
// You can also specify server: | |
// Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80); | |
// Change the IP address to match the IP address of your local server | |
Blynk.begin(auth, ssid, pass, IPAddress(192,168,0,5), 8080); | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment