Sensor interference. Lack of power?

Dear All,

Attached is the schematic.
I realized when relay module status is LOW (consuming energy), capacitive soil moisture sensor has its values changed.

  1. all sensors, LDC display and relay are powered by arduino 5V pin and Ground.
    It seems lack of energy shared to all components including a W5100 Ethernet Shield.
    Any previous experience/solution to share?
    Suggestions?
    Feed relay using another power source such as a stepdown straight from 9V/1A source?
    Feed moisture sensor instead relay?
    Use a simple voltage divider using resistors instead a stepdown?

Another important info. Memory are 90% used. Maybe should I change to Mega 256?

Your contributions are always welcome.

Thanks

Reinaldo Lorenzato

Maybe run the 9V power through a DC-DC buck converter (efficient, inexpensive) or a 7805 linear regulator (not efficient but real cheap) to get 5V and ground. Run 5V and ground to the Arduino, the ethernet adapter, the lcd controller and the relay (unless the motor runs better on 9V) and maybe the moisture control board. Grounds will be common.

5V to Arduino goes straight to the 5V pin, not the power connector (with on-board 7805 that needs at least 7V to run right).

Arduino power connector only has 2 contacts, you show 3. The Arduino board has a power on led, why add another?

Maybe should I change to Mega 256?

Without first seeing what you can do to reduce ram use? Taking the "easy" answer right away leads to cheesy code.

Never use an int where a byte will do especially in arrays. Pin numbers do not need ints, extra byte each when they're int.

If you can deal with bits, each byte is 8 T/F bits that can be logic-operated on in a single step. Instead of 1 byte each for current and previous pin states try using bit 0 for current state and bit 1 for previous state. That make 4 possible combined states as byte values 0 to 3, just right for switch-case structure. Before you read a new current bit, shift the 2 bits up 1, mask off the higher bits and then read the current state and add it to the byte. This saves a byte, I use it in some button arrays/matricies to save a byte per button.

var = var << 1; // left shift bits 0 and 1 into bits 1 and 2.
var &= 2; // only bit 1 is copied
var += digitalRead( pin ); // the new read is put in bit 0, now the current pin state

If you do serial prints like this,

Serial.print( "this text loads into ram at startup and stays there" );

then doing this,

Serial.print( F( "this text stays in flash and prints from there" ));

will free up as much ram as you have text.