Getting Started with the new Blynk IoT platform using Maker UNO

Introduction

The Blynk app is a very popular IoT platform. About mid-year, Blynk introduced a new Blynk platform, and for this tutorial we will try to explore it.

Part 1 – Template and Device Setup

Hardware Preparation

This is the list of items used in the tutorial.

Part 2: Control the LED using Arduino

Sample Program

This is Arduino sample program. You may need to install Blynk library from Library Manager.


/*
[blynk.io] Part 2 – Control the LED using Arduino
Board:
– Maker UNO
https://my.cytron.io/p-maker-uno-simplifying-arduino-for-education?tracking=idris
– Arduino Grove Sensor Kit for Beginner
https://my.cytron.io/p-arduino-grove-sensor-kit-for-beginner?tracking=idris
– Cytron ESP8266 WiFi Shield
https://my.cytron.io/p-cytron-esp8266-wifi-shield?tracking=idris
Library:
– Blynk V1.0.1
Blynk Documentation:
– https://docs.blynk.io/en/
Last Modified: 31 Oct 2021
*/
/* 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 <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
// Hardware Serial on Mega, Leonardo, Micro…
//#define EspSerial Serial1
// or Software Serial on Uno, Nano…
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(8, 9); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
#define LED 6
ESP8266 wifi(&EspSerial);
BLYNK_WRITE(V0)
{
int pinValue = param.asInt();
digitalWrite(LED, pinValue);
}
void setup()
{
pinMode(LED, OUTPUT);
// Debug console
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
}
void loop()
{
Blynk.run();
}

view raw

UnoBlynkLED.ino

hosted with ❤ by GitHub

Part 3: Display the Sensor Reading using Arduino

Sample Program

This is Arduino sample program. You may need to install Blynk library from Library Manager.


/*
[blynk.io] Part 3 – Display sensor reading using Arduino
Board:
– Maker UNO
https://my.cytron.io/p-maker-uno-simplifying-arduino-for-education?tracking=idris
– Arduino Grove Sensor Kit for Beginner
https://my.cytron.io/p-arduino-grove-sensor-kit-for-beginner?tracking=idris
– Cytron ESP8266 WiFi Shield
https://my.cytron.io/p-cytron-esp8266-wifi-shield?tracking=idris
Library:
– Blynk V1.0.1
Blynk Documentation:
– https://docs.blynk.io/en/
Last Modified: 7 Nov 2021
*/
/* 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 <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
BlynkTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
// or Software Serial on Uno, Nano…
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(8, 9); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
#define LED 6
#define LIGHT A3
ESP8266 wifi(&EspSerial);
long prevMillis = 0;
int interval = 1000;
BLYNK_WRITE(V0)
{
int pinValue = param.asInt();
digitalWrite(LED, pinValue);
}
// This function sends Arduino's up time every second to Virtual Pin (1).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
int light_adc = analogRead(LIGHT);
Serial.println("Light ADC: " + String(light_adc));
Blynk.virtualWrite(V1, light_adc);
}
void setup()
{
pinMode(LIGHT, INPUT);
pinMode(LED, OUTPUT);
// Debug console
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}

Part 4 – Mobile Dashboard Setup

Part 5 – Sending Notification

Sample Program

This is Arduino sample program. You may need to install Blynk library from Library Manager.


/*
[blynk.io] Part 5 – Log Event and Notification
Board:
– Maker UNO
https://my.cytron.io/p-maker-uno-simplifying-arduino-for-education?tracking=idris
– Arduino Grove Sensor Kit for Beginner
https://my.cytron.io/p-arduino-grove-sensor-kit-for-beginner?tracking=idris
– Cytron ESP8266 WiFi Shield
https://my.cytron.io/p-cytron-esp8266-wifi-shield?tracking=idris
Library:
– Blynk V1.0.1
Blynk Documentation:
– https://docs.blynk.io/en/
Last Modified: 14 Nov 2021
*/
/* 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 <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
BlynkTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
// or Software Serial on Uno, Nano…
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(8, 9); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
#define LED 6
#define LIGHT A3
ESP8266 wifi(&EspSerial);
long prevMillis = 0;
int interval = 1000;
bool eventTrigger = false;
BLYNK_WRITE(V0)
{
int pinValue = param.asInt();
digitalWrite(LED, pinValue);
}
// This function sends Arduino's up time every second to Virtual Pin (1).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
int light_adc = analogRead(LIGHT);
Serial.println("Light ADC: " + String(light_adc));
Blynk.virtualWrite(V1, light_adc);
if (light_adc < 100 &&
eventTrigger == false) {
eventTrigger = true;
Blynk.logEvent("LIGHT", "Light ADC is less than 100");
}
else if (light_adc > 300) {
eventTrigger = false;
}
}
void setup()
{
pinMode(LIGHT, INPUT);
pinMode(LED, OUTPUT);
// Debug console
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}

Thank You

References:

Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for a better application.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Is it possible to program Maker UNO with Python?
Camera and DSI Driver on the Latest Raspberry Pi Bullseye OS
Remote Control ZOOM:BIT using Grove 8266 WiFi and Blynk
Icon Case with Heatsinks & Fan Stressberry Test
Low Profile Aluminum Case Stressberry Test
Tutorials of Cytron Technologies Scroll to Top