Storing data from an Arduino

Discussion in 'The Projects Forum' started by potentialeemajor, Jun 5, 2014.

  1. potentialeemajor

    Thread Starter New Member

    May 27, 2014
    3
    0
    Hey guys,

    I have a project that requires up to 20 arduinos, each collecting its own data, and I need to collect all that data on one computer. I've looked in arduino to arduino i2c, but I'm not sure if it's the most efficient method. Any ideas?

    On a side note, if the i2c is the best method, I wasn't sure how to combine the code for my circuit and the i2c code. In my case, the slaves are the writers and the master is the reader. I have the master code, but I'm having trouble with the slave code.

    This is the code for my circuit:

    Code ( (Unknown Language)):
    1.  
    2. #define inPin0 0
    3.  
    4. void setup(void) {
    5.  
    6.   Serial.begin(9600);
    7.   Serial.println();
    8.      
    9. }
    10.  
    11. void loop(void) {
    12.    
    13.   int pinRead0 = analogRead(inPin0);
    14.   float pVolt0 = pinRead0 / 1024.00 * 5.0;
    15.   Serial.print(pVolt0);
    16.   Serial.println();
    17.    
    18.   delay(100);
    19.    
    20. }
    21.  
    22.  
    23. Can I incorporate it with the i2c code as follows?
    24. #include <Wire.h>
    25.  
    26. #define inPin0 0
    27.  
    28. void setup() {
    29.  
    30.   Wire.begin(2);
    31.   Wire.onRequest(requestEvent);
    32.    
    33. }
    34.  
    35. void loop() {
    36.  
    37.   delay(100);
    38.    
    39. }
    40.  
    41. void requestEvent()
    42. {  
    43.   Wire.write("1");
    44.   int pinRead0 = analogRead(inPin0);
    45.   float pVolt0 = pinRead0 / 1024.0 * 5.0;
    46.   Wire.write((byte)pVolt0);  
    47.  
    48. }
    49.  
    Thanks ahead of time!
     
    Last edited by a moderator: Jun 5, 2014
  2. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
  3. KL7AJ

    AAC Fanatic!

    Nov 4, 2008
    2,040
    287
    http://www.dataq.com/
    Here's about the cheapest DAQ card you can get.
     
Loading...