Skip to content

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

Notifications You must be signed in to change notification settings

davicedraz/raspberry-usb-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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

Usage

Create a __main__.py file in this directory:

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:

$  python3 __main__.py &

Install

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

$ make install

Or simply:

$ 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:

$ make build

Test

$ make tests

Run

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

$ make run

Or simply run the good old build & run:

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

Run USB thread only

Start the script creating a background proccess:

$ python usb.py &

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published