In this tutorial, we will use Cayenne to capture some accelerometer readings on their nice Internet of Things dashboard that can be accessed from computer or mobile application!
This tutorial builds on a couple of things, so you may want to check out the TinyZero Setup Tutorial, the TinyZero with Accelerometer BMA250 Tutorial, and the WiFi TinyShield connection tutorial before getting started with this project.
You will build this setup by connecting the WiFi shield to the TinyZero board with the 32-pin connectors. You can snap them together like legos, it's that easy.
This part may be a little involved, but it'll be broken down into a lot of small steps.
Create a Cayenne account (or use a previous one)
Create a device:
Click in the top left: Add new.../Device/Widget and then you should be opened to this screen where you can select Arduino:
Make the selections Arduino Pro / Wifi101 Shield. You should see your Cayenne mqtt username, password, and client id on this page:
In order to move on from this screen, the board must connect to Cayenne via your WiFi and Cayenne authentication info, so we will move on to the Arduino IDE to prepare for the program by downloading some libraries:
Go to Sketch/Include Library/Manage Libraries... and type in WiFi101 in the window that pops up, click Install on the library called WiFi101:
You'll use the same process to Install the library CayenneMQTT:
Now you can download and program your TinyZero!
Plug in your USB to your TinyZero and make sure your Tools tab choices are correct! Make the following Tools selections to connect to your TinyDuino:
So now we can download or create files for the program below. 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, error windows will pop up immediately to let you know you need to fix this.
You’ll need to change:
Once you make those changes and download the program, you must open up the Serial Monitor in the Arduino IDE under Tools/Serial Monitor. If you do not open the Serial Monitor, the program won't move forward from the line that says "while(!SerialUSB);" so the WiFi won't connect until you do this step.
The Serial Monitor will print out the values from the BMA250 accelerometer sensor so you can see them before they are sent to Cayenne.
Speaking of Cayenne, once the WiFi connects with your authentication info, the Cayenne screen should find your device and open up to your dashboard:
At the end of the program, a function called CAYENNE_OUT_DEFAULT() will be sending the x, y, z, and temperature data read from the BMA250 sensor to Cayenne. This data should show up after a minute or two and look something like this:
You should see a '+' button to add those channels to your dashboard permanently.
Now that you have data coming from the BMA250 sensor, you can re-label and make the data look a little nicer!
You can click on the graph icon on any of the data blocks to see a graph of data readings over time.
Customize your dashboard however you like to use your new Internet-Connected device! Cayenne even has an app you can use to monitor your data readings on the go.
If you have any questions or feedback, feel free to email email@example.com or make a post on our forum.
Share your tiny IoT projects by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!
Thanks for making with us!