Close

Multiplots for Arduino

A project log for Lighthaus

Earthquake detection & early warning systems

ryan-logsdonRyan Logsdon 07/07/2018 at 01:580 Comments

We've run into a hardware issue, needing an FTDI board to connect our 3.3 volt Arduino Pro Mini boards' row of programming headers to our laptops. Those boards are on their way now, and with them in place, we'll be able to directly interface with our custom hardware.  In the meantime, we've switched gears to get the software ready.

In order to evaluate our 7 different MEMS accelerometers, we're going to need to test a few things:

* signal drift
* delay between physical inputs (motion) and signal outputs
* ease of programming (we've already settled on I2C communication instead of SPI communication because of the libraries that are at the ready for I2C on the Arduino; plus the Arduino Pro Mini boards have nicely labeled 

And in order to do this, we need 3 plots to stream out from our Arduinos.  

To access the serial plotter, we simply setup the sketch with:

void setup() {
  Serial.begin(9600);
}

Next, we want to keep the graph from jumping erratically when there are very high or low values read from the chips, so we plot a constant upper bound and lower bound in the loop:

void loop() {
  Serial.print(1.0);        // upper bound of expected data
  Serial.print(-1.0);       // lower bound of expected data
  
  // ...
  
}

And all that's left is to plot the input data from the I2C comm:

I2c.read(EVAL_CHIP_1, 0x03, 6);
  x = I2c.receive() << 8;
  x |= I2c.receive();
  y = I2c.receive() << 8;
  y |= I2c.receive();
  z = I2c.receive() << 8;
  z |= I2c.receive(); 
  
  Serial.println(x + ', ' + y + ', ' + z);

Notice that the final "Serial.println(...)" is a full printLINE and not just a print.

With this code, we should be able to plug-and-play with our custom boards next week!  Let the accelerometer evaluations begin!

Discussions