-
1Step 1
Here's the wiring diagram for the data logger- it's pretty simple. For the sake of clarity I'm only showing one accelerometer connected but the other sensors are connected in a similar fashion. As I go through the build instructions I'll show how to solder all of the components on a proto board, mount everything in a weatherproof enclosure and build a wiring harness for the sensors step by step so this will be really easy to build.
-
2Step 2
Here's the code for the Spark Core. The programming for this is very similar to an Arduino. Once you go to the Spark website and get your Core setup you just click on the BUILD tab, create a new App and paste in the code and it'll upload the code over your WiFi network.
Here's the code-
// Define the pins we're going to call pinMode on
int sensorPin1 = A0; //analog pin 0
int sensorPin2 = A1;
int sensorPin3 = A2;
int sensorPin4 = A3;
int sensorPin5 = A4;
int sensorPin6 = A5;
int sensorValue1 = 0; // variable to store the value coming from the sensor
int sensorValue2 = 0;
int sensorValue3 = 0;
int sensorValue4 = 0;
int sensorValue5 = 0;
int sensorValue6 = 0;
// This routine runs only once upon reset
void setup() {
Serial1.begin(115200);
}
// This routine gets called repeatedly, like once every 5-15 milliseconds.
// Spark firmware interleaves background CPU activity associated with WiFi + Cloud activity with your code.
// Make sure none of your code delays or blocks for too long (like more than 5 seconds), or weird things can happen.
void loop() {
// read the value from the sensor:
sensorValue1 = analogRead(sensorPin1);
sensorValue2 = analogRead(sensorPin2);
sensorValue3 = analogRead(sensorPin3);
sensorValue4 = analogRead(sensorPin4);
sensorValue5 = analogRead(sensorPin5);
sensorValue6 = analogRead(sensorPin6);
// print the results to the serial monitor:
Serial1.print(millis());
Serial1.print(',');
Serial1.print(sensorValue1);
Serial1.print(',');
Serial1.print(sensorValue2);
Serial1.print(',');
Serial1.print(sensorValue3);
Serial1.print(',');
Serial1.print(sensorValue4);
Serial1.print(',');
Serial1.print(sensorValue5);
Serial1.print(',');
Serial1.println(sensorValue6);
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.