Log serial data to sd card only when data is received

Hi

For my internship i need to make a serial logging system that logs the weight of something. The interval between different weighings is variable. How can i program that it only logs data when send?

And how can i get the serial data in the arduino and the arduino stores it to the sd card?

Thanks

You could constantly poll the input, but only use the data if it not zero. In that event, use it and poll again.
The examples in the IDE show how to set up the SD. You print numbers - myFile.print - just like you print to serial.

Nick_Pyner:
You could constantly poll the input, but only use the data if it not zero. In that event, use it and poll again.
The examples in the IDE show how to set up the SD. You print numbers - myFile.print - just like you print to serial.

thank you!

How can i program that it only logs data when send?

I translate this to mean:
How do I only log data when the weigh-cell sends data
Which is easy enough, but a weigh cell will (probably) send data continously, so the question probably is
How do I log data only when something is weighed?
That would mean to remember the last 2-5 readings and notice when it stabilises (ie the last weighing is close to the average of the last N weighings) nd it is not close to zero.

But I'd much prefer you explain what you are trying to do, and links to the equipment that needs interfacing.

how can i get the serial data in the arduino?

Depends on your Arduino. If it s a simple UNO you either use the hardware serial pins and the Serial.calls, or you use another pin and use the SoftSerial library. (I have checked your "last posts" and you've been asking about this project for some time - presumably you have been told about voltage problems when reading from serial device.) If it is a bigger Arduino like the Mega you have several Serial ports you can use.

[ how .. ]the arduino stores it to the sd card?

When you get a SD-shield and use the SD-library SD - Arduino Reference it has a open, write, close calls. And examples.