Build a Turbidity Sensor to Monitor and Control Microalgae Biomass Density

Log data via Raspberry Pi

Log data by a Yun Shield was a better option than making a board with RTC1307 Real-time unit and a SD module breakout. We could even simplify to circuit by using Raspberry Pi.

First off, if using Raspberry Pi is new to use, please have a look at another tutorial to set up Raspberry Pi from the beginning.

The idea is to capture the Serial.print() data from Arduino Serial and on Raspberry Pi running a Python script to listen to the USB port, add a timestampe from the Linux system. Finally, the data is saved in a text file (or .csv file). The file can be excessed by VNCViewer, FTP, or Samba Share Folder.

Schematics:
Concept: Log data from USB
A simple approach to log data via Raspberry Pi.

First, download the code for Arduino here, stored in GitHub.

And here the Python script to capture the data, stored on GitHub.

To excute the Python script, download it and save it to your RPi. For execution, please to have a look at this one.

Here is the code to send data to Raspberry Pi for recording:

if (intercept == 60){
    // make a string that will print out to Serial line, and be logged by computer
    String dataString = "";
    averageRead = round((read25+read35+read45+read55)/4);

    dataString += String(averageRead);
    dataString += ",";
    dataString += String(setValue);
    dataString += ",";
    dataString += String(_pumpON);
    _pumpON = 0;       //reset counter

    Serial.println(dataString); //Python script will catch this line and save to the computer
}