This tutorial will guide you through reading values from the Accelerometer Sensor that can be populated on the TinyZero processor, you can also use this tutorial for the TinyZero and the Accelerometer TinyShield. The code included in this tutorial shows you how to display the accelerometer sensor values to the Serial Plotter, and the Serial Monitor.
If you want more info on the BMA250 sensor itself, check out the datasheet for all the specs!
All you need to do here is plug your USB cable from TinyZero to computer.
Now you just need to open up your Arduino IDE and make sure you're hooking up the board correctly!
TinyZero Tools selections for the program in this tutorial.
In this program, the BMA250 has the four available sensor readings output to the Serial Monitor, OR the Serial Plotter, you can find these options under the Tools tab. The Serial Monitor will output the data readings of the sensor, which may not be very easy to read long term. The Serial Plotter, however, graphs the sensor data, and is nice to look at when you want to see data over time. The four variables being output are three axes of perpendicular acceleration that are measured and output by the sensor as x, y, and z, and the sensor can read out the temperature in degrees Celsius.
You cannot use the Serial Plotter and Serial Monitor at the same time in Arduino.
When downloading these files or copying and pasting them into new files, make sure the folder they're in has the same name as the .ino program so that everything compiles correctly in Arduino. Often, window errors will pop up immediately to let you know you need to fix this.
If you've never used the Serial Plotter, now's a good time! There is a function in the .ino program above that will print the accelerometer sensor data to the Serial Plotter. This tool makes a good visualization of the range of sensor readings! Here's an example of my data when I was waving the sensor around every couple of seconds:
The constant, turquoise-colored value is the temperature reading. You can find out which color corresponds to the axes by moving the sensor in different directions and keeping track of which value is changing when you do.
As always, if you have any questions or feedback, feel free to email us at firstname.lastname@example.org.
Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!
Thanks for making with us!