Using the TinyZero Accelerometer

by Laverena Wienclaw November 21, 2018

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: 

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!

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 x, y, and z, and the temperature in degrees Celsius.

You cannot use the Serial Plotter and Serial Monitor at the same time in Arduino.

Zip File of Program

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 have never used the Serial Plotter, now is a good time! There is a function in the Arduino sketch 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 is 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.


    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!



    Laverena Wienclaw
    Laverena Wienclaw

    Author



    Also in Projects

    TinyLily Halloween: Harry Potter Luna Lovegood Spectrespecs
    TinyLily Halloween: Harry Potter Luna Lovegood Spectrespecs

    by Laverena Wienclaw October 15, 2019

    Light up your world with Spectrespecs to see all the wrackspurts out there making minds fuzzy! Using TinyLily RGB LEDs, you can...

    View full article →

    Tiny Weather Station Tutorial
    Tiny Weather Station Tutorial

    by Zachary Lee October 03, 2019

    In this simple tutorial, we will show you how to build a very low power weather station that measures wind...

    View full article →

    RGB LED Scooter
    RGB LED Scooter

    by Hunter Hykes October 01, 2019

    Jazz up your scooter with RGB LED Underglow sensitive to the scooter's speed. This project uses the Digital Hall Sensor Whisker...

    View full article →