Arduino Project Power Distribution Problem

Hello,

I am not an engineer,but am in school for an electrical related degree and had to build a project. As is intended with projects like this I learned a TON with the help of this forum and website, but I still have lingering issues that were never really solved or that I feel could have been done better. So, I want to post a detailed write up of my project here and see what kind of answers I can get to help me understand what was/is going on.

My project was to create an Arduino controlled fire alarm system that provided the following functionality:

I used an Arduino Mega 2560 as my main board.

  1. Use a Graphic LCD screen for message and data display. I used this one… https://www.adafruit.com/products/188

  2. Monitor ambient temperature with this temp sensor…https://www.sparkfun.com/products/11050

  3. Connect to a wireless network and send an email notification whenever the system activated.

For this part I used the Arduino WiFi shield.

  1. When the ambient temperature reached a value higher than my set trigger temperature, the system would activate doing the

following:

a. Turn on a submersible water pump that would start the sprinkler system… I used this pump with small rain bird dripper

sprayers…https://www.sparkfun.com/products/10455

b. Start an actual fire strobe light that draws 12VDC 300mA.

c. Turn on a buzzer that operates anywhere from 5 - 15 volts.

d. Send one email notification to me that the system was activated.

e. Continue to monitor the temp and stop the system once the ambient temperature was once again below the trigger temp.

This was all for a basic demonstration for my class, so no need for big sprinklers or anything.

To accomplish this I set up my Arduino Mega with the LCD screen connected as indicated, and it worked fine. The WiFi shield was stacked on the Mega. To run the pump, strobe and buzzer I used a motor driver board recommended for use with the pump…

https://www.sparkfun.com/products/9815?

I also attached a small 5 VDC 25mm cooling fan in my 10x8x10 foam board enclosure for airflow.

The final project consisted of a different configuration. I ended up using a small 5VDC relay with 12VDC 2A as the pass through power instead of the Ardumoto board. The Ardumoto would not power the pump/strobe/buzzer even when given the entirety of the 12VDC 2A through the external power connection.

I was not able to use the temp sensor for some unknown reason because I could not get it to be reliable nor stable enough, so it was replaced by a standard TM36 sensor.

The LCD screen seemed to work ok, but would become unstable anytime the pump was going, but the temperature displays were always erratic. I used the LCD to show very basic information as in the example below:

Trigger Temp: 80 F

Current Temp: 70 F

System Status: OFF or ACTIVE

Pump: Off or On

Connected To:

Network Name

My biggest problem was with power. I was never able to get enough to the places that needed it and I seemed to be at or exceeding the requirements of the components, but this is where I know the least.

I bought a AC to DC power supply rated at an output of 12VDC at 2A and thought I would be ok with everything, but it was not. I ended up having a 12VDC 2 A supply to just the pump/strobe/buzzer, a separate 9VDC 1A supply for the Mega, WiFi, and LCD screen, and another 9VDC 1A supply running through a 5VDC regulator to power my proto board, for connections to pots and my LCD. I also used standard 10k pots for adjusting the screen contrast, for adjusting the trigger temp through the software and displaying on the screen, and a third pot for setting the volume of the buzzer. I ended up having to remove the trigger temp set pot because it was REALLY erratic and the system would turn on and off because of the jumping value of the temp.

I was finally not able to get the proper voltage from the digital pin on the Mega to properly trigger the 5VDC relay that only requires about 30mA of current to trigger it. The relay would trigger in random ways. Sometimes really fast on and off or not at all. Then after sometime the whole system would slowly lose power to where the screen was barely on and everything else just shut off. I now have 3 power adapters inside to power everything separately, as mentioned above.

I am including some images so you can see different setups I used and what i finally ended up with.

I know this is long and complicated, but I need to learn as much as possible about all this. I thank you in advance for reading all of this and hope that some of you can and will take some time and start a discussion with me on this. Thank you.

More images:

Final inside view:

Arduino Code: again I am not a programmer!

//#include <OneWire.h>

#include <WiFi.h>

#include <glcd.h>

#include <fonts/allFonts.h>

#include <SPI.h>

//----------Global Varialbles------------------------------------------------

int triggerTemp = 80;

float temperature;

int emailCount = 0;

int systemTogglePin = 41;

int temperaturePin = 0;

int yetAnotherInt = 0;

//Wireless network configurations

//char ssid = “XXXXXXXXXXX”; // your network SSID (name)

//char pass = “XXXXXXXX”; // your network password

char ssid = “XXXXXXXXX”; // your network SSID (name)

char pass = “XXXXXXXXXXX”; // your network password

int status = WL_IDLE_STATUS; // the Wifi radio’s status

//Temperature chip i/o

//OneWire ds(DS18S20_Pin);

//-----------------SETUP---------------------------------------------------------------------

void setup() {

delay(5000);

GLCD.Init();

GLCD.SelectFont(System5x7);

startupDisplay();

wirelessNetwork(); //make wireless connection

mainLcdDisplay(); //setup main display elements

pinMode(15, INPUT); //Trigger Temp pot set

pinMode(systemTogglePin, OUTPUT);

}

//-------------------------LOOP--------------------------------------------------------------------------

void loop() {

temperature = getVoltage(temperaturePin); //getting the voltage reading from the temperature sensor

temperature = (((temperature - .5) * 100) * 1.8) + 32;

//Monitor Temperature

printTriggerTemp();

printCurrentTemp();

//Refresh basic system status

pumpStatus();

systemStatus();

if((temperature >= triggerTemp)) {

digitalWrite(systemTogglePin, HIGH);

if(emailCount >= 1){

//emailService();

emailCount = 1;

}

}else{

emailCount = 0;

digitalWrite(systemTogglePin, LOW);

}

delay(1000);

}

//---------------------FUNCTIONS-----------------------------------------------------------------------------------

float getVoltage(int pin){

return (analogRead(pin) * .004882814); //converting from a 0 to 1023 digital range

// to 0 to 5 volts (each 1 reading equals ~ 5 millivolts

}

void startupDisplay() {

GLCD.ClearScreen();

GLCD.CursorTo(2, 0);

GLCD.println(“Tech 115 Project”);

GLCD.print(“Networked Fire Alarm”);

GLCD.CursorTo(4, 2);

GLCD.print(“xxxxxxxxxx”);

GLCD.CursorTo(7, 3);

GLCD.print(“xxxxxxxxx”);

GLCD.CursorTo(2, 4);

GLCD.print(“xxxxxxxxx”);

delay(5000);

}

void mainLcdDisplay() {

GLCD.ClearScreen();

GLCD.CursorTo(0, 0);

GLCD.println("Trigger Temp : "); //trigger temperature

GLCD.println("Current Temp : "); //Current temperature from sensor

GLCD.println("System Status: "); // System status - active/off

GLCD.println("Pump : "); //staus of pump - on/off

GLCD.println("Connected to : ");

GLCD.print(WiFi.SSID());

}

void printCurrentTemp () {

GLCD.CursorTo(15,1);

if (temperature >= 0)

yetAnotherInt = (int) (temperature + 0.5);

else

yetAnotherInt = (int) (temperature - 0.5);

GLCD.print(yetAnotherInt);

GLCD.print(" F ");

}

void printTriggerTemp() {

GLCD.CursorTo(15,0);

GLCD.print(triggerTemp);

GLCD.print(" F ");

}

void systemStatus(){

if(temperature >= triggerTemp) {

GLCD.CursorTo(15,2);

GLCD.print(“Active”);

}else if(temperature < triggerTemp){

GLCD.CursorTo(15,2);

GLCD.print("Ready ");

}

}

void pumpStatus(){

if(temperature >= triggerTemp){

GLCD.CursorTo(15, 3);

GLCD.print("On ");

}else{

GLCD.CursorTo(15, 3);

GLCD.print(“Off”);

}

}

void wirelessNetwork() {

GLCD.ClearScreen();

// check for the presence of the shield:

if (WiFi.status() == WL_NO_SHIELD) {

GLCD.print(“WiFi shield not present”);

// don’t continue:

while(true);

}

// attempt to connect to Wifi network:

while ( status != WL_CONNECTED) {

GLCD.CursorTo(0, 0);

GLCD.println("Connecting to: ");

GLCD.print(ssid);

// Connect to WPA/WPA2 network:

status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:

//delay(10000);

}

// you’re connected now, so print out the data:

GLCD.ClearScreen();

GLCD.print(“You’re connected to the network”);

//delay(3000);

printCurrentNet();

//delay(3000);

//printWifiData();

//delay(10000);

}

void printWifiData() {

GLCD.ClearScreen();

// print your WiFi shield’s IP address:

IPAddress ip = WiFi.localIP();

GLCD.println("IP Address: ");

GLCD.println(ip);

//delay(5000);

// print your MAC address:

byte mac[6];

WiFi.macAddress(mac);

GLCD.println("MAC address: ");

GLCD.print(mac[5],HEX);

GLCD.print(“:”);

GLCD.print(mac[4],HEX);

GLCD.print(“:”);

GLCD.print(mac[3],HEX);

GLCD.print(“:”);

GLCD.print(mac[2],HEX);

GLCD.print(“:”);

GLCD.print(mac[1],HEX);

GLCD.print(“:”);

GLCD.print(mac[0],HEX);

//delay(5000);

}

void printCurrentNet() {

GLCD.CursorTo(0, 0);

// print the SSID of the network you’re attached to:

GLCD.println("SSID: ");

GLCD.print(WiFi.SSID());

//delay(2000);

/*

// print the MAC address of the router you’re attached to:

byte bssid[6];

WiFi.BSSID(bssid);

GLCD.CursorTo(0, 0);

GLCD.println("BSSID: ");

GLCD.print(bssid[5],HEX);

GLCD.print(“:”);

GLCD.print(bssid[4],HEX);

GLCD.print(“:”);

GLCD.print(bssid[3],HEX);

GLCD.print(“:”);

GLCD.print(bssid[2],HEX);

GLCD.print(“:”);

GLCD.print(bssid[1],HEX);

GLCD.print(“:”);

GLCD.print(bssid[0],HEX);

//delay(5000);

*/

// print the received signal strength:

long rssi = WiFi.RSSI();

GLCD.CursorTo(0, 0);

GLCD.println(“signal strength (RSSI):”);

GLCD.print(rssi);

//delay(2000);

/*

// print the encryption type:

byte encryption = WiFi.encryptionType();

GLCD.println(“Encryption Type:”);

GLCD.print(encryption,HEX);

*/

}

void emailService() {

WiFiClient client;

if (client.connect(“74.125.131.26”, 25)) {

client.println(“ehlo XXXXXXXXX”);

delay(1000);

client.println(“mail from: <XXXXXXXXX.com>”);

delay(1000);

client.println(“rcpt to: <XXXXXXX@gmail.com>”);

delay(1000);

client.println(“rcpt to: <XXXXXXXXX@yahoo.com>”);

delay(1000);

client.println(“data”);

delay(1000);

client.println(“Subject: Tech 115 Project”);

delay(1000);

client.println(“Fire System Activated.”);

delay(1000);

client.println(“.”);

delay(1000);

client.println(“quit”);

delay(1000);

client.stop();

}

else {

GLCD.println(“Unable to connect to smtp server!”);

}

}