When arduino board experiences some jerk in electricity or when the power goes off for just a moment and energized again the arduino board, Ethernet shield stops working and i get nothing on the web page until i plugged off the usb (power) cable of arduino and then plugged on again.
Power supplies must be stable to ensure a stable process executing your sketch.
Which means you have to make sure that your Arduino is powered continuously without having spikes or short interrupts of the power rail. Depending on the kind of "noise" your Arduino has to deal with there are some technical solutions:
Simplest one:
use an electrolytic capacitor (let's say 1000 .. 2200 uF) between +5V and GND to bridge the power outages
with a parallel ceramic capacitor of 100pF .. 470pF to catch the spikes
Depending on the kind of spikes the value mightbe higher or lower, but normally not smaller than 47pF and not bigger than 10nF.
A little bit more complex
use a rechargeable battery powering the arduino being charged as long as the power plant is still delivering power (needs a bit of electronic around not just parallel wiring!)
rpt007:
Power supplies must be stable to ensure a stable process executing your sketch.
Which means you have to make sure that your Arduino is powered continuously without having spikes or short interrupts of the power rail. Depending on the kind of "noise" your Arduino has to deal with there are some technical solutions:
Simplest one:
use an electrolytic capacitor (let's say 1000 .. 2200 uF) between +5V and GND to bridge the power outages
with a parallel ceramic capacitor of 100pF .. 470pF to catch the spikes
Depending on the kind of spikes the value mightbe higher or lower, but normally not smaller than 47pF and not bigger than 10nF.
A little bit more complex
use a rechargeable battery powering the arduino being charged as long as the power plant is still delivering power (needs a bit of electronic around not just parallel wiring!)
Thanks.. It means that i have to provide continuous power to arduino board ? (It is difficult, sometimes power goes off and on again). Because when the power goes off and on again, Ethernet shield stops working until i to go to a room and insert the usb cable (power) again into the arduino board and then it shows the data on web page.
How long is the power off period? Seconds/minutes/hours?
If less than a second - the simple solution should do
if the outage is longer than a few seconds, you will have to calculate the value of a suitable capacitor, which can deliver long enough power, so that the voltage drop doesn't go lower than something like 4V, maybe down to 3.8V to keep the processor still alive
The capacitor (don't forget the little ones for the spikes) is to be connected to Arduino's +5V and GND pins and not to Vin, as Vin is "before" the voltage regulator.
If the power outage lasts longer than, let's say, some minutes and could not be bridged by a very big capacitor, you should go with the rechargeable battery as recommended in my previous post.
The rechargeable battery will be always connected to your mains power supply, and is a backup, which could bridge hours of mains power outages, depending you have designed it big enough, so the battery's capacity can deliver the current needed by your project.
So, if your configuration is running at 5V and draws 100mA continuously, a 5000mAh battery can survive about 5000mAh/100mA = 50h theoretically (I would calculate with 20% less to be on the safe side - which still survives a mains power outage of 40h).
One more question:
you say you have to unplug and plug again the USB cable to wake up your ethernet shield after a power outage? So my question is:
Is your Arduino powered through a USB cable from a PC or laptop?
If so, I would suggest to connect the (pre-calculated) capacitors (big one plus small one in parallel) to the +5V and GND of your Arduino whether you are powering the project just via USB cable or wall outlet.
ii might also help to buy a distortion filter which are normally used in cars to keep spikes away from electronics
Arduino itself draws some current so you have to add this as well; I have no idea how much that is, but I guess it will also be in the magnitude of 10-20mA (never measured that) plus your ethernet shield, if I am not mistaken.
I strongly suggest NOT to continue powering your project through USB from laptop.
Reasons:
do you know the quality of your USB cable (there are huge differences, i.e EM shielding etc.)
laptop itself could be a source of failure due to windows doing some background activities, running into timing issues to serve the USB connection etc.
Thus I suggest to go with a good quality DC wall wart adapter of 9V plus 2200uf or 4700uF capacitor from +5V to GND on the Arduino. Pls pay attention to the polarity of the capacitor to avoid explosive reactions.
Arduino itself draws some current so you have to add this as well; I have no idea how much that is, but I guess it will also be in the magnitude of 10-20mA (never measured that) plus your ethernet shield, if I am not mistaken.
I strongly suggest NOT to continue powering your project through USB from laptop.
Reasons:
do you know the quality of your USB cable (there are huge differences, i.e EM shielding etc.)
laptop itself could be a source of failure due to windows doing some background activities, running into timing issues to serve the USB connection etc.
Thus I suggest to go with a good quality DC wall wart adapter of 9V plus 2200uf or 4700uF capacitor from +5V to GND on the Arduino. Pls pay attention to the polarity of the capacitor to avoid explosive reactions.
OK now i will try with the capacitor.
I would like to repeat that in the beginning of my project, i was powering my arduino with USB adapter and when the power goes off and on again, ethernet shield stops working until i unplug and plug again the USB cable into adapter.
when the power goes off and on again, ethernet shield stops working until i unplug and plug again the USB cable into adapter.
I suppose it's the main power which goes on and off?
So I am still doubtful about your laptop not being able to have a working battery which normally should survive mains outages a bit of time - if the battery is not working anymore then that is what could produce or let through some spikes on your USB cable.
That somehow kills the communication between Arduino and ethernet and shoots your program into an undefined state which only recovers when you plug/unplug the USB (=power supply) cable => reboot.
But, as @TomGeorge said, it would be useful if you could give us the full picture with EVERYTHING which is connected to each other in your project including all devices which are wired including the power cord connected to your mains.
I would like to repeat that in the beginning of my project, i was powering my arduino with USB adapter and when the power goes off and on again, ethernet shield stops working until i unplug and plug again the USB cable into adapter.
Power= what do you mean?
Is it your main AC power, if so then doesn't your whole ethernet system go down as well?
Yes it the main power and when the main power goes off and on again, my whole Ethernet system goes down until i unplug and plug the power cable (black cable in picture) to arduino. ( In this case Arduino is not connected to laptop, powered by wall adapter)
Generally it is no good idea to use RX or TX pins in an Arduino project if it is not necessary. TX/RX are used for serial communication and while loading a sketch up to the MCU; if you have other pins available, stay away from the RX/TX pins (you may modify your sketch accordingly)
Outages of 15 to 20 seconds are way too much being bridged by a capacitor of a reasonable size.
Depending on the overall power consumption of your project, which imho will be around 50mA and up, you can calculate the time that a capacitor of 4700uF can bridge to go from 5V to 4.32V (this is the absolute minimum to operate an Arduino by a reduced speed (MHz)).
This calculation will be in the magnitude of ms(!) and not at all close to only one second!
Hence the only advice I have for you: go with a chargeable battery to bridge the outages. In reply #2 I included a simple circuit for using the wall adapter to charge the battery while the mains is available and the battery taking over for the period of time when mains is gone. Think of a small capacitor (1nF .. 100nF) to avoid spikes being produced by your mains when it goes on or off - the value of the capacitor - this is something you should experiment with, as I have no clue what kind of spikes your mains is causing for you project.
In your picture it is not clear to see what other connections you use to other devices.
Could you pls tell us, how the wires on the right side of the Ethernet shiled are used.
I would prefer your answer in the following form:
Ethernet shield wire color Destination
A0 red ??
9V orange ??
GND brown ??
?? blue ??
rpt007:
In your picture it is not clear to see what other connections you use to other devices.
Could you pls tell us, how the wires on the right side of the Ethernet shiled are used.
I would prefer your answer in the following form:
Ethernet shield wire color Destination
A0 red ??
9V orange ??
GND brown ??
?? blue ??
My table is only a guess, pls correct.
Ethernet shield wire color Destination
A0 red Smoke sensor
9V orange Supply to sensors
GND brown + blue GND to sensors