Pages: [1]   Go Down
Author Topic: Stand Alone Arduino?  (Read 903 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Code:
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: [code] [/code] tags added.
« Last Edit: January 11, 2012, 12:33:29 am by Coding Badly » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17306
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Lefty
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19306
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

0
Offline Offline
God Member
*****
Karma: 2
Posts: 596
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 :-)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies!

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?

thanks,

Morgan Anderson
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 596
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

New Jersey
Online Online
Faraday Member
**
Karma: 72
Posts: 3760
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 596
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Your arduino doesn't have anything like enough power to run a sql database

To be precise it wouldn't need to host the server, just the client access libraries.

Code:
[me@mypc] ls -lha /usr/lib/libmysqlclient.so.16.0.0
-rw-r--r-- 1 root root 2,1M 2011-02-10 10:30 /usr/lib/libmysqlclient.so.16.0.0

That's on a 64 bit Ubuntu installation.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 98
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :
1. Your sql database directly (you need to handle corrupt deliveries/non delivery)
2. To a relay remailer (the system does it all for you.)
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 596
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Really no need to make it this complicated with linux libraries
ù

It was just to show that a client rdbms library can hardly fit into an arduino, hence the need to have a PC bridge the gap between arduino and the db.
Logged

Pages: [1]   Go Up
Jump to: