Add wifi capabilities to Arduino Mega 2560 for OTA software updates?

Okay, so the OTA updates using the "upload sketch using programmer" method are working pretty consistently! However, I am noticing that for some reason every time I perform an OTA update I need to cycle power to the project if I want to do another one because the WiFi chip seems to not turn back on or connect after an OTA update has been performed. Is this normal? What can i do, if anything, to prevent this from happening?

the shield connects reset of the WiFi module to a pin of Arduino. is this connection good? you could try activate this reset in your sketch by setting the pin as output and setting it to HIGH after a millisecond

1 Like

This actually worked, thanks so much! Before I had the enable (EN) pin of the breakout board wired directly to 5V so the chip would always be on, but now I changed it so that EN is connected to a digital I/O pin instead, and in setup() I set it to LOW and then HIGH right away to manually 'reset' the WiFi chip. This works well and I was able to successfully perform 5 OTA updates in a row without cycling power or unplugging my project!

I would expect the WiFi101 library to do the reset. If it was not wired, then try now without doing reset in sketch

Hello @Juraj, here is an update on how the ArduinoOTA library has been working for me, and I need some help. When I perform an OTA update while connected to my PC via USB, it works flawlessly, and the board even resets itself so I can perform updates again and again! However, my project is not meant to be connected to my pc but rather a separate device powered by a wall adapter, and when my pc and the project are completely separate from each other, no USB cable, I have 1 problem. The OTA update still works and the code on the arduino is successfully updated, but only after I manually cycle power to the project. The update is successful, and I get this message:

Connecting to board ... done
Uploading sketch ... done
Flashing sketch ... done
OK
Sketch uploaded successfully

But then the Arduino seems to freeze, it does nothing until I unplug the power and plug it back in, and then it starts up with the new, updated code. Ideally though it should restart itself after an update, even when it is completely wireless from my pc. Why isn't it doing that even though it does reset itself when connected to my pc with USB? Thanks for your help!

I guess it is the powering which can't supply enough current at startup. how did you solve resetting of the shield?

1 Like

@Juraj The project seems to be powered just fine, issues only arise after an OTA sketch upload is completed. I am powering my project with a 9V 1A wall adapter that plugs into the DC input jack on the Arduino. This should provide enough power and my project functions well, except after an OTA update when the Arduino freezes and power must be cycled to it. I am doubtful that it is a power issue, it seems more like the Arduino receives a command to restart when connected to the pc but not when it is wirelessly updated? When I "upload sketch using programmer" while my projected is connected to my pc it restarts fine, but when it is not connected to the pc the update still works, but the Arduino freezes and does not restart itself.

did you try to power it with USB wall socket adapter (phone charger)?

That's a good point, I will test this and get back to you with the results.

Sorry, I have been busy, but I will definitely test this next week and get back to you with the results.

Hello @Juraj, I just tested your suggestion of power the device with a USB wall socket adapter, and... it worked! So I guess then it was either an issue of not having enough power to reset or maybe the Arduino can only reset itself when powered through the USB port for some weird reason? Here are the specifications of the two power adapters I've used:

DC Barrel Jack
9V * 1A = 9 Watt
DIDNT WORK

USB Wall Socket Adapter
5.2V * 2.4A = 12.48 Watt
WORKED!

So I guess the wall socket adapter did have more power than the original power adapter I used.

I also tried a different 5V * 1A = 5 Watt USB Wall Socket Adapter, and this one did NOT work! So in my mind this confirms your theory that the Arduino was not resetting because it couldn't pull enough current from the power supply.

I guess I will order a new DC Barrel Jack Wall Adapter with higher current draw and test it with that.

@Juraj What do you use to power your projects that use ArduinoOTA?

I guess your problem is related with the WiFi shield's boot consumption. I use Ethernet.
I tested the WiFi101 shield only on USB power.

1 Like

Yeah, you're probably right, I must not be supplying enough current for the Arduino MEGA and Wi-Fi shield to both reboot themselves. I started looking into ordering a new power supply for my project, but got kind of stuck on the question of whether the USB port can pull more current than the barrel jack or not. I don't know if I can just use a DC barrel jack power adapter with a higher current draw, or if I need to switch to powering my project via the USB port.

Sorry to nitpick, but using the terminology wrong is like fingernails on the blackboard to me.

The current draw will be exactly the same whether you have a 100 Watt or a 1,000 Watt power supply. Your Arduino and attached devices only draw the current they need. Not one microwatt more.

Yes, except not necessarily because if the devices are unable to draw the current they need (which seems to be the case), then a higher amperage power supply would allow them to draw more current, right?

What I am wondering is if the USB port has a higher MAX current draw than the DC barrel jack

Neither the USB port or the barrel jack draw power. Their internal resistance is so close to zero ohms that they consume practically no power.

I am guessing that you are asking which port provides more available power to the board and downstream devices.

The USB spec says 500mA, and on the Arduino board there is a 500mA fuse on the power line from the USB connector.

The power into the barrel jack goes first through a diode, then into a 5V regulator that is rated at 800mA. The diode is rated at 1A

Yes, that is what I am asking. So theoretically the DC barrel jack can provide more power to the board than the USB port? But neither can provide over 1A? That seems weird considering that I was using a 1A barrel jack power supply, but the board only reset with USB power, which theoretically would have had less current available (500 mA).

Maybe my issue isn't power-related then? Maybe there's just something weird about the barrel jack that is making it so the board and wifi shield can't reset themselves, and I have to power my project over USB instead?