Looking for Greenhouse Project input (Electronics and code optimization)

I volunteered to develop a little greenhouse automation for a family friend, so I spent some time getting the required hardware and writing the code for the project. I am at the alpha stage where i have built my prototype about 80% there and wrote 90% of the code. I suspect I will need to add some electrical components to improve my design and maybe my code can be optimized a bit.

So, here's the high level project overview:
I am monitoring the temperature and humidity of the greenhouse to make sure they don't go too high. If they rise above a threshold then I trigger a relay to turn on an exhaust fan to get the warm humid air out. Additionally, I have a pair of soil moisture sensors (I average the 2 sensors for my threshold reference), which when the threshold is passed, they trigger another relay which is connected to a pool/fountain water pump to get water over to the plants in the greenhouse.

The LCD flips between displaying the current sensor readings and the fan/water pump status during general run time.
Additionally, based on the input to the keypad the user can see the thresholds, or enter a configuration mode or shortcut to a specific configuration setting. I am storing the thresholds in the EEPROM and loading from the EEPROM when the Arduino is powered.

Components are:

  • Arduino Nano v3
  • 2 Relay Module with Songle SRD-05VDC-SL-C relays (Based on this post I "may" be ok?)
  • 2 Soil Moisture Sensors eBay reference
  • 4x4 Matrix Keypad eBay reference
  • 16x2 LCD Display
  • DHT11 Sensor

Since I started with the Arduino and pieced it all together, I am certain my electronics connections can be much improved as the modules and sensors are tied to the pins (Where the tutorials called for potentiometers/resistors those were added but I am not sure if having everything together requires additional design). Unfortunately I could not get a hang of using Eagle to draw my schematic.

The code behind the project is attached. Note that I am aware that there is technically a "logic error" with the soil threshold and it is reversed right now, this will be adjusted closer to release time.

My next "to do" steps are:

  • Get 2 extension cords (3 prong variety) and to splice the relays into the extension cords.
  • Build/integrate an enclosure of some kind, preferrably so that it only has a few plugs for sensors and fan/pump

GreenHouseBeta.ino (21.6 KB)

compared to the cost of the other parts, this is downright expensive.
but at around $10, not expensive.

http://www.ebay.com/itm/Waterproof-Clear-Cover-Plastic-Electronic-Project-Box-Enclosure-case-115-90-55MM-/331152480579?pt=LH_DefaultDomain_0&hash=item4d1a39d943

as for the power, I am a big fan of using actual electrical boxes and receptacles and putting the relays into the receptacle box. you may need to use a fuse or circuit breaker, or run the risk of someone plugging in that 5hp pool filter.
a simple double gang box will give you a lot of extra room for relay and such.

you can score with relays from e-bay.
you need to power these from the power supply, not through the Arduino.

You haven't asked any questions . What is your question ? You get 3 questions. Make them good. (just kidding) :grin:
Seriously, congratulations on your project, sounds ambitions, but what is it you want (or need) from us ? We don't have a crystal ball. My compliments on the presentation of your post. Outstanding for a Newbie. Hell of a lot more than we usually get. Anyway,
What is your question ?

raschemmel:
You haven't asked any questions . What is your question ?

Yeah the question part isn't as clear as the rest of the post.

I am requesting someone who is more electronics saavy to review my wiring/connections to make sure I don't need diodes/and all of those other doodads I learned about back in college 15 years ago. Case in point, the 2nd reply regarding the relay modules....I don't quite understand if I can drive it directly from the arduino.

The VCC/GND pins on the module are wired to the Arduino Nano 5V and GND, the signal for the relay itself is coming off of pins D8 and D9 and this seems to work fine. I was getting the LCD to DIM when I was driving everything from a USB port on the computer but I also have a 2.1mm center positive barrel connector wired to go into VIN and GND so I can use a 12VDC/2A wall wart at which point the LCD doesn't dim at all.

Additionally, I've done a decent job with the code part but I'm sure that could possibly be optimized?

A quick look at the code, I see several things I would do differently, mostly style issues.

I see a lot of comments that are more than obvious from code. Removing those would make it easier/less time consuming to read the code. example

//Sensors info
int temperature; //Holds the read temp
int humidity; //Holds the read humidity
int soil_moisture; //Holds the read soil moisture

using well chosen function names could reduce the amount of comments.
example

  //Load the thresholds from eeprom
  eeprom_read();

could be

  eeprom_read_thresholds();

Why use a variable, when you can also use the #define in the code?

//Assign the pins for use in the program
int fan = FAN_PIN;
int pump = PUMP_PIN;

now in theory the variable fan could be changed!

// Turn the fan relay on 
void FanOn(char *fan_status){
  digitalWrite(FAN_PIN, enable);
  strcpy(fan_status, "on ");
}

in fact as fan_status is a global var you do not need to send it as parameter

// Turn the fan relay on 
void FanOn()
{
  digitalWrite(FAN_PIN, ENABLE);
  strcpy(fan_status, "on ");
}

you use different styles for functions
the_connect_with_underscores()
and
UpperCaseAtTheBegin()

one style is preferred

it is common in C to use capitals for #defines to show they are constants

#define enable LOW
==>
#define ENABLE LOW

use your own functions where possible.

applying the above on setup()

//Run once setup
void setup()
{
  //Load the thresholds from eeprom
  eeprom_read();
  //Read sensors to start program with
  readSensors();
  //Start serial communication
  Serial.begin(9600);
  //Disable the fan & pump first
  digitalWrite(fan,disable);
  digitalWrite(pump,disable);
  //Set the pins attached to fan & pump as output
  pinMode(fan,OUTPUT);
  pinMode(pump,OUTPUT);
  //Start sensors and lcd
  dht.begin();
  lcd.begin(16,2);
  //Set up the time tracker for screen update
  last_lcd_update = millis();
}

might become (also some reordering as not all statements were in right order! (use sensor before initialize)

void setup()
{
  pinMode(FAN_PIN, OUTPUT);
  pinMode(PUMP_PIN, OUTPUT);
  FanOff();   // note this also sets the status in right mode.
  PumpOff();

  eepromReadThresholds();

  dht.begin(); 
  readSensors();

  Serial.begin(9600);
  lcd.begin(16,2);
  //Set up the time tracker for screen update
  last_lcd_update = millis();
}

what do you think?

http://www.oddwires.com/5v-dc-songle-power-relay-srd-5vdc-sl-c-pcb-type-2-pack/

This relay module ?

Case in point, the 2nd reply regarding the relay modules....I don't quite understand if I can drive it directly from the arduino.

LOOK AGAIN AT THE REPLY NUMBERS.
Do you mean THIS reply ?

« Reply #1 on: Today at 05:00:03 am »

(the one that says "Reply #1 " ?
FYI, here on the forum we NEVER refer to replies by their sequential order because in 24 hrs it can change from 2 replies to 20
and therefore it is easier and more reliable to use the [Reply#] tag at the top of the post.

The answer to your question is in the post YOU linked when you asked this :

Based on this post I "may" be ok?

Think about it. The comment below is about the high current consumption based on the calculation of the power rating using the wattage. (0.36mW). We are led to believe that this means the coil draws 72mA. This may or may not be the case. There is no question that based on the specs we MUST conclude that but I am sceptical. The standard engineering proceedure is to order the part and verify the specs using empirical lab testing (measure the coil current with an ammeter). The price is $1.36 (+shipping). So I ask you, can you afford $1.36 (+shipping) to find out if the little tiny relay draws enough current to power a relay almost 10 times it's size ? An led draws 10 - 20 mA . (1/3 of 72 mA roughly). I personally would have to see it to believe it. If it were me , I would not hesitate for a second to order one so I can measure the coil current.

The relay is Songle SRD-05VDC-SL-C. It is rated at 0.36W, so the current consumption is around 72ma. This seems a bit high and strange because I can control the relay just fine with my Arduino UNO.

Let's assume it is correct and it draws 72mA. Now we have to deal with that. You sure as hell are not going to be driving these directly from your digital pins for obvious reasons.

The total current from all the IO pins together is 200 mA max

(based on the specs, 3 of these relays puts over the max current for all the I/O combined) So, what to do...tic toc tic toc tic toc ..BLINNNNNNG ! Sorry, times up. What's your answer ? Yeah, the answer is obvious, we need some kind of switchable device to turn on and off the relay (like a fet or transistor) and secondly , we need an external +5V power source to power the relay like a 9V wall wart (small black brick that plugs in wall outlet) and a LM7805 regulator with a healthy heatsink. (radioshack has an excellent one http://www.radioshack.com/product/index.jsp?productId=2102857 ) Note the cooling fins. This kind of heat sink is way better than this type: Heatsink TO-220 - PRT-00121 - SparkFun Electronics even though this type will work for your application. Now, we have a 2n2222, or 2n3904 NPN transistor (see attached) with the emitter connected to ground and the collector connected to the coil of the relay. The other end of the coil is connected to your external +5Vdc power supply. You have a 1 k resistor connected between your arduino digital output pin and the base of the transistor. With the external power supply turned on you turn on the digital pin (HIGH) and that applies about 5Vdc to the 1 k resistor supplying enough current to turn on the transistor which in turn allows current to conduct through the coil of the relay without overloading your arduino regulator. Problem solved. Now read this comment from the post YOU linked about the relay.

The VCC/GND pins on the module are wired to the Arduino Nano 5V and GND, the signal for the relay itself is coming off of pins D8 and D9 and this seems to work fine. I was getting the LCD to DIM when I was driving everything from a USB port on the computer but I also have a 2.1mm center positive barrel connector wired to go into VIN and GND so I can use a 12VDC/2A wall wart at which point the LCD doesn't dim at all.

Ok, this guy is clearly not an electronics tech . What he really saying , is that when he turned on a bunch of these relays his lcd dimmed when he was running off the usb power until he connected a 2A , 12Vdc ps to the round external power input of the arduino. Just so you know. What he has done, makes no sense, because the external power input for the arduino IS THE INPUT OF THE ON BOARD 5V REGULATOR that has a MAXIMUM RATING OF 200mA !

The total current from all the IO pins together is 200 mA max

So you tell me, If the regulator maxes out at 200mA, is he gaining ANYTHING AT ALL by connecting a 2A power supply to the INPUT of a regulator that maxes out at 200mA ? The correct approach is use everything on the arduino to drive other devices (like the transistor) AND make sure that the power supplied to the devices that draw a lot of current comes from an EXTERNAL ps .

Songle_SRD(T73)_Relay.pdf (98.9 KB)

P2N2222A-D.PDF (120 KB)

relays.

the Songle you listed is just the relay.

on ebay:

http://www.ebay.com/itm/1-Channel-5V-Relay-Module-Shield-for-Arduino-uno-1280-2560-ARM-PIC-AVR-DSP-/271320439592?pt=LH_DefaultDomain_0&hash=item3f2bf55b28

shows the same relay, on a board, with opto-isolator.

to use this, you connect your power supply to the relay board. this comes directly from your power supply, not from the Arduino.

you also connect an output pin. since this unit has an opto-isolator, all you need to power is the LED in the opto. the notes say 4ma, well within the rating for the output pin.

Yeah . That's what I'm talking about ! I looked for something like that with an onboard transistor but didn't find it.

@robillaart:

Thank you, I agree with all of your feedback, I went back and integrated the feedback into my program. With regards to comments, I figured it's better to err on the side of being redundant with comments rather than having no comments. I went back and removed the blatantly obvious comments. I also cleaned up all of your other suggestions, although I think my logic at the time was using ThisMethodForFunctions was for different states while this_method_for_functions was for supporting functions. I did make everything consistent in GreenHouseBeta1 (attached).

@dave-in-nj:
I am actually using this similar module. I have it on hand already wired into the project. The VCC pin from the Arduino Nano is wired to the VCC on the module, I am not sure if this is what you mean by wiring it to the power supply. It's my understanding, although perhaps incorrect, that whatever voltage I feed into the VIN/RAW pin, is going through the voltage regulator on the Arduino board and comes out @ 5V on the VCC or 5V pin and @ 3.3V on the 3.3V pin and that's ok to use. That was the reference in my first post, to the other discussion where a similar setup is used and from my understanding the output pin being driven by Arduino is "ok". I think you confirmed that in your second post.

@raschemmel:
Good morning, I think you woke up on the wrong side of the bed today. I hope you cheer up by tomorrow. I already said I am not an Electrical Engineer :slight_smile: or an Electronics Tech and that's why I was looking for improvements in the component design of the project. While you state that it's obvious that we need some kind of a switchable device it really may not be so obvious. You don't really have to be condescending when trying to answer the question. That's correct that I wired everything to the pins on the Arduino Nano and when I use the wall wart on the VIN pin my LCD doesn't dim....the information and schematic for the Nano hasn't even been updated with the ATMEGA328 chip and the information that's provided doesn't make it clear whether the VCC/5V PIN is ok to use to power relays and other components.

My BAD. SORRY ! I don't know what came over me. Maybe I did get up on the wrong side of the bed but that's no excuse to be rude. I didn't mean to be condescending. Please accept my apology. (I would say it won't happen again, but I don't know if I can truthfully say that. I'll say I'll try not to let it happen again.
ok , so let's look at this situation.

I am not sure if this is what you mean by wiring it to the power supply. It's my understanding, although perhaps incorrect, that whatever voltage I feed into the VIN/RAW pin, is going through the voltage regulator on the Arduino board and comes out @ 5V on the VCC or 5V pin and @ 3.3V on the 3.3V pin and that's ok to use.

Yeah, so here is where I think there may be a problem. The power supply that powers the arduino is not 5V, which is why you are plugging it into the RAW (round) connector. The goal is to offload the onboard regulator because it is limited to 200mA. That's why I mentioned that you would need a 5V regulator (rated for 1.5A) with the Input pin of the regulator getting it's power from the same wall wart you plug into the arduino, meaning you would have to split the wall wart output before the round plug and add an additional cable in parallel with the one going to the arduino. That cable would power and ground connected to the regular (lm7805) and the output of the regulator (+5Vdc) connected to all the relay modules. That way none of the relays will load down the arduino onboard regulator. The LM7805 would need a good heatsink mounted with thermal paste to prevent the regulator from going into overtemp shutdown mode, (a condition identifiable by the 5V output working for a few seconds and than reducing to 0.5Vdc. This allows you to drive 1.5A/0.072mA =250 relay modules. Isn't that better than trying to drive the relays from the onboard arduino regulator which can only support 0.2A/0.072mA = 2.7 (less than 3) relay modules ?

Now, we have a 2n2222, or 2n3904 NPN transistor (see attached) with the emitter connected to ground and the collector connected to the coil of the relay. The other end of the coil is connected to your external +5Vdc power supply. You have a 1 k resistor connected between your arduino digital output pin and the base of the transistor. With the external power supply turned on you turn on the digital pin (HIGH) and that applies about 5Vdc to the 1 k resistor supplying enough current to turn on the transistor which in turn allows current to conduct through the coil of the relay without overloading your arduino regulator. Problem solved

This no longer applies since you are using modules with onboard transistors.

No problem, we all have a bad day once in a while. I appreciate the apology and additional information.

I checked RadioShack and there are two regulators besides a small price difference:

Not sure there's significant difference between the two?

And possibly a heatsink

For wiring, the wall wart output would be rewired this way:

---> Wall Wart 12VDC/2.5A --> Y junction where one leg goes to Arduino VIN/RAW and the other leg goes to 7805 voltage regulator, both sharing a ground lead. I could use another rail on the breadboard for this.

Then to clarify the last part of your reply,
I only have a single 2 relay module and it is possible for both relays to be toggled...Although approaching the threshold based on your calculations, does the DHT11, 1602 LCD and 2 referenced relays on a single module cross the threshold? Perhaps having it near max reduces the overall life of the regulator but if we're talking about 10 years @ optimal draw vs 7 years of near max draw I think I am ok with taking this risk. I know my hardware choices are complete (and the project logic/testing does work) and no additional hardware is going to be added.

As a side discussion....Part of the reason why I am confused regarding the VIN and power requirements for my projects is that I purchased a Radio Shack Tri Color LED strip a while back and the support files tell you to wire the strip to the Arduino Uno by connecting:

+12 V to VIN
GND to GND
DIN (Data) to A0

The LED strip needs 1A which is 4x the onboard voltage regulator you refer to....I would think wiring it per the LED strip instructions would have burned out the PIN or caused odd behavior (albeit perhaps after a longer period rather than a few minutes of verifying that the LED strip actually worked)

does the DHT11, 1602 LCD and 2 referenced relays on a single module cross the threshold?

1602 LCD = 0.020A
2 referenced relays = (2 * 0.072mA= 0.144 A
DHT11 = 0.005A

TOTAL: 0.169 A (+ CPU /leds current draw)

I found this post :
arduino uno max and minimum power consumption - 3rd Party Boards - Arduino Forum and this one : http://forum.arduino.cc/index.php topic=108201.0 and this one : Gammon Forum : Electronics : Microprocessors : Arduino Uno Rev3 pinouts photo I max ampere for VIN pin - Motors, Mechanics, Power and CNC - Arduino Forum

If you use an external supply a voltage range of 7V to 12V is recommended (e.g., a 9V battery could be used). Bear in mind the higher the voltage the more work the voltage regulator has to do to "throw away" the excess voltage, so with a 12V supply, and powering quite a few "peripherals" the voltage regulator is likely to get hot. On the other hand, the internal circuitry is designed to switch from USB to external if the external supply exceeds 6.6V, so supplying much less than 7V probably won't work properly.

I think this guy knows what he is talking about:

Yes, there is a series polarity protection diode wired between the external power connector + to the Vin pin, this is I believe a nominal 1 amp maximum forward current rated diode. Lefty

And then there's this:

The Arduino Diecimila has an on board regulator for use when powering from an external power supply. It uses the MC33269 series regulator chip. A question often asked is “can I run it off a 12V supply”. A look at the schematics show that C5 and C6 will be exposed to the full input voltage so the first thing is to see that those capacitors are rated at at least 12V, in this case they are with a 35V rating. So no trouble there. Next see if the regulator can stand that much, again looking at the data sheet shows this to be able to stand 20V. So next see if it can handle the power. The regulator drops the difference between the input voltage and the output voltage. Also their is a series diode in front of the regulator so that drops 0.7V. This gives us a total voltage drop across the regulator of 12 - 5 - 0.7 = 6.3V. The power burnt off by the regulator is a function of the current it is taking. Now the board takes about 120mA when it is running, add a bit extra for interface current LEDs and so on and let’s call that 200mA. So now we can calculate the power, it is simply 6.3 * 0.2 = 1.26 Watts. Is that too much? Well the data sheet for that device is a little more helpful than most. In includes this graph which shows what effect the copper on the PCB has on the thermal

If you look at the Arduino you will see that there is only the minimum pad, that is there is no extra copper surrounding the regulator. So in this case reading off the graph we have a maximum power of about 1.5W for a 50 oC ambient or a thermal resistance of 68 oC / W. So that mans for our example we can only draw 1.5 / 6.3 = 0.238 A or 238mA. So it looks like we will be just about OK with 200mA. The data sheet also says there is a thermal cut out that operates at 170 oC so you can use that if you need in your calculations. However, it warns that the thermal cut out is not a substitute for an adequate heat sink.

After reading all these posts my conclusion is that the onboard regular maximum is 800mA and 200mA maximum that you see elsewhere and on the net is not the regulator maximum but the ATmega328 I/O maximum draw. The fact that the diode they talk about here: max ampere for VIN pin - Motors, Mechanics, Power and CNC - Arduino Forum is rated for 1A maximum confirms it for me because in 30 yrs of working with electrical engineers, they almost always allow a 20 to 25% safety margin so if they want the maximum to be 800mA they put a series diode that stops conducting at 1A. There is actually more to it than what has been discussed in all these posts with the exception of the the guy who said this:

Yes, of course. However the original question was how much Vin current could the OP draw from the Vin pin to power external componets. So the on-board +5vdc regulator is really only related in that it too draws from the total external power current limit imposed by the series diode.

But what exactly did he mean ? In order to answer that you have to dig deeper ? If your consult Wikopedia Diode - Wikipedia

The most common function of a diode is to allow an electric current to pass in one direction (called the diode's forward direction), while blocking current in the opposite direction (the reverse direction). Thus, the diode can be viewed as an electronic version of a check valve. This unidirectional behavior is called rectification, and is used to convert alternating current to direct current, including extraction of modulation from radio signals in radio receivers—these diodes are forms of rectifiers. However, diodes can have more complicated behavior than this simple on–off action, due to their nonlinear current-voltage characteristics. Semiconductor diodes begin conducting electricity only if a certain threshold voltage or cut-in voltage is present in the forward direction (a state in which the diode is said to be forward-biased). The voltage drop across a forward-biased diode varies only a little with the current, and is a function of temperature; this effect can be used as a temperature sensor or voltage reference.

If you look at the temperature derating curve at the bottom of the attached datasheet, you see drops dramatically as you approach 150 deg C. One must be careful not to misinterpret this to mean that it stops conducting. I would like to think that but I am having trouble finding anything to confirm it. The only thing you can take to the bank is that if you find the series diode referred to in the posts (D1/M7 on the attached schematic) you be sure that if you get some very tiny wire and you connect a wire from each end of that diode and connect those two wires to two pairs of resistors in series, each a voltage devider with 10k at the diode end and 5k at the other end where they are connected to ground, and then you add two tiny wires from the point in between the 10k and 5k resistors and connect those two wires to A0 and A1 analog inputs, then when you plug in your 9V wal wart (which actually measures 10+V unloaded) you will get two voltages that differ by the forward conduction voltage for a silicon diode (0.7V) so if the voltage on the input (Anode) side of the diode was 9Vdc, then the voltage on the arduino regulator side (cathode) would be 9-0.7=8.3Vdc. The voltage at the midpoint of the added voltage dividers would 3V and 2.77V respectively which at 4.8mV per count of the analog range of 1023 counts for 5V dc, that would give you a reading of about 614 on the input side and 553 on the cathode (arduino regulator input side). As you load down the arduino regulator incrementally, when it starts to exceed the 1A maximum rating , you should see the cathode voltage drop dramatically as it approaches 150 degrees C., while the voltage on the anode would(should) remain constant until the diode self destructs. Until I can find proof that it acts like a current limiter, I will asume it does not and will continue conducting as it heats up until it fails catastrophically. On the other hand, the wal wart starts to heat up and the voltage reduces , both voltages would go down. At no time should you see more than a 5 % (probably2%) deviation in either voltage if the regulator is happy. If you ran a program that monitored the cathode voltage and used a CASE statement or IF statement , either by a routine in the main loop (the measurement would only take uSeconds so it wouldn't slow down your system) or by an interrupt driven routine , similar to a watch-dog timer, you could shutdown all I/O application based I/O and turn on a relay that turns on an audio alarm or flashing red light (24Vdc variety) to notify you there is a problem. All this for four resistors and a few lines (more like a dozen) of code. So to answer your question about whether or not you are ok using the onboard regulator (which I now believe is ok up to 800mA) , the answer is your probably have about 500 to
600mA more available with the parts you mentioned connected.

1n4001.pdf (76.9 KB)

arduino-uno-schematic.pdf (32.7 KB)

M7-diode.pdf (886 KB)

It'll take me a day or so to digest the presented information (not an electrical engineer :slight_smile: ) but on the last few sentences of your reply lines up closer to what I observed in my software development cycle. Driving the Nano with a USB 3.0 port I am able to control all outputs but, as I mentioned I can see the LCD dim when both relays are enabled, and for a brief second when the DHT11 is read there's a "blink" of the LCD...However, with the DC wall wart the Nano is getting closer to the 1A and the dimming and blinking are not there.

I also see quite a bit of varying information/speculation on proper powering of higher energy components (motors/relays/etc) where 20 mA/40 mA are thrown around but I take that to mean if I was going to take 2 digital pins and GND from an Arduino, I wouldn't be able to:

Drive D8 HIGH and use that for the VCC pin of a relay/motor and use D9 as the OUTPUT (signal) for the relay...GND to GND of course....

I am perhaps a bit more cavalier in wiring it up and testing because the components are relatively cheap and I ordered a couple of spares in case my shenanigans resulted in little puffs of smoke.

Follow up question to this would be....Since I am inserting the 110v mains power into the equation are there any additional components I may need to include into my project for safety?

SORRY, I just realized you were using a NANO and not an UNO. I know you mentioned that several times but it didn't sink in till now. So with that in mind:
500mA-170mA=330mA for the cpu and all the onboard circuitry or leds. (NOT 1A. THAT WAS FOR THE UNO)
That's why your lcd was dimming.

Recommended Operating Conditions
MIN MAX UNIT
uA78M33 5.3 25
uA78M05 7 25
uA78M06 8 25
uA78M08 10.5 25
VI
Input voltage V
uA78M09 11.5 26
uA78M10 12.5 28
uA78M12 14.5 30
uA78M15 17.5 30
IO Output current 500 mA
uA78MxxC 0 125
TJ Operating virtual junction temperature °C
uA78MxxI –40 12

SEE ATTACHED DATASHEET FOR UA78M08 (for all 7800 series)

ArduinoNano30Schematic.pdf (200 KB)

ua78m08.pdf (1.01 MB)

To add to this confusion, the Nano module actually uses an ams1117 5.0 1308 regulator that has an output current of 1a based on the spec sheet

Well that's great news and how come the schematic shows a UA78M05 ?

ArduinoNano30Schematic.pdf (200 KB)

I have an explanation for that :slight_smile:
Mine is a Nano clone from eBay....

But it's also possible that the schematic isn't current anymore since it also shows an ATMEGA168 instead of a 328

I would strongly suggest using a different power supply for the relays since you are already experiencing mild power issues. this would provide better isolation (from voltage spiking caused by the relays, fan and pump) and a more stable supply for your arduino. So after rereading some of the posts it looks like the LCD dims when the setup is powered from the computer's USB, but runs fine when powered externally with a 12v 2a wall wart? This is to be expected. USB protocol is limited to 500ma, but the computer host is only required to put out 100ma without the client device "negotiating" for more. You will probably be fine without an external voltage regulator as long as you run your relays off the external 12volt source.
Have you measured the 5volt and 12 volt rails to see if it sags when the relays energize?
When you bring mains voltage into the mix, safety should be the utmost consideration . From personal experience, I would strongly recommend a GFCI outlet. My greenhouse controller malfunctioned when water got into the relay box and power shorted on (fans=on, window vent motors=on, water valves=on) . I was electrocuted (moderately) from touching the aluminum greenhouse frame and the standing water on the ground. Better safe than sorry.
Secondly, circuit protection can save you from having to replace everything should a fault occur- Fuses are a must.
Another consideration would be eliminating transients on the power line and whatever noise is caused by switching the pump and fan. Fans and pumps are highly inductive. Transients on the power rails can cause erratic behavior and resetting of the microcontroller as well as LCD scrambling. Snubbers, movs, tvs, and varistors are used for filtering on the AC powerline. Usually a snubber close to the load is sufficient.