I’ve tried switching On/Off the 5Vdc relay connected to NodeMCU ESP8266 at pins D5 and D7 which are 13 and 14 digital pins. The 2 relays are powered from the same 5Vdc power adaptor as the NodeMCU, so the physical set-up is not an issue. I used the sketch below. I can see the device online. However non of the pins responds to the commands. Tried both V0 and V1 virtual pin set-up at blynk.cloud and digital as well. All libraries updated in Arduino IDE. Not sure if there is a mistake in the code itself.
It could be an issue, depending on your power supply and your relays.
14 & 13 to be more accurate.
I’d start by adding some serial print commands into your BLYNK_WRITE() functions so that you know that they are being triggered, and you can see what values you are getting through on your virtual datastreams.
You might also want to share information about the widgets that you have attached to datastreams V0 and V1, and how you’ve configured these datastreams.
Physical set-up was tested with Blynk Legacy and it worked well.
When I tried Blynk 2.0 set-up and checked Serial Monitor - for some reason resets happen. But I’m not sure why.
Regarding the widgets I have attached the V0 setting. And V1 is similar with the corresponding V1 virtual pin.
Please don’t post screenshots of your serial output,
It’s far better if you copy the text from your serial monitor and paste it between triple backticks, and start with the data that is displayed when you initially boot the device.
Your ping times seem quite long. Which regional server are you connecting to (it tells you this in the app, or the bottom right hand corner of the web console) and which country are you in?
Have you tried disconnecting the relays and powering the device via a god quality USB cable?
Dear Pete,
Thank you for the advice regarding the screenshots.
Power Supply adaptor is 2Amps, should be okay.
As for the USB cable - another 2 USB cables have been tested, same result. Another test to check the cabling was done as following: the IN1 and IN2 wires of the dual relay module were checked by connecting to D1 pin(SCL) of the NodeMCU and this made the relay switch on/off at certain intervals as it is supposed to.
The Legacy Blink was working perfectly even with the old cable.
If this is an issue due to the long ping times in Blynk 2.0 - is there anything that can be done to improve the situation?
Regarding the country - I’m helping people with simple Blink projects from a number of countries, this is just an example from one of the users.
Recently I’ve received a number of requests regarding this issue since a number of users started to test new projects with the new Blynk 2.0 set-up.
Best regards
John
Dear Pete,
Please receive the serial output from the initial device boot.
This is retrieved from the computer of a user who has ‘sgp1’ at the bottom right hand corner of the web dashboard.
Dear Pete,
I think I missed the question “Have you tried disconnecting the relays and powering the device via a god quality USB cable?” - yes, the NodeMCU is disconnected from all modules/sensors.
I have removed all snapshots that have been placed in this topic and used the triple back-ticks as you’ve suggested.
Best regards
John
And now, what you all have been waiting for… (drum roll): Me guessing what’s wrong!
Despite the fact that I don’t have a NodeMCU, relay module or have written a single line of code the last two years, I have some questions (or feedback) for you:
The relays: I don’t have the specs for your particular module, but the markings (SRD-05VDC) suggests it’s a “standard” 5 V product. Even if the module gets 5 V by an external PSU, the voltage from D5/D7 to IN1/IN2 might not be high enough (3.3 V from the NodeMCU). Google gave me answers ranging between 2-3,7 V as a minimum for IN1/IN2 to work.
Multiple power supplies: IN1/IN2 must share the same GND (common ground) as your NodeMCU.
If you don’t like my guesses, listen to @PeteKnight. He knows everything!
Dear Distance,
NodeMCU can control 5Vdc relay without any issues.
The issue here is to keep the connection to blynk cloud server ‘spg1.blynk.cloud’ active. Both Wemos D1 as well as with NodeMCU boards have the connection ‘hang-up’ with the new cloud set-up. As you can see from the serial output above - the connection is reset as soon as the device is connected to the Blynk cloud server.
Hey @distans hope you had a good Christmas - assuming that its’s something you celebrate/tolerate.
Despite @John1’s inability to answer questions and provide the requested information, he is right about these relays - the do work well with 3.3v logic level signals. I think it’s the optocouplers in the circuit that allow them to work this way.
You can often get away with powering them from the same power supply too, although the more relays there are on the board the more current they draw when the coils are energised they will eventually drag the supply voltage down to the point where the processor can’t function and it experiences a brownout.
It’s worse if the coils are energised with a digitalWrite LOW (assuming they are active LOW relays) immediately before the Blynk.begin command, as this increases current draw immediately before the ESP8266 fires-up its WiFi chip, which is also a high current event.
But, @John1 says that he’s tried this with the relays disconnected, so it shouldn’t be an issue anyway.
Except the stuff I don’t know, I just make that up!
Dear Pete,
Merry Christmas!
Please let me know which questions you refer to.
Here is the summary of my answers:
Power Supply adaptor is 2Amps, should be okay for both dual relay module and NodeMCU.
USB cable - another 2 USB cables have been tested, same result.
Disconnected everything from NodeMCU - same result, you could see the result in the serial output in the earlier messages.
Wemos used - same result.
Regional server the NodeMCU is connecting to is the ‘spg1’.
One of my friends (Andy from Chesterfield in UK) suggests that one of the options I could explore is to set-up a simple web-server with ESP32 and a ‘Dynamic IP Adress Code’ if this issue with Blynk.cloud persists.
I’ve mentioned that ping times are long
I’ve asked which country the device is in
I’ve asked which regional server that device is connecting to
You have (eventually, and in a rount-about way, provided one of the two pieces of information I asked for. Do you think that this piece of information makes sense without the other? Do you not realise that geographic location of the device in relation to the geographic location of the server that you’re pinging has an impact on ping times?
I’ve asked you for info regarding your datasterams. You uploaded some screenshots then removed them again.
You didn’t tell me if these are the only datastreams you gave set up, or if these are the only two that you felt like sharing, and you didn’t share a screenshot of the datastreams screen to provide this information either. Do you think that this is helping us to help you?
There are many alternatives to Blynk, but this is probably the last one that I’d choose to implement.
BTW, If you’re ever in Chesterfield on a Thursday you should pop along to the flea market, it’s pretty good.
Dear Pete,
Thank you for your time.
I have removed the snapshots of the ‘web dashboard’ as I thought that only the code snippets are welcomed in the discussion, so I tried to minimize the number of pictures, that’s all it was.
As for the ping times - here is the story: some users have projects in remote locations where the internet slow as it is provided using a cellular data plan which is basically a wifi router with a USB data modem, which in turn could be placed somewhere in a rural area inside the building where the cellular signal is bad. So the Wifi provided by a fiber optic cable in the city could be totally different from what they have, as in this particular case.
I solved the issue in the following way - in the loop part I kept only the following and it worked:
Blynk.run(); command and nothing else. Final code is attached.
We’ve all been working on the assumption that Blynk.run(); was the only thing in your void loop. Why would we assume this? Because that what you posted in your first post in this topic…
So, we’ve been wasting our time trying to help with this issue because you’ve fed us incorrect information.
There are significant issues with this code, but I’m not going to waste any more of my time with you.
Actually this is a part of the issue. I tried to place something like a reconnect function, but then removed it.
Another part is - I removed everything and started the web dashboard from scratch. It could be that this was another part of the puzzle.
No need to waste any time with me, I’m fine with that. I understand that from the ‘height’ of the professional programmer’s standpoint - it is not easy to cope with erroneous code that unexperienced users post here, but it takes time to learn.
However if you mentioned the particular issues in this code - this could help others as well.
Could you please explain in more details.