BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Upgrade from 1 to blynk 2

Hello all,
I have now played and tested a bit and tried new sketches. So far everything is good.
Now I want to port my running sketches to the new app.
I will add these lines new in the sketch.
#define BLYNK_TEMPLATE_ID
#define BLYNK_DEVICE_NAME
Then I need to create new data streams?
Then create a new template
Then create a new device
And finally create all widgets again in the app.
Is this correct?

Unless you are using the Edgent sketch and it’s associated dynamic provisioning, you also need the Auth token, which is only available once you’ve created the device from t( template.

So, in this case, you would add the three lines of code available in the device view, rather than the two lines of code available in the template view.

Also, you can add, or modify, or add additional datastreams to your template after you’ve created the device, and they will then alu to magically be available or updated on the device itself.
Obviously datastreams need to be added before you can complete the widget setup.

The other thing to look out for is that integer and float datastreams default to having a min value of 0 and a max value of 1.
So, if you’re using Blynk.virtualWrite to push say temperature and humidity values to those datastreams then do data will display in the widgets, because any values that are outside the min/max values are ignored totally.

Pete.

Thankyou checked.
My Device is online and work, now i optimize the App.
I would style a segmentet switch, but i can’t give the 3 option a name or put Text into the field

got it, i uses the wrong widged

did set property work in segmented switch

here is my old code

void Strahler_an_Blynk_senden() {
  if (strahlerStatus) { //Strahler sind an
    Blynk.setProperty(V5, "color", "#0088FF"); //Blau
  } else {
    Blynk.setProperty(V5, "color", "#23C48E"); //Gruen
  }

@uwe please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

did it

It should work, have you tried it?

https://docs.blynk.io/en/blynk.apps/widgets-app#styled-button

Pete.

ok thanks i see the diffrent,
have something else change from the old to the new version of segmented Switch

It’s all very tedious.
Is there a list where you can see what has changed.
Next what i need is the time function that does not work

Is always a good idea to start with the official documentation…

https://docs.blynk.io/en/blynk-1.0-and-2.0-comparison

Pete.

Sorry, I’m starting to get pissed off because nothing is working. Everything has to be painstakingly put together.
This has nothing to do with you Pete.
In another post I got the answer that you only have to insert a few lines in the old code and that was it.

Changing the color at the segmentedswitch does not work.
I have now tried everything, The data is definitely being sent to the V5 every second.
In the app I have set blue as the active color but the color stays green.

setproperty works but with a normal button

  Blynk.setProperty(V5, "onBackColor", "#0088FF");
  Blynk.setProperty(V5, "onColor", "#FF0000");
  Blynk.setProperty(V5, "onColor", "#FF0000");
    Serial.println("Daten gesendet");

Like what ?

to change the color of a segmented switch
the switch is V5

I meant have you tried something like this

Blynk.setProperty(V5, "BackColor", "#0088FF");
Blynk.setProperty(V5, "Color", "#FF0000");

If you’re referring to this comment then I think you may need to re-read what I wrote (bold added to make that easier for you)…

Pete.

Thank you very much, now it works.
This morning I had the same question if something has changed.
I got a link to read.
A look at my posted code and a tip would have saved me a lot of time and trouble.

In the old app I use Notification, email and Real Time Clock.
I read that i have to use Blynk.logEvent if there is more description about it

You can use automation to send notification and emails as well.

https://docs.blynk.io/en/getting-started/events-tutorial#use-blynk.logevent-firmware-api

For that to have worked, we would have needed to know exactly what it is that you were trying to achieve, and that’s something that you omitted to include.

Pete.

In my old code I have the following function to send a mail

void notification() {
  // function to send a mail on SensorAlarm
  if (strcmp(sensorName, sensorNameAlt)) { // compare if old sensor equals new sensor
    String body = String("sensor ") + sensorName + " has on " + (day()) + " " + month() + " " + year() + " at " + (hour()) + ":" + minute() + ":" + second() + " triggered";
    Blynk.email("Sensor Alarm", body); //Send email
    notifyOnButtonPress();
  }
  strcpy(sensorNameAlt, sensorName); // Store old sensor.
  //************ mail end *************
}

Is there an example of how this needs to be done in the new app?