BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

How to connect existing project with blynk app?

i have complete program on 1 project but how to implement with blynk??

@hasmie you have’t given us nearly enough information to be able to help you.

What hardware do you have or do you plan to obtain to put your project on Blynk?
What does your project do?

  1. http://www.blynk.cc/getting-started/

  2. http://docs.blynk.cc/ once you have looked through getting started look through the different hardware set ups and work out which one matches your setup.

  3. Forget your project for now and ensure your hardware can connect to Blynk using the examples provided.

  4. Once your hardware can connect to Blynk add your project code into the example you picked at stage 3.

  5. Ensure your loop just contains just the following:

    void loop()
    {
    Blynk.run(); // Initiates Blynk
    timer.run(); // Initiates SimpleTimer
    }

  6. The rest of your code should be called with a Timer (most people use SimpleTimer but there are others available).

  7. If you have problems along the way please provide full details of your hardware setup together with your sketch.

2 Likes

This is a great troubleshooting guide! @Dmitriy - we should include it in the docs

actually, i want to try connect another arduino which it can communicate with other arduino by using this blynk… izzit possible or not??..below i attached how the project would be like…

I can’t follow the small image you provided but with Blynk Arduinos can communicate with other Arduinos. It is covered with the Bridge widget, see http://docs.blynk.cc/#widgets-other-bridge and be sure to look at the sketch that it refers to.

thank you for the information…one more thing…how to communicate between arduino without using blnyk apps installed at smartphone…

There are several options. You could use the NRF 2.4 transmitters (bad idea in wifi enviroment though), use I2C, but that limits cable length or use an “ordinary” TCP protocol, that should be possible too I think.

1 Like

do you have some reference that can guide me…

There are a bunch of tutorials on the internet about that. If you search for I2C link arduino or NRF2.4 Arduino.

This post is in reference of point #6, calling functions of my code with timers.

I have an Ethermega (Freetronics Mega2560 combined with Ethernet Shield), soldered to the Ethermega’s proto area I have a DS3231 chronodot RTC. Also in the circuit is a single DHT22 sensor and together, they are queried with each pass of my loop to control any of 8 relays. My newbie code skills are evident in my sketch, but it compiles and uploads all the same and spins like a top IMO.

That aside, I am able to upload the Arduino Ethernet example and can toggle my relays via BLynk just fine.

Of course I would love to integrate Blynk into my sketch, or as you stated, I can integrate my Sketch into the Blynk example. Without completely hijacking this thread away from the OP’s questions, can I ask for some foundational literature that will help me in my studies? Being a newb, I request to not be inundated with partially related materials as this will frustrate me and make my learning curve all the more difficult to get through. Actually, if it’s possible, is there a theoretical explanation of how to bring the 2 sketches together that depicts the things I need to accomplish so that I can learn the core basics and build upon that understanding?

@myggle I don’t believe what you want currently exists but maybe as you work through the process you can make notes for others to use…

When you strip out the comments in the Blynk examples many of them are only about a dozen lines of code. Some libraries are called, a set up routine mainly for a specific serial interface, some Blynk functions and then a couple of lines of code in the loop.

So when I say add your sketch to the Blynk examples it is normally easier to do it the other way round, subject to one proviso. That being, that you fully understand how you are connecting to Blynk and that it works reliably for you.

Once you have done that transfer the 4 blocks of Blynk code (libraries and definitions, setup, functions and loop) to your existing sketch.

You need to have some understanding of how Blynk works for your sketch to work. I guess the big issue is that is is now an internet based sketch with data streaming all over the world. Your original sketch did not need to consider interaction with other computers as it was a standalone sketch but you do now. This is why timers are so important.

OK scrap the above, I guess you are specifically asking about simple timer rather than adding Blynk to your sketch in general.

Take a look at https://github.com/blynkkk/blynk-library/blob/master/examples/GettingStarted/PushData/PushData.ino#L30 and http://playground.arduino.cc/Code/SimpleTimer

When I’m stuck I go to http://docs.blynk.cc/ and then CTRL F and enter ‘timer’ for example. Make sure you don’t confuse Blynk’s Timer widget with Simple Timer though.

My apologies for lack of efficient communication. I now see that I am wanting a few different things. My studies suggest that Blynk doesn’t work well with delays which is why I am wanting to learn how to use Simple Timers to learn how to use millis() in conjunction with my onboard RTC module as my base sketch often relies on the RTC for planned events. So I want to learn how these 2 different time keepers can work together, or at least not against each other.

More to the point of how this all relates to Blynk, I suppose I need to learn how to code my sketch so that the loop first looks to see if there are any communications from the Blynk server, and if not, proceed through the rest of the loop. So in short, there is the preset routine, but Blynk would provide an override. I suppose there might be too many conflicts, or the code would need to be overly explained to prevent any conflicts that it may defeat the purpose of what (I think) I want.

Just to get my feet into the water though, I would like to access sensor readings via Blynk while my sketch continues to run it’s routine, and I believe that over time I can slowly build the sketch towards my goals. Any insight or study leads will be most appreciated. TYIA

You can have the timers operate indifferently of what Blynk does. There are several options to keep stuff going in case of disconnections or other trouble. BLYNK_CONNECTED() for example. You could even connect Blynk, let’s say, every ten minutes, do changes, sync stuff and disconnect and start a local routine. I’m not sure why, but it probably can be done. For non-time critical stuff it would be great. You could switch on your lights for example. That doesn’t require precision to the second.

A post was split to a new topic: Looking for advise