I have been searching and searching for a simople beginning to end type of tutorial on how to just get Blynk connected with my ESP8266. The only thing I can find is finished products not how they got to that point.
The project that I am working on is using a standalone ESP8266-01 with a DHT22 to get room temps from various places in my house. I already have this connected to thingspeak.com with no issue.
But getting Blynk to just receive a simple form of data seems impossible to me. There is NOTHING anywhere that is just, start with this connect that and you can see data here.
Does anyone have anything like this? Please do not post links on how someone did this with an UNO or a Raspberry Pi. I am looking for the ESP8266 that is it.
Maybe I am reading it incorrectly but the INO file on that only shows how to use the Blynk Lib to connect the ESP to the wifi. Not how they control the LED. It says drag and drop widgets to the Blynk app and set the Pin. Then in the sketch there is nothing in the code that controls the GPIO pins.
Then that thread that you linked is about using the ESP as a shield with a NANO not running the ESP as standalone. The pictures are just the replying person showing it wired up.
Perhaps I just do not understand how to read into these threads but I still do not see a beginning to end tutorial just finished products.
First: BLYNK_WRITE() - this is used where you have a widget, lets say a button on your dashboard and when you press it you want the Arduino to do something:
Eg. Button on the dashboard assigned to pin V10 -> in the code something like
BLYNK_WRITE(10) { //Note the Pin number here that i'm "reading" from the application
int a = param.asInt(); //Determine the state of the button, either 1 or 0
if (a == 0) {
bridge5.digitalWrite(5, LOW); //Here I'm sending the LOW via "DigitalWrite" to an alternate device's (Named bridge5, Look into the bridge function) pin D5
} else {
bridge5.digitalWrite(5, HIGH); //Here I'm sending the HIGH via "DigitalWrite" to an alternate device's pin D5
}
The second is virtualWrite:
Blynk.virtualWrite(23, temp); //This sends the value store in the var called "temp" to pin 23 in the dashboard, this is being done in a function called by the timer every 10 seconds to send the temperature to a display widget
Maybe a third thing, Blynk automatically controls digital pins, i.e if you put a button on your dashboard and assign it to D13 (Assuming your Arduino has a built in LED on PIN 13) you don’t need anything more in your code.
Bit of messing around with a few devices on a table and you will be surprised on the number of things Blynk can do,
I have 4 devices currently deployed around the house to open / close and turn things on / off, still on the workbench is the ESP8266 (via a Nano) that is sending Temp and Humidity data to the application dashboard as well as a second ESP8266-EVB with an OLED screen attached.
Waiting now for Apple to approve the update so we can get a few additional functions to test.
What actually you need? Read sensor data or switch GPIOs ON/OFF ?
Next, have you successfully compiled Blynk on your ESP8266 ever?
If you need switching GPIOs - then no code is needed. Just connect an LED to the GPIO, Open app, select this GPIO in PIN field. Press PLAY - it should work.
So if I am controlling the state of a GPIO pin Blynk will handle that control but if I am reading data from a module I will have to write the data to the virtual pin?
You can read data directly from the Analog Pin without any code: choose input widget (Graph, Gauge, Value Display…), set the PIN, set the frequency of requests (how often data should be refreshed) and you are done.
But DHT22 sensor is an I2C device, so Blynk can’t read data from it directly. This means you have to:
get this data on your own (using a DHT library or by writing your code - we don’t care)
somehow push this data to the Blynk app. And here is why you need to use Virtual Pins - they are designed specifically for such cases.
Take a look at this example and read all the comments carefully. Especially about the timer. Don’t pay attention that this is Arduino example and that it’s about Ethernet. After establishing Internet connection, Blynk works the same on every platform.
I agree with Pavel here. You see the reason i made the step by step tutorial is because beginners like me easily give up when things don’t go our way. I believe tinkering is a learning process. And yeah read comments carefully, there are usually some changes required that must be adjusted either on the ino sketch or app end.
Maybe when Im free I going to make a video tutorial! You must see to believe. The feeling I got when I finally managed to switch the LED over the net cannot be expressed in words.
Well to be honest programming micro controllers with Arduino is fairly easy but you need to be committed to it. Also for me it was a lot easier when i started because I had programming background mainly in C and C++ so all I had to do was to understand electronics better. It gets tricky when you get to real micro controller programming (assembly or in better case C however operating pins directly here by using registers.) Honestly all you need at the beginning is understand electronics how basic things work and learn C. But you have to be committed and focused on your project. If you know your goal then write an algorithm on pice of paper or in your head that has to be followed then implement it in Arduino IDE or whatever you want.
Always remember to implement failsafe functions, think of human mistakes when operating your hardware and of program mistakes, as an example my irrigation system is controlled by Blynk and also some scripts. It’s designed in a way that even when internet connection drops the system still can work because tasks are executed based on current time and stuff like that. However once when connection dropped in a middle of me setting timer after 7 hours or so when i wake up the water was still turned on and hundred liters of water were wasted because of one stupid mistake: I opened valves, but in the middle of programming timer the internet connection dropped and arduino had no idea it should turn off valves after 30 min. This is just one of hundreds examples of how important it is to carefully write code and think through your idea and algorithm.
However this is a lot of fun and its rewarding when you actually see your stuff working so trust me it’s worth spending hours.
I really appreciate all the help you have all provided. Last night I was able to get my Raspberry Pi up and running controlling 3 LEDs as a test via the application and today I was able to get the ESP and DHT to send over the temp correctly.
Here you can find a complete ESP8266 Blynk Example. If you are not familiar with ESP modules I recommend you this thorough ESP8266 Arduino Tutorial, a complete review with many example and everything you need to know.
I don’t see the problem, this subject is still hot, and also 1st google page, so many people will still bump into it. It helped me, hopefully will help others too.
Bumping old threads with a nice little helpful note is not a good idea.
These people had issues when ESP’s were not very popular or well supported. Blynk and general knowledge of ESP’s has come a long way and there are also Official Blynk examples (with ESP) to follow now.