Storing data from an Arduino

Thread Starter

potentialeemajor

Joined May 27, 2014
3
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:

Rich (BB code):
#define inPin0 0
 
void setup(void) {
 
  Serial.begin(9600);
  Serial.println();
     
}
 
void loop(void) {
   
  int pinRead0 = analogRead(inPin0);
  float pVolt0 = pinRead0 / 1024.00 * 5.0;
  Serial.print(pVolt0);
  Serial.println();
   
  delay(100);
   
}


Can I incorporate it with the i2c code as follows? 
#include <Wire.h>

#define inPin0 0
 
void setup() {
 
  Wire.begin(2);
  Wire.onRequest(requestEvent);
   
}
 
void loop() {

  delay(100);
   
}

void requestEvent()
{   
  Wire.write("1");
  int pinRead0 = analogRead(inPin0);
  float pVolt0 = pinRead0 / 1024.0 * 5.0;
  Wire.write((byte)pVolt0);  

}
Thanks ahead of time!
 
Last edited by a moderator:

KL7AJ

Joined Nov 4, 2008
2,229
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:

Rich (BB code):
#define inPin0 0
 
void setup(void) {
 
  Serial.begin(9600);
  Serial.println();
     
}
 
void loop(void) {
   
  int pinRead0 = analogRead(inPin0);
  float pVolt0 = pinRead0 / 1024.00 * 5.0;
  Serial.print(pVolt0);
  Serial.println();
   
  delay(100);
   
}


Can I incorporate it with the i2c code as follows? 
#include <Wire.h>

#define inPin0 0
 
void setup() {
 
  Wire.begin(2);
  Wire.onRequest(requestEvent);
   
}
 
void loop() {

  delay(100);
   
}

void requestEvent()
{   
  Wire.write("1");
  int pinRead0 = analogRead(inPin0);
  float pVolt0 = pinRead0 / 1024.0 * 5.0;
  Wire.write((byte)pVolt0);  

}
Thanks ahead of time!
http://www.dataq.com/
Here's about the cheapest DAQ card you can get.
 
Top