Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************************
- You’ll need:
- - Blynk IoT app (download from App Store or Google Play)
- - ESP32 board
- - Decide how to connect to Blynk
- (USB, Ethernet, Wi-Fi, Bluetooth, ...)
- There is a bunch of great example sketches included to show you how to get
- started. Think of them as LEGO bricks and combine them as you wish.
- For example, take the Ethernet Shield sketch and combine it with the
- Servo example, or choose a USB sketch and add a code from SendData
- example.
- *************************************************************/
- // Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
- // See the Device Info tab, or Template settings
- #define BLYNK_TEMPLATE_ID "TMPLDTK7VdBa"
- #define BLYNK_DEVICE_NAME "Quickstart Template"
- #define BLYNK_AUTH_TOKEN "XPz_Xh-4UZCPlTw4kMsyWSAYFyP-Egli"
- // Comment this out to disable prints and save space
- #define BLYNK_PRINT Serial
- #include <WiFi.h>
- #include <WiFiClient.h>
- #include <BlynkSimpleEsp32.h>
- char auth[] = BLYNK_AUTH_TOKEN;
- long randNumber;
- // Your WiFi credentials.
- // Set password to "" for open networks.
- char ssid[] = "hideyowifi";
- char pass[] = "hideyokids";
- /* ------------ */
- BlynkTimer timer;
- BLYNK_WRITE(V6) {
- int pinValue = param.asInt();
- Serial.print("Vi fikk endring på: ");
- Serial.println(pinValue);
- }
- void myTimedEvent() {
- int _data = random(0, 255);
- Serial.print("Sender ");
- Serial.print(_data);
- Serial.println(" til Blynk");
- Blynk.virtualWrite(V7, _data);
- }
- /* ------------ */
- void setup()
- {
- // Debug console
- Serial.begin(115200);
- randomSeed(analogRead(0));
- Blynk.begin(auth, ssid, pass);
- timer.setInterval(1000UL, myTimedEvent);
- // You can also specify server:
- //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
- //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
- }
- void loop()
- {
- Blynk.run();
- timer.run();
- // You can inject your own code or combine it with other sketches.
- // Check other examples on how to communicate with Blynk. Remember
- // to avoid delay() function!
- }
Advertisement
Add Comment
Please, Sign In to add comment