Storing continuous data on Arduino and sending it to Pi

Hello everyone,

I wanted to know what would be the best method to store current sensor data on arduino. Ultimately, I want to take this data that is stored in arduino and send it over to RPi for graphing purposes. Also, what would be the best way to send this type of data over to the RPi?

Thank you

mraf:
I wanted to know what would be the best method to store current sensor data on arduino.

If speed is a design factor and you don’t care too much about physical portability, EEPROM is your best bet. Otherwise an SD card should work fine.

mraf:
Also, what would be the best way to send this type of data over to the RPi?

The easiest thing to use would be a UART to USB converter. The UART/TTL side would be connected to your Arduino’s serial port and the USB plug would be connected to your RPi. Software-wise, you can use Python on your RPi to take advantage of the easy to use libraries pySerialTransfer (pip-installable) and SerialTransfer.h (installable via the Arduino IDE’s Libraries Manager).

Both of these compatible libraries have highly efficient and robust packetizing/parsing algorithms with easy to use APIs.

Example Python Script:

from time import sleep
from pySerialTransfer import pySerialTransfer as txfer

if __name__ == '__main__':
    try:
        link = txfer.SerialTransfer('COM13')
        
        link.open()
        sleep(2) # allow some time for the Arduino to completely reset
    
        link.txBuff[0] = 'h'
        link.txBuff[1] = 'i'
        link.txBuff[2] = '\n'
        
        link.send(3)
        
        while not link.available():
            if link.status < 0:
                print('ERROR: {}'.format(link.status))
            
        print('Response received:')
        
        response = ''
        for index in range(link.bytesRead):
            response += chr(link.rxBuff[index])
        
        print(response)
        link.close()
        
    except KeyboardInterrupt:
        link.close()

Example Arduino Sketch:

#include "SerialTransfer.h"

SerialTransfer myTransfer;

void setup()
{
  Serial.begin(115200);
  Serial1.begin(115200);
  myTransfer.begin(Serial1);
}

void loop()
{
  myTransfer.txBuff[0] = 'h';
  myTransfer.txBuff[1] = 'i';
  myTransfer.txBuff[2] = '\n';
  
  myTransfer.sendData(3);
  delay(100);

  if(myTransfer.available())
  {
    Serial.println("New Data");
    for(byte i = 0; i < myTransfer.bytesRead; i++)
      Serial.write(myTransfer.rxBuff[i]);
    Serial.println();
  }
  else if(myTransfer.status < 0)
  {
    Serial.print("ERROR: ");
    Serial.println(myTransfer.status);
  }
}

Thank you! This was really helpful. I will give that a try.