SubNewbie...need help with my first attempt at using Blynk

Senior Citizen (78) here…

NEW to ADUINO Jan 2022;
Using WeMosD1 and my iPhone, I completed so far:

(a) LED sketch…can turn LED on/off from iPhone

(b) SERVO sketch…can control servo angle from 0 to 90deg

© Parola sketch…can type in new message from iPhone

(d) Tried with NO success to access my WeMosD1 from the “internet”… I was able to create a Port Forwarding, however, it appears Spectrum is blocking me from accessing my WeMosD1 board when I type in 192.168.1.223:8080 (they couldn’t help me)
So I gave up on that and would like to use Blynk to control my project(s)

BRAND NEW TO BLYNK…never used it before…hence an extreme NEWBIE here.

For my very first Blynk project I want to simply use Blynk to turn on/off the LED with or without entering my SSID and PASSWORD (as I said above I can do this now with WiFi when at home)

Not sure how to use my current LED sketch (or for that matter, my SERVO sketch) with Blynk ?

FYI. here’s what I’ve done so far;

(a) Uploaded Blynk App on iPhone

(b) Created Blynk account to access Blynk.Community.

© Somehow…luckily…I created a BLYNK_TEMPLATE_ID “TMPLObRM6zc”
BLYNK_DEVICE_NAME “RichiPhone”

(d) I can see this NAME and ID on the Blynk.Cloud/dashboard
(NOT SURE HOW I went from blynk.community to blynk.cloud…)

(e) In blynk.community I clicked on Sketch Builder

That’s as far as I was able to go…
It then needed a token…and I even tried Manual, etc trying to get a token number.

BOTTOM LINE: I am very confused as to how to progress…I was trying to learn and do this on my own…but I guess at 78 that’s not so easy.

Also…Metadata and Datastreams got me stumped.

PS: while on the Arduino forum trying to access via internet, a fella wrote this…which makes me feel Blynk is a good choice for me…he wrote:

“With Blynk, the Wemos establishes a link with Blynk’s servers that allows 2-way communication, rather than an external client requesting an incoming connection, which your ISP might block.”

Thank You, Rich

To get the auth token, go to device info tab

I highly recommend you to read the documentation, there’s a lots of valuable information

There’s an even simpler way that the one that @John93 described.

In @John93’s screenshot, there is a black box on the right hand side that says “Firmware Configuration”. This has the Template ID, Device Name and Auth Token that you can copy.

The SketchBuilder examples then have a place for you to paste this information into the sketch in the correct format…

// 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           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"

Pete.

1 Like

Guys, thank you for your replies ! !
I must be doing something wrong…let me explain:

Pete,
I found firmware configuration and Copied the Code, but when I paste it in a sketch or even pasting it in Word doc, it only has the template Device NAME and the Template ID……it doesn’t have any Token number ? (SEE PHOTO)

John,
I apparently do not have the same screen you have, mine doesn’t have Device Info TAB. (SEE PHOTO)

FYI, as an aside, I did do Files > Examples > Blynk > Blynk.Edgent > Edgent_8266 and when I went to Serial Monitor and pressed wemos Reset button, I got the data shown in the PHOTO. Not sure if this helps or not.

Excuse me, but I can’t see any photos.

You’re looking at the Template screen, not the Device screen.
Go to the spyglass icon at the top left.
If you don’t see a device then you haven’t created one yet - in that case clock the “+ New Device” button and create a device from the template you’ve created.

Pete.

A few tips…

If you want to post the serial monitor data then select the text using the mouse and use CTRL-C to copy it, then paste it into your post with triple backticks at the beginning and end.
Triple backticks look like this:
```

Instead of taking a photo of the screen, use either the Windows Sniping tool, or if you’re using Windows 10 use the Snip & Sketch tool to capture the screen and paste the resulting image into your post.

It appears that you are using the Edgent example sketch, which does not require a device to be created or a an Auth token to be provided.
You add the device from within the mobile app, and provide the WiFi credentials in the app. This process is known as provisioning and allocates a dynamic Auth token.

Pete.

You should update the blynk library to the latest version ( 1.0.1 ) as well.

1 Like

I’m now making some headway thanks to you both !!!

a) I tried Ctrl-C to copy Serial Monitor info…it and it works great. And also thanks for the alternate Snippet approach.

b) I used the spy-glass, and found my DEVICE

c) I clicked on it and then saw the Device Info TAB. Clicked it and the TOKEN id was now listed, which I copied.

d) I also just now UPDATED my Blynk Library to version 1.0.1

e) I ran the Quickstart IDE sketch with the token this time. Compiled and went through perfect. When done I went to Serial Monitor and clicked reset and got the message saying … “Ready” (see bekow).

How do I OPEN this project and turn on/off the LED with Blynk on my iphone.?

FYI, I have Blynk-New app on my iPhone. When I open it (see photo), I can’t seem to find a dashboard or anything that asks me to open a blynk device/project .

Am I using the wrong iPhone App to open my device and control the LED…?

Serial Monitor

[4304] Connected to WiFi
[4305] IP: 192.168.1.223
[4305] ___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v1.0.1 on ESP8266
[4311] Connecting to blynk.cloud:80
[4394] Ready (ping: 35ms)

Check this out

but when you pasted the text into your post, you didn’t use triple backticks, you used different characters instead, so the text didn’t display correctly. If you’re using a UK/US keyboard then it’s the key to the left of the number 1 key, otherwise copy/paste the triple backticks that I provided as an example.

As I said earlier, you are using the Edgent example, which dynamically provisions the auth token, so you don’t need to copy/paste this into your sketch. You can’t mix and match the Edgent dynamic provisioning process with the static provisioning process where you hard-code the auth token and the WiFi credentials into your sketch.

I would delete your device and template then start again, following these instructions step by step.

Pete.

I’m trying to stay organized as best I can and advise as much detail as best I can.

Item (A):

I Created Quickstart Template (from the Instructions) and is shown in the Developer Mode display. I then added ONE button widget (assuming I use that to turn on LED.

And in the device display screen, it shows my Quickstart “Device” which I assume is on-line (?)

Don’t know what to do next on this display ?

I don’t know how to have my Quickstart SKETCH….incorporated into or accessed by Blynk……

I honestly have read the multitude of instructions and think I was doing right……but obviously I’m messing up somewhere.

(and I also created the IDE sketch from the Instructions and inputted my Device Name, ID and token – also added pinMode (D7, OUTPUT) and digitalWrite (D7, HIGH) Uploaded it and it ran without any errors and the LED came on and stayed on.

On YouTube sites it shows people simply clicking on their Blynk app and selecting stuff and turning things on and off. Any suggestions and corrections to what I am doing will be really appreciated. I am real anxious to get my first Blynk program to work.

Item (B):
As an Aside,
I then clicked on ADD a DEVICE and clicked on Connect to WiFi
It said Power on your device……and click Ready. Since my router is ON and my WeMosD1 is ON I then clicked Ready and it said go to iPhone WiFi setting choose your device (my SSID was connected, so I clicked “Already Connected”)

Then it went to “Getting Device Information” and it said “Can’t connect to device”
FYI, my Router and WeMos board and iPhone were all within inches of each other
So I stopped trying to add a device.

I don’t know if this means anything…I have the SAME email address but DIFFERENT passwords on iPhone Blynk App and the Blynk Community

CORRECTION … I didn’t “input” the Device Name, ID and token…it was there already.

The two are totally unconnected.

I’m really struggling to understand what you’re doing, and whether you’re doing this from the web console or from the app.
I find that it’s easier to do it from the web console, as you can then copy/paste the quickstart sketch straight into your Arduino IDE.

I’d recommend that you delete all the existing templates and devices in the web console, and check that they have also been deleted from the app.
Then, do this…

  1. in the web console, click the the “lifebelt” icon (third icon up from the bottom on the left) and choose Quickstart. This will lunch the Quickstart “wizard”

  2. Click “Lets go!” then in the next screen choose ESP8266 and WiFi then click Next

  3. Choose the IDE that you’re using (hopefully that’s Arduino) then click Next

  4. Presumably you’ve already installed the Blynk 1.0.1 library, so you can skip the next step

  5. Type your WiFi SSID and password into the boxes on the left hand side (take care with this, both are case-sensitive). Then, on the right had side iof the screen you have two buttons at the top of the code window, “Copy Code” and “Download as File”. Click the “Copy Code” button.

  6. Navigate to your Arduino IDE and click File > New. Delete the code that the IDE automatically inserts, then paste the code that you’ve just copied from the Blynk web console. Choose the correct board type, port etc, then upload the code to your board. It’s usually a good idea to press the reset button on the board when that is complete, then open the serial monitor.

  7. Go back to the Blynk web console and click the Next button. You should briefly see a “Connecting” animation, then a fireworks animation and the “Go to Device” button should be enabled. When this happens click the button. If it can’t connect then you’ve probably mis-typed your WiFi credentials and if this is the case then correct them in the IDE and re-upload the sketch to your board.

You should now see a web dashboard that looks like this:

and when you go to the app you should see a device called “Quickstart Device” on the main screen, and when you tap that device you should see a mobile dashboard that looks like this:

If you have any problems along the way, refer to the numbered steps above and try to clearly explain what went wrong at which point in the process.

Once you have everything working correctly you can the start to edit the Blynk sketch to change what happens when the On/Off button is pressed. This button is attached to V0, and when its value changes it triggers the BLYNK_WRITE(V0) function in the sketch.

Read this tutorial to learn how to control the GPIO pins on your board when the value of the virtual pin changes…

Pete.

1 Like

Pete,
YOU solved my whole issue. Thank you so very much. First you were 100% right to say “I’m really struggling to understand what you’re doing” especially since I was struggling to understand what I was doing…

OK. FYI here’s what I did:

a) Deleted device and template from web console. You were spot-on target since THIS WAS THE KEY to get back to ground-zero

b) I then meticulously followed every word of your post. Thank you for taking the TIME to do the step by step in such detail.

c) I got all the way through to this part of your post “…and when you go to the app you should see a device called “Quickstart Device” on the main screen”

    • when I went to the app, it didn’t show any device at all, so I clicked on the tripple dot and it said Add a device…well I knew that would be wrong. Then I clicked on the “wrench” and it gave me the screen with “Quickstart Template”…then clicked on it and the rest fell in place…I could see the button, I could go back to the home page and it showed the Quickstart Device box. All was GOOD

d) And now for even MORE GOOD NEWS, I decided to then do what your post said, namely “…Once you have everything working correctly you can then start to edit the Blynk sketch to change what happens when the On/Off button is pressed”

e) I also read your guide about how to use virtual pins, and googled for as much info as I could. I found a webpage and pasted much of it’s code in my sketch; had to add ESP8266 items; bottom line, I finally got the sketch to upload with NO errors, and in the Serial Monitor (pressing reset) I got the Blynk logo and the glad-to-see word “ready”

f) I went to my iphone app and pressed the button and the LED went on/off. And then for the REAL TEST…I went to my iphone settings and SHUT the WiFi. Then went to the Blynk app again…and BINGO…I was able to turn the LED on/off. So this was my very first IoT (truly allowing me to access my wemos board from ANYWHERE in the so-to-speak world…I was thrilled. (ps: I also called my wife from about 3 miles away and then used my iphone to control the led…which she verified)

Sorry for all the details above buy I just wanted to share it all. Also, FYI below is my SKETCH.

One more thing…I noticed a ton of your posts whereby you helped a lot of people who were at an advanced level (or at least appeared to me to be very knowledgeable). That said, thank you for helping a sub-Newbie. I guess at 78, they’re right when they say, you’re never too old to learn (…and I will impress my grandkids with lights going on and off…ha) Thank you, Rich


////  file NAME:   FINAL_2_Quickstart_asORIGconfigured_AFTER_addingBlynkButtonCodes

//// got most button codes from: https://www.hackster.io/rocketman27/led-blink-with-blynk-2-0-e86daa

// 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           "TMPL0DMC7IMm"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "7I8_L1AhIUX3DotowbKFTIWeMWh5FZhU"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>   // I ADDED THIS
#include <BlynkSimpleEsp8266.h>  // I ADDED THIS


#include <SPI.h>

char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "OCEANVIEW";
char pass[] = "RICHARD88";
BlynkTimer timer;
// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0) {
  int pinValue = param.asInt();
  digitalWrite(D7, pinValue);
}
// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}
// This function sends Arduino's uptime every second to Virtual Pin 2.
void setup()
{
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
  pinMode(D7, OUTPUT);
  // Setup a function to be called every second
}
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!
}
1 Like