How come my Arduino will only start when I open up my COM port with a Serial Monitor application. If I want my Arduino to stand alone what do I have to do?
void setup()
{
// SPI pin initialization
pinMode(MOSI, OUTPUT);
pinMode(MISO, INPUT);
pinMode(SCK,OUTPUT);
pinMode(CS,OUTPUT);
digitalWrite(CS,HIGH); //disable device
pinMode(6, OUTPUT); // Set digital pin 6 as OUTPUT to power WiFly shield VIN Pin
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0);
clr=SPSR;
clr=SPDR;
delay(10);
Serial.begin(9600);
Serial.println("\n\rWiFly Shield Terminal Routine");
if(SPI_Uart_Init()){ // Test SC16IS750 communication
Serial.println("Bridge initialized successfully!");
}
else{
wdt_enable(WDTO_8S); //start watchdog set for max 8 seconds
Serial.println("Could not initialize bridge, locking up.\n\r");
while(1);
}
}
void loop()
{
//Start Main Loop Here
}
Moderator edit: </mark> <mark>[code]</mark> <mark>
Opening the serial monitor in the IDE causes a auto-reset to be sent to the board. So hitting the manual reset button on the board would accomplish the same thing. Your loop() function is a do nothing loop so once there only a reset condition will restart the program and perform the code in the setup() function. Powering the chip up initially also initates the reset process. So what is your issue and what are your expectations, what isn't working the way you expect? Perhaps your code is getting locked up in the setup() function? I have no experiance with WiFi applications via arduino so maybe someone else can shead light on your issue.
MJA1:
How come my Arduino will only start when I open up my COM port with a Serial Monitor application. ...
What do you mean by "only start"? It always starts when you power it on. Whether it does what you expect depends on your expectations, and your observations.
How come my Arduino will only start when I open up my COM port with a Serial Monitor application. If I want my Arduino to stand alone what do I have to do?
Opening the serial monitor is like pressing the reset button on the Arduino board.
To use the board "standalone", well... just connect the power
The code functions properly. I think the answer to my question is that the serial monitor resets the arduino when it is opened. I have not tried yet to reset the arduino manually. It seems that my code is running fluently now as expected.
What I am doing is posting sensor readings whenever the server (Wifly) is called by entering its IP address into a browser. What I want to do is enter that data into a SQL database. Does anyone have experience when it comes to inserting data into a database from the Wifly?
Well, no, I don't have experience with that shield, but I suspect it's not possible to talk directly to a database from the Arduino. An idea is to have a webapplication on a PC that acts as a bridge between the (http) requests coming from the Arduino and the database.
Your arduino doesn't have anything like enough power to run a sql database so it will have to run elsewhere, presumably on a PC. So, you need some code running on the PC to receive data from the arduino and perform the SQL operations. You could have a PC program listening on the serial port for example. Since you're using a wifi shield, I assume you'd like to send data from it. You could send UDP packets to a listener on your PC. Easiest though (for coding on the PC side at least) is to run a web server on the PC and run the arduino as a client. Use a GET or POST to send sensor data to the web server and user PHP, perl or your language of choice there to push the data into it. If you don't fancy running a web server, take a look at pachube.
Really no need to make it this complicated with linux libraries and pc's and udp & http.........
Sql server allows stored procedures, you can install an email interface to send and receive emails in the database (well documented).
The arduino has an ethernet shield.....(well documented)
Email is just text commands and bytes sent to a pre-defined port (well documented)
There is at least one thread recently on sending emails from arduino. (user: zoomkat I think)
Package up all your data as an 'email' and pop it off to either :
Your sql database directly (you need to handle corrupt deliveries/non delivery)
To a relay remailer (the system does it all for you.)