An open API service indexing awesome lists of open source software.

https://github.com/davicedraz/raspberry-usb-csv

Automatically detects new USB disks and copy to it the actual sensors readings on a .csv file
https://github.com/davicedraz/raspberry-usb-csv

csv-export raspberry-pi usb-drive

Last synced: 8 months ago
JSON representation

Automatically detects new USB disks and copy to it the actual sensors readings on a .csv file

Awesome Lists containing this project

README

          








# Automatic .csv backup to USB Disks

This program creates an execution routine that basically works by: when connecting a USB drive to the device's USB port, the user will only needs to wait for an automatic copy of all the data collected by the device in .csv format. In order to have access to the data quickly when he has physical access to the machine and that it is not necessary to have access to the internet.

The script `save.sh` performs this backup once, exactly at the moment you execute it, as an example of the continuous operation of the software.

## Setup

Create a .env file and set the enviroment variables needed, for example:

```bash
FILE_PATH = ./temp/google_stock_data.csv
SERIAL_PORT = 'COM1'
DEBUG = 1
```

## Usage

Create a ```__main__.py``` file in this directory:

```python
import export as export
from config import config as env

backup_thread = export.USBListener(thread.new_drive_signal)

if __name__ == "__main__":
payload = {} #your json dict
backup_thread.start()
print("Waiting for USB connections ...")

export.write_data(payload)
```

Start the script creating a background proccess:

```bash
$ python3 __main__.py &
```
----

## Install

Pip will install all the libraries required by the following command:

```bash
$ make install
```

Or simply:

```bash
$ pip install -r requirements.txt
```

## Build
In order to generate a package ready for execution and loading on the desired device, we recommend that you use the build command:

```bash
$ make build
```

## Test

```bash
$ make tests
```

## Run
This command will execute the build product file generated by the build command:

```bash
$ make run
```
Or simply run the good old build & run:

```bash
$ python setup.py install && python firmware.py
```

## Run USB thread only

Start the script creating a background proccess:

```bash
$ python usb.py &
```