2
\$\begingroup\$

I am trying to use the WiFly shield ( http://www.sparkfun.com/commerce/product_info.php?products_id=9367) with Aduino Mega board.

I am making modifications to the built in examples that ship with the WiFly. I have modified the sketch to make an http request to my personal server.

When I run the sketch through the USB port attached to my laptop, everything works fine. I can see the requests arriving at my remote machine.

When I try to run the board independently using batteries, I run into issues. Basically, the code in the "setup()" doesn't seem to be running. If I do a reset on the board by pressing and holding the push button on the Arduino Mega board, it also works fine. This proves that there is no error in the Sketch or back end server and that the hardware is also not broken.

So basically, when I start up the board via the first start up from a battery power source, it doesn't work. But subsequently resetting of the board using the power button on the mega seems to work.

Does anyone know why this is caused and how I can start running my sketch as soon as the battery pack is turned on (rather than having to do a subsequent reset?)

I had a look at the Arduino trouble shooting guide here http://arduino.cc/en/Guide/Troubleshooting2 and tried connecting the RX pin to the TX pin as well as connecting the Rx pin to GND via a 10k resistor. This doesn't help either.

Edit

I am running the sample WiFly sketch provided by Sparkfun from here. I changed the URL in the sketch from google.com to myserver.com and it works fine when running via USB connection to the laptop or after a reset. I have since added a 2000ms delay as suggested in the answer by kmort and that seems to work fine now. So it would seem there are "settling down issues" with the shield.

\$\endgroup\$
  • 2
    \$\begingroup\$ Could you share the code with us? It's hard to tell what's wrong without it. Maybe there are calls in setup() that are returning errors that are being ignored. \$\endgroup\$ – Ricardo Jan 9 '14 at 14:58
  • \$\begingroup\$ Put some LED toggle in before the Ethernet initialization and do you get them before the lockup? With and or without the shield. Does normal (blink.ino) work off of battery, correctly? With and or without the Ethernet Shield attached. \$\endgroup\$ – mpflaga Jan 9 '14 at 19:03
  • \$\begingroup\$ Updated the question accordingly. \$\endgroup\$ – Chaitanya Jan 11 '14 at 6:47
  • \$\begingroup\$ Any proper library for that shield should have an initialization function that waits for the thing to boot up and then returns a code indicating the ready state of the device. You might need to look for a better library - the ones provided by Sparkfun and AdaFruit aren't really intended for "production" code. OMG, why is SO showing me these old questions as "hot" ? \$\endgroup\$ – Jasmine Jun 30 '14 at 17:58
4
\$\begingroup\$

When power is first applied, any values you read could be crazy, and are certainly suspect.

Are you making any decisions based on reading values in setup()? If so, it could it be that the rest of your circuit has not settled down yet, and you get interesting bugs because of it.

Try a delay() in your startup() and see if the problem goes away.

\$\endgroup\$
1
\$\begingroup\$

In review of the schematic I see two possible causes:

  1. Your battery is not above 7.0Vdc, causing an erratic start that leads to a brown-out lockup. Or,

  2. The RC delay of the RESET is too weak. \$2 \times \pi \times 22pF \times 10K\Omega\$ is only \$1.3 \,\mu s\$ and the spec for reset is \$2.5 \,\mu s\$ minimum. Placing 1nF (aka 1000pF) across the shields RESET pin and GND will slow initial release of RESET some 50 times that of the DTR's 100nF from the FTDI.

However, the shield adds 100nF and 10K in parallel to each, respectively, which should make the delay sufficient (about \$0.5 \,ms\$). So there may be a problem with the shield.

\$\endgroup\$
  • \$\begingroup\$ please describe the battery. is it possible to add another 1.5V cell, to get voltage above 7.0 minimum \$\endgroup\$ – mpflaga Jan 9 '14 at 19:19
  • \$\begingroup\$ This also turned out to be an issue later on. The shield does seem to take a lot of power and runs down the battery quickly. \$\endgroup\$ – Chaitanya Jan 11 '14 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.