Exploring hypothesis-driven research using Arduino boards and Matlab
Summary
In this activity, students explore hypothesis-driven research through the development of an experiment using Arduino Uno style microcontroller boards and Matlab. This project encourages students to develop a research hypothesis, use an Arduino-style microcontroller board to collect data, and use Matlab to perform data analysis. The objectives of this activity are for students to:
- Be able to formulate a research question and hypothesis
- Be able to integrate data collection and data analysis in Matlab
- Be able to use some basic statistical methods to assess a hypothesis
- Be able to graphically display data and communicate results effectively
- Be aware of the research process
This is a 6-week project that was developed for a freshman, Mechanical Engineering programming course.
Learning Goals
The goals of this project are:
- to introduce students to hypothesis-driven research
- to develop and reinforce programming skills in Arduino (C++) and Matlab
- to practice oral, graphical, and written communication of scientific data
- to develop teamwork skills
The objectives of this activity are for students to:
- Be able to formulate a research question and hypothesis
- Be able to integrate data collection and data analysis in Matlab
- Be able to graphically display data and communicate results effectively
- Be aware of the research process
Context for Use
The project is a 6-week final project in a freshman, Mechanical Engineering programming course at a large public university. Class size is typically between 50 and 100 students. The project is completed by teams of 5-6 students. Students each purchase the Sparkfun Inventor's Kit 4.1 (https://www.sparkfun.com/products/15267) and additional sensors are available to the students. In this course, students have already completed 7 weeks of Arduino IDE (C++) programming and are familiar with the elements of their kits. In parallel to the project, the course covers Matlab programming including conditional statements, loops, functions, and plotting. The project could be simplified and adapted to other types of courses by providing Arduino code and hardware setups rather than expecting students to develop that code. Sample code for this using the ultrasound distance sensor is included in Teaching Notes.
Course structure: classschedule.pdf (Acrobat (PDF) 136kB Nov8 21)
Description and Teaching Materials
This project has several stages:
- Learn about research through interviews and videos
- Develop a research question and hypothesis. Plan how one might investigate this research question using the sensors available.
- Develop the Arduino code and breadboard wiring to collect the data.
- Develop Matlab code to import the data via the serial port, save the data.
- Use Matlab to graphically display and analyze the data.
- Present the research through a poster presentation and research report.
The attached file describes the project deliverables for this project.
Project 3.pdf (Acrobat (PDF) 116kB Sep17 21)
The students are also given access to a library of videos and reference cards on the wiring of each sensor type with the Arduino boards. The attached file gives the students some ideas of things that could be measures and a list of sensors available to them outside of those in the Sparkfun Inventor's Kit.
Project Ideas (Microsoft Word 2007 (.docx) 21kB Sep17 21)
Prior to the data analysis portion of this project, students complete laboratory exercises and homework assignments to learn to code statistical tests in Matlab including mean, standard deviation, and linear regressions. An example of these assignments is included here:
Linear Regression Homework (Acrobat (PDF) 72kB Sep10 21)
The final component of project is to create a poster presentation of the research at a university undergraduate research showcase. A template is provided to the students based on the university guidelines for the showcase.
Project Poster Template (PowerPoint 2007 (.pptx) 142kB Sep17 21)
The students also complete a project report. The template for the report is provided below:
ProjectReportFormat.pdf (Acrobat (PDF) 64kB Nov8 21)
These deliverables fit within a broader course structure which begins introducing Arduino IDE (C++) programming and then transitions to Matlab programming during the second portion of the semester.
Teaching Notes and Tips
There are several options for porting data from Arduino to Matlab. These include:
- Copying data from the Arduino serial monitor into a text file and loading that text file into Matlab
- Using serial communications to directly pull data from the device into Matlab
- Using Matlab's Arduino package add on.
We chose to use #2 with #1 being an option as well. Installing the Arduino package onto student's personal computers and lab computers proved to be too cumbersome to be feasible. For #2, Matlab has changed the serial commands as of version R2021a, so students with older versions may need to use the older commands. In the first semester, many groups chose to note data down and directly type it into their Matlab code if they were measuring single data points.
Below is example code for collecting ultrasound distance sensor data in the Arduino IDE and using serial communications in Matlab to import the data (in R2021b).
Arduino Code: Arduino Code ( 2kB Sep17 21)
Matlab Code: Matlab Code to read serial port (Matlab File 771bytes Sep17 21)
Assessment
Each deliverable is graded based on satisfactory progress on each of the weekly tasks.
The students are given a guide for the format of the project report and project research poster. Students are graded using a rubric based on 1. meeting the project requirements, 2. clear and complete communication of results.
Example Poster Rubric: Project3rubric.pdf (Acrobat (PDF) 35kB Nov8 21)
Peer evaluations of team members are collected through CATME software ( http://www.CATME.org ).
References and Resources
Sparkfun Inventor's Kit used in this course: https://www.sparkfun.com/products/15267
This kit includes the following sensors:
Ultrasound Distance Sensor https://www.sparkfun.com/products/15569
Temperature Sensor (TMP36) https://www.sparkfun.com/products/10988
Mini Photoresistor https://www.sparkfun.com/products/9088
Basic Button https://www.sparkfun.com/products/14460
We also provided the following sensors as options:
Accelerometer https://learn.adafruit.com/adafruit-analog-accelerometer-breakouts/overview
Accelerometer http://wiring.org.co/learning/basics/accelerometer.html
Load Cell (HX711) https://www.sparkfun.com/products/13879 https://www.sparkfun.com/products/13329
Rotary Encoder https://www.adafruit.com/product/377
Anemometer https://moderndevice.com/product/wind-sensor/
Wheel Encoder https://www.youtube.com/watch?v=oLBYHbLO8W0
Sparkfun video series for Arduino Coding: https://www.youtube.com/playlist?list=PLBcrWxTa5CS0u-rQNkGtLMg1yA7h56r6_
Communicating from Arduino to Matlab using Serial Communications (older versions of Matlab): https://www.youtube.com/watch?v=ymWXCPenNM4
Communicating from Arduino to Matlab using Serial Communications (R2021a and later versions of Matlab): https://www.mathworks.com/help/matlab/import_export/write-and-read-serial-port-data.html
Arduino Package within Matlab (we didn't use this but others might): https://www.youtube.com/watch?v=wLrVQpzva6s
https://www.youtube.com/watch?v=8NQ1h0gGgX8