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, checkout 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 a Serial Monitor, and the Serial Plotter, you can find these options under the Tools tab. Both of these output methods has it's own function found after the loop() section of the program. 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.
Note: you need the two BMA250 supporting files (the .cpp and .h) for the .ino to work.
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 email@example.com.
Show us what you make by tagging @TinyCircuits on instagram, twitter, or facebook so we can feature it!
Thanks for making with us!