Blynk won't Connect (Ethernet w/ SD card)

On Prject 3 running Arduino Mega and Ethernet Shield on a Blynk server.

Blynk does not connect after a new sketch upload unless I cycle the power to the Arduino. Then it starts fine and runs good. I updated all the libraries. It also does not start of I open a Serial Monitor window, this is what I get:

⸮Starting Up
Starting Blynk
[187] Getting IP...
[6471] IP:192.168.1.33
[6472] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.2 on Arduino Mega

[6584] Connecting to blynk-cloud.com:80

It sits there for as long as I have patience.
When I cycle the power it connects and runs normally. It then allows me to open the Serial Monitor once. After that it fails to connect until I cycle the power.

Anyone with an idea where to look?

Let me re-check this HW.
Is anyone running Ethernet Shield with the latest library? Do you face similar problems?

Ok here is what I found. The moment I unplug the micro SD card from the Ethernet Shield Blynk connects.
I can then plug it back in and all works good. The SD Card is used to store some operating parameters so the system wakes uo with the correct running values.
I hope this brings us closer to a solution.

With the Arduino Ethernet/SD shield you can’t access the Ethernet adaptor and the SD card at the same time, so you have to disable one whilst using the other. However, if you disable the Ethernet card then you’ll lose your Blynk connectivity.

Pete.

1 Like

Thanks Pete. Here is my problem. I have 2 projects with identical Mega’s. They have different Ethernet shields on them. The way I use the SD card and Blynk they never access the Ethernet and the SD card at the same time.
The first project have been running for almost 2 years with a local web server that I developed myself. Then I discovered Blynk and deleted the web server and installed Blynk. They have been working together in that configuration for 6 months or more. The second project has similar code with different functionality and equipment attached but working flawlessly,

Then I prepare for project 3 and 4 and now nothing works. So I replaced project one with the new Mega and Ethernet card and it fails. Put the older system back and it works.
I have to now assume that the two Ethernet shields I purchased are bad. This makes it 3 bad in a row - from the same manufacturer.

I will order new (different manufacturer) today and report back what I find.

Herman

I suspect the inherent design of these Ethernet shields is bad to begin with… I literally crushed mine :angry: after many failed attempts to get it to work reliably. Have you considered switching to ESP-01 for WiFi use? I use that on my Mega (Serial1) and it has been rock solid.

Take a look at the main chip on the Ethernet shield under a magnifier and look for solder bridges. If you find any then have a go at removing them by using a chisel-tip soldering iron and wiping away from the chip.

Also, you’re not doing anything silly with allocating the same MAC address to multiple shields are you?

Pete.

I did that as well… problem is there are some that I suspect are meant to be there… as they are on every one I looked at.

I doubt that the manufacturing process would rely on solder bridges between pins, it’s not the easiest way of ensuring consistent results. They’d be more likely to design the circuit board with tracks between the pins that were meant to be shorted.
It may be that some solder bridges are acceptable and won’t result in a QA failure.

Pete.

Many circuits do bridge the solder connections right at the device. And as mentioned… when I checked mine and compared with others, including online views that I could see… the "errors’ where always in the same place :stuck_out_tongue: In fact I think in the end, it was removing the bridges that finally killed it dead.

Besides, the ESP-01 was sooo much cheaper, simpler and more reliable.

The 2 new ones I have have exactly the same solder bridges on the 2 main chips. The one form a different manufacturer have non.
Anybody know what the function is of setting the pins 10 and 4 (or 53) HIGH or LOW. I get conflicting information and is now setting up a test so I can figure out what exactly they mean.
My problem is I am running out of time on this project. Deadline to have it functioning in a week with lots to do in the meantime. Any help will be appreciated.

This might help

https://playground.arduino.cc/Main/ShieldPinUsage

Looks like I finally made it work. With pinselect 4 and 5100 select 10 I found that if I SetUpSdCard() (see below) before Blynk.begin(); the sd card fails to start but Blynk starts fine. Changing the order helped nothing SD card failed so I made a Global called bool SDcard and set it if the card succeeds. Then in the loop every 2 seconds I SetupSdCard(); and it starts the card immediately after the first attempt.
In Setup:

  pinMode(SDCARD_CS,OUTPUT);
  pinMode(W5100_CS,OUTPUT);
  SetupSdCard();
  ReadParameters();  //This one fails in setup()
  Serial.println("Starting Blynk");
  Blynk.begin(auth,"blynk-cloud.com",80,mac);  //Blynk sometimes need 2 attempts to connect.

I have a 2 second timer in the loop() for some useful work so in the timer event:

if(!SDcard){
      SetupSdCard();
      if(SDcard)ReadParameters();  //This one succeeds on first cycle.
}

I do not know why but I am desperate so now I continue. If someone knows why this works let me know please so I can sleep.
Thanks for all the help.

I found that Blynk would disconnect unexpectedly and then does not reconnect.
It gets stuck in this loop: “[5299] Connecting to blynk-cloud.com:80” and repeats this about every 30 seconds or so and never recovers.
I then added the following code to execute every 2 seconds:

   if(!Blynk.connected()){
      Blynk.begin(auth,"blynk-cloud.com",80,mac);
      BlinkRestarts++;
      Blynk.virtualWrite(V18,"Blynk Restarted: "+String(BlinkRestarts)+" Times"); //V18 is where I display special events
   }

Please remember to properly format any pasted code :wink: I fixed all of your posts.

Blynk - FTFC

Thanks I will remember.

I’m more confused than @Gunner is about sports… does it or doesn’t it work? :laughing:

1 Like

With the code above it has been stable for a few days now. Blynk restarted 9 times in the 3 days or so on one system and 2 times on the second and not has yet failed on the 3rd.
The SD card only restarted after the startup failure and has not failed since on all 3 systems. In the fast moving stuff (On/Off status and so on I update Blynk once every 2 seconds. For the slower moving stuff (Temperatures etc) only once every 5 minutes. Hope this helps.

Walk thru the code and comments in this example sketch. I found it helpful to understand the SPI/SD/Ethernet thingy. :slight_smile: