Introduction: Pushing Date and Time to Blynk App Using Wemos D1 Mini Pro
We will use the Wemos D1 Mini Pro to push the time & date to the Blynk App.
You will not need to connect any components to the Wemos D1 Mini Pro for this activity.
Step 1: Create a Blynk Account
After you download the Blynk App, you’ll need to create a New Blynk account. This account is separate from the accounts used for the Blynk Forums, in case you already have one. We recommend using a real email address because it will simplify things later.
Why do I need to create an account?
An account is needed to save your projects and have access to them from multiple devices from anywhere. It’s also a security measure. You can always set up your own Private Blynk Server (Links to an external site.)Links to an external site. and have full control.
Step 2: Create a New Project
After you’ve successfully logged into your account, start by creating a new project.
Step 3: Name/Board/Conection
Give it a name and select the appropriate board (Wemos D1 Mini). Now click create.
Step 4: Authentication Code
Your Authentication token will be emailed to you and you will also be able to access it in the settings of your project. A new number will be generated for each project you create.
Step 5: Select Widgets
Add Widgets
Your project canvas is empty, let’s add 3 widgets - Two Value Display Widgets and One Real Time Clock Widget. Tap anywhere on the canvas to open the widget box. All the available widgets are located here.
Step 6: Widget Settings
Drag-n-Drop - Tap and hold the Widget to drag it to the new position.
Widget Settings - Each Widget has it’s own settings. Tap on the widget to get to them. Set them up with the following settings.
Note: Select your timezone.
Step 7: Run the Project
When you are done with the Settings - press the PLAY button. This will switch you from EDIT mode to PLAY mode where you can interact with the hardware. While in PLAY mode, you won’t be able to drag or set up new widgets, press STOP and get back to EDIT mode. You will get a message saying “Arduino UNO is offline”. We’ll deal with that in the next section.
Step 8: Arduino Code
Now let’s take a look at the example sketch for a Wemos D1 Mini Pro. Notice there are three key components that you will need to include:
1. char auth[] = ""; Specific to your project (Blynk App).
2. char ssid[] = ""; Specific to the network that we are connecting to (network name). You can "hotspot" from your phone also.
3. char pass[] = ""; Specific to the network we are connecting to (password).
CODE
#define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h><br> #include <TimeLib.h>#include <WidgetRTC.h>
// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = ""; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = ""; char pass[] = ""; BlynkTimer timer; WidgetRTC rtc; String currentTime; String currentDate; void setup() { // Debug console Serial.begin(9600); //pinMode(LED, OUTPUT); Blynk.begin(auth, ssid, pass); // Begin synchronizing time rtc.begin(); // Display digital clock every 10 seconds timer.setInterval(10000L, clockDisplay); } void loop() { Blynk.run(); timer.run(); } void clockDisplay() { // You can call hour(), minute(), ... at any time // Please see Time library examples for details currentTime = String(hour()) + ":" + minute() + ":" + second(); currentDate = String(day()) + " " + month() + " " + year(); Serial.print("Current time: "); Serial.print(currentTime); Serial.print(""); Serial.print(currentDate); Serial.println(); // Send time to the App Blynk.virtualWrite(V1, currentTime); // Send date to the App Blynk.virtualWrite(V2, currentDate); }
Step 9: Check APP to See Results
Go back to the Blynk App and check your diplay. You should see the current date & time.
Note: I have the time set to update every 10 seconds.
Step 10: Video
Note: I have the time set to update every 10 seconds.