Help with old simple blynk project

Hello All,

Many, many, many moons ago I created a blynk app to open my gate. I used a arduino uno to switch digital pin 4 wo which I connected a remote control. I used Teleduino to access the URL to call this action. This has been running for many years untill today.

I found out I had to upgrade but I really have no idea what I have done. My old Blynk code is below and I hope somebody can help to get it running again on the new platform.

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
int ledPin1 = 4; // Switch D4 = Poort
int ledPin2 = 5; // Switch D5 = Zwembad Open
int ledPin3 = 6; // Swicth D6 = Zwembad Dicht
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "MyToken";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);
  // You can also specify server.
  // For more options, see Transports/Advanced/CustomEthernet example
  //Blynk.begin(auth, "server.org", 8442);
  //Blynk.begin(auth, IPAddress(172,1,16,200), 8888);
}

void loop()
{
  Blynk.run();
 // Check de Poort Switch
    if (digitalRead(ledPin1) == 1) {
    delay (1000);
    digitalWrite(ledPin1, 0);
  }
 // Check de Zwembad Open Switch
if (digitalRead(ledPin2) == 1) {
   delay (1000);
   digitalWrite(ledPin2, 0);
}
// Check de Zwembad Dicht Switch
 if (digitalRead(ledPin3) == 1) {
    delay (1000);
    digitalWrite(ledPin3, 0);
 }
     
   }

Any help is really appreciated!

Thanks in advance,

Joost

Hey there,

Read this
https://docs.blynk.io/en/blynk-1.0-and-2.0-comparison/migrate-from-1.0-to-2.0

and this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

to be honest I just copied en pasted my previous project code so this is too much for me…
I am no programmer.

Okay buddy, just check the links

I did…

So what’s the problem ?
All you have to do is update the library to the latest version and Add BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME on top of your sketch, before anything, and clean the void loop.
The ideal blynk void loop should look like this

void loop()
{
Blynk.run();
}

something like this ?

// 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           "MyTemplate"
#define BLYNK_DEVICE_NAME           "Poort Opener"
#define BLYNK_AUTH_TOKEN            "MyToken"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG        // Optional, this enables more detailed prints

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

char auth[] = BLYNK_AUTH_TOKEN;

int ledPin1 = 4; // Switch D4 = Poort
int ledPin2 = 5; // Switch D5 = Zwembad Open
int ledPin3 = 6; // Swicth D6 = Zwembad Dicht

BlynkTimer timer; // Announcing the timer

#define W5100_CS  10
#define SDCARD_CS 4



void setup()
{
 timer.setInterval(1000L, PinDataSend); //timer will run every sec 
}

void PinDataSend()
{
   // Check de Poort Switch
    if (digitalRead(ledPin1) == 1) {
    delay (1000);
    digitalWrite(ledPin1, 0);
  }
 // Check de Zwembad Open Switch
if (digitalRead(ledPin2) == 1) {
   delay (1000);
   digitalWrite(ledPin2, 0);
}
// Check de Zwembad Dicht Switch
 if (digitalRead(ledPin3) == 1) {
    delay (1000);
    digitalWrite(ledPin3, 0);
 }
}


void loop()
{
  Blynk.run();
  timer.run();        // run timer every second
     
   }

But how do I get my app to do something ?

I’m not aware of anything that has changed today that would stop your old project from working.
Yes, the Legacy version of Blynk will be retired at some point, but that hasn’t happened yet.

The most likely cause of it not working is a hardware failure, or some other change outside of Blynk.

Before you do anything, you should investigate why your old project/hardware has failed and fix that.

Pete.

Oh my I am so stupid! Thanks @PeteKnight my old code is indeed still working.

I think I jumped to conclusion probably had an internet hiccup. If it doenst work I use my blynk app to check but that did not work anymore (never used it on this iphone). I read there was a new app + platform so concluded that must be it…

How long will this continue to work ? Is it wise to try to port it to the new platform ?

Thanks,

Joost

No estimated date.

Definitely yes

Your current code is badly structured and your app uses digital pins rather than virtual pins.
You should change over to using virtual pins when you migrate to Blynk IoT.

Pete.

1 Like

@PeteKnight I tried following your guide, as my project basically the same, I want to set Pin 4 of my board to 0 when you press a button. How hard can it be :slight_smile:

I get the error: error: ‘param’ was not declared in this scope

Can you maybe show me the full code from you example ? What am I missing ?

Thanks

Post your code, along with the error message.

Pete.