Using the TinyZero Accelerometer
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!
Materials
Hardware:
- Micro USB Cable (not pictured)
- TinyZero with Accelerometer
- Optional: Battery
Software:
- Arduino IDE
- BMA250 Files (Included later in the tutorial!)
Some important things:
- The BMA250 sensor is sensitive, with a wide range of values, so you probably need to establish value limits for functionality in future projects using the sensor. (ie. if(accReadings < 500 or accReadings > 400){ // Do something } )
- This accelerometer has the extra feature of a temperature reading, so you don't need to buy a separate temperature sensor if you need temperature readings in your project.
- You probably hold a sensor like this every day, it's the reason your smartphone screen knows when to rotate the display!
- Accelerometer sensors measure acceleration, so you can do projects that measure how fast something can accelerate or IoT applications that involve a sudden movement you need to detect. Common hobby projects include pedometers, robot behaviors, or you can trigger events based on movement.
Step 1: Assembly
All you need to do here is plug your USB cable from TinyZero to computer.
Step 2: Software
Now you just need to open up your Arduino IDE and make sure you're hooking up the board correctly!
- Board -> TinyZero
- Port -> COM## (If you're not sure which Port your Arduino is connected to, check this out for Windows/Mac help)
- Programmer: "Arduino as ISP"
TinyZero Tools selections for the program in this tutorial.
Step 3: The Code!
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.
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.
Contact Us
As always, if you have any questions or feedback, feel free to email us at info@tinycircuits.com.
Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!
Thanks for making with us!