My arduino gets some data from sensors and save it into EEPROM. Now, I want that when I connect my arduino to PC there should be a software(like sketch) which can fetch data from arduino's EEPROM processes it and saves it into a file in PC. I am willing to create such a software but how will I then communicate with arduino like Sketch does?
3 Answers
Just use serial communication. Make sure you know which port your Arduino is recognized in your system, make a sketch to send data through Arduino's serial communication and try making a simple Node.js application using serialport package which will receive your data. There is a code sample where you can start from. Just set the port and start receiving data. And that's good, using Node.js you are really close to web tools, so it's easy to migrate your application to web.
It's really simple and you can get it done in a few minutes, even if you have not been introduced to node.
These kind of embedded applications have been accepted by Node.js and there are plenty of robotics projects which use node on the web.
var SerialPort = require("serialport").SerialPort
var serialPort = new SerialPort("/dev/ttyACM0", {
baudrate: 57600
});
Usually Arduino is recognized as ttyACM0 on Unix-based systems. With this line of code you establish a serial communication with your board.
Going further you can register events like data, which is fired when data comes from Arduino:
// it opens the connection and register an event 'data'
serialPort.on("open", function () {
console.log('Communication is on!');
// when your app receives data, this event is fired
// so you can capture the data and do what you need
serialPort.on('data', function(data) {
console.log('data received: ' + data);
});
});
In this example your app just receives data and log it to your terminal.
The options that I see:
- Via serial - this can either be done wirelessly via Bluetooth serial adapter, or via the standard USB connector. Your program will have to have a way of sending the data - some way to indicate that you want to download the data.
- Transfer via ICSP - these are the 2x3 grid of pins on your Arduino. You can download the data, without having to write any code. You will need something like a USBASP - they're cheap. You can download the entire EEPROM, and dissect it once you have it on your computer.
I have a vague recollection that EEPROM may be overwritten when you upload a sketch, so if you want to use serial (the first option), make sure your sketch already knows how to transfer the data before you collect it. This is not a limitation for ICSP.
-
Or you can set the EESAVE fuse via ISP in order to preserve EEPROM contents when flashing. But really, your sketch should know how to handle the data. A primitive serial interface is easy to write into almost anything. May 7, 2015 at 21:00
You should specify what programming language/compiler/IDE you want to use for the part on your pc.
I would suggest using "Processing" - https://processing.org/ it's a similiar IDE as the arduino IDE and the coding is also a bit similiar. You can use a serial library to receive data from USB/COM port.
Processing has the ability to create a window with graphics. You could read the position of something with your arduino, then send it to 'processing' and it will draw the object on the screen (after a bit of coding).
Guide: https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing