Tony.Yan @anu.edu.au
March 2024
First, download Arduino IDE (integrated development environment) from https://www.arduino.cc/en/software.
Once you have the Arduino IDE installed, we need to verify that the Arduino works by connecting it to your computer and the IDE.
As illustrated in the figure below, I also strongly recommend mounting your Arduino Nano onto a breadboard and connecting the 5V and 3.3V to each power rail on the breadboard. This makes connecting various modules much simpler later.
Our Arduino Nano uses a USB Type-C connector; you can connect it to your computer with any Type-C cable and Arduino can be powered from Type-C.
The Arduino IDE will preload a default BareMinimum script (Menu -> File -> Examples -> Basic -> BareMinimum
) so you can test your connections to your Arduino.
Configure the IDE to our specific Arduino by clicking Select Board
Select Arduino Nano
and its USB Serial Port
.
Then, you can try uploading the BareMinimum script onto your Arduino by pressing the Upload
icon (or Menu -> Sketch -> Upload
or Cmd-U
).
You might experience the following error saying the programmer is not in sync
In that case, you need to go to Menu -> Tools -> Processor and select: ATmega328P (Old Bootloader)
Then try upload again and it should upload without error.
If there are other Arduino setting-up issues, feel free to contact us.
You might find the following Arduino Pin layout helpful (available at https://content.arduino.cc/assets/Pinout-NANO_latest.pdf).
For a more detailed guide on using the MAX6675 module, please read https://lastminuteengineers.com/max6675-thermocouple-arduino-tutorial/
The MAX31855 is a newer version MAX6675, but they work basically the same.
The kit includes
The following table shows the connections used in the sample code:
MAX6675 | Arduino |
---|---|
VCC | 3.3V or 5V |
GND | GND |
SCK (Serial Clock for synchronising data transmission) | D6 |
CS (Chip Select pin) | D5 |
SO (Serial data Out) | D4 |
You also need to grab a code library to use the MAX6675 module. Go to Menu -> Sketch -> Include Library -> Manage Libraries
(or Shift-Cmd-I
or click on the Library icon in the left sidebar) and search for MAX6675
.
I used the official library from Adafruit, but you’re of course welcome to experiment with other ones.
Once the library is installed, open the provided sample code at Menu -> File -> Examples -> MAX6675 library -> serialthermocouple
; there’s also a copy of it named MAX6675SerialLogger.ino
in this repository.
Try uploading their sample script and opening the serial monitor (Menu -> Tools -> Serial Monitor
or Shift-Cmd-M
or the top right Magnifying glass icon). You should see the thermocouple printing the temperatures onto the Serial Monitor. You could also show their timestamps by toggling the clock icon on the right.
For a more detailed guide on using the DS18B20 module, please read https://lastminuteengineers.com/ds18b20-arduino-tutorial/ .
We provide the DS18B20 sensor that comes in the waterproof probe. You also need a 4.7kΩ resistor between VCC and DQ.
DS18B20 | Arduino |
---|---|
VCC | 3.3V or 5V |
GND | GND |
DQ (Data Queue) | D2 |
You also need to grab a code library to use the DS18B20 module. Go to Menu -> Sketch -> Include Library -> Manage Libraries
(or Shift-Cmd-I
or click on the Library icon in the left sidebar) and search for DS18B20
.
I used the official library from DallasTemperature
, but you’re of course welcome to experiment with other ones.
Once the library is installed, open the provided sample code at Menu -> File -> Examples -> DallasTemperatures -> Single
; there’s also a copy of it named DS18B20Simple.ino
in this repository.
Try uploading their sample script and opening the serial monitor (Menu -> Tools -> Serial Monitor
or Shift-Cmd-M
or the top right Magnifying glass icon). You should see the thermometer printing the temperatures onto the Serial Monitor. You could also show their timestamps by toggling the clock icon on the right.
Menu -> File -> Examples -> DallasTemperatures -> TwoPin_DS18B29
.For a more detailed guide on using the MPU6050 module, please read https://lastminuteengineers.com/mpu6050-accel-gyro-arduino-tutorial/.
You might need soldering skills to make the pins.
MPU6050 | Arduino |
---|---|
VCC | 3.3V or 5V |
GND | GND |
SCL (Serial Clock Line) | A5 (SCL) |
SDA (Serial Data Line) | A4 (SDA) |
Other pins not connected. |
You also need to grab a code library to use the MPU6050 module, go to Menu -> Sketch -> Include Library -> Manage Libraries
(or Shift-Cmd-I
or click on the Library icon in the left sidebar), and search up MPU6050
.
I used the official library of Adafruit
, but you’re of course welcome to experiment with other ones.
Once the library is installed, open the provided sample code at Menu -> File -> Examples -> Adafruit MPU6050 -> basic readings
; there’s also a copy of it named MPU6050Basic.ino
in this repository.
Try uploading their sample script and opening the serial monitor (Menu -> Tools -> Serial Monitor
or Shift-Cmd-M
or the top right Magnifying glass icon). The sample codes use 115200 serial baud rate (instead of the default 9600), so you need to manually select the baud rate in the serial monitor. Then, you should see it printing the sensors’ values onto the Serial Monitor. You could also show their timestamps by toggling the clock icon on the right.
You could also try the script in Menu -> File -> Examples -> Adafruit MPU6050 -> plotter
and use the Serial Plotter (top right oscilloscope icon) to get a realtime plot from the accelerometer and gyroscope.
mpu.setAccelerometerRange(MPU6050_RANGE_8_G)
and mpu.setGyroRange(MPU6050_RANGE_500_DEG)
. For example, if you choose maximum acceleration of $2g$, then you maximum sensitivity is $\frac{1}{16384}g \approx 0.6 \mathrm{mm/s^2}$, while max acc set to $16g$ would have sensitivity of $\frac{1}{2048}g\approx 4.8\mathrm{mm/s^2}$. More details about this is available on their datasheet https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdfDepending on your sensor type, usually, they only need ground and 5V, then the sensor output 0-5V depending on their spec. Then any Arduino’s analog pin can read that 0-5V in 1024 steps using analogRead(pinNo)
.
SDCardDataLogger.ino
) is connected to analog pin A1.For a more detailed guide on using the SD card module, please read https://lastminuteengineers.com/arduino-micro-sd-card-module-tutorial/
For the SD card module to work with the sample code (SDCardDataLogger.ino
), connect the pins as follows,
microSD Card Module | Arduino |
---|---|
VCC | 3.3V or 5V |
GND | GND |
MISO (Serial Peripheral Interface Output) | 12 |
MOSI (Serial Peripheral Interface Input) | 11 |
SCK (Serial Clock) | 13 |
CS (Chip Select) | 10 |
Open the built-in sample code at Menu -> File -> Examples -> SD -> CardInfo
, and change the value of chipSelect
at line 36
to 10
, then upload the code onto Arduino, you should get the following info from the provided SD card (your’s probably will not show any files, I have some files from macOS filesystem crap).
Unless you installed all the sensors mentioned in the exact pins (in pic below), the sample code SDCardDataLogger.ino
would most likely throw some errors and complain about missing sensors.
If you do have all sensors installed, then SDCardDataLogger.ino
would log data to both the SD card and Serial Monitor, and it could also log data to the SD card without connecting it to a computer. The Serial monitor output would look something like this:
MPU6050 Initialised.
Initialising SD card...done.
Logging to: log20.csv
Tms,423,Acc,-3.10,3.44,-8.87,Rot,-0.08,-0.01,0.02,V1,0.01,TC,0.00,TS,25.00,
Tms,557,Acc,-3.09,3.45,-8.88,Rot,-0.08,-0.02,0.02,V1,0.01,TC,0.00,TS,25.00,
Tms,690,Acc,-3.11,3.47,-8.85,Rot,-0.08,-0.02,0.02,V1,0.00,TC,0.00,TS,25.00,
...
...
The first three lines are just checking setup; from the fourth line onwards, they show the exact data logged to the SD card.
Tms
is milliseconds since Arduino boot.Acc
shows x,y,z acceleration (m/s^2) and Rot
shows xyz rotation (rad/s) using MPU6050V1
is the voltage from analog pin A1 for the pressure sensor. Depending on your pressure gauge spec, you need to convert this value to pressure.TC
is MAX6675 thermocouple reading in C. (It’s showing zero cuz I might have accidentally blown mine)TS
is DS18B20 temperature sensor in C.The data are logged in CSV (comma separated value) format which can be easily read by Mathematica, Python, Excel or your preferred stats tool.
You should comment out (Cmd-/
) any code about the sensors that you are not using.
Codes about MAX6675:
// Line 13-14
// MAX6675 Thermocouple
#include "max6675.h"
MAX6675 thermocouple(6, 5, 4); // SCK - pin 6, CS - pin 5, SO - pin 4.
...
// Line 100-101
// MAX6675
logToSerialAndSD("TC");
logToSerialAndSD(thermocouple.readCelsius());
Codes about DS18B20
// Line 18-21
// DS18B20 Temperature Sensor
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(2); // setup a oneWire with DS18B20 DQ connected to pin 2
DallasTemperature tempSensor(&oneWire); // pass oneWire to DallasTemperature library
...
// Line 104-106
// DS18B20
tempSensor.requestTemperatures(); // send the command to get temperatures
logToSerialAndSD("TS");
logToSerialAndSD(tempSensor.getTempCByIndex(0));
Codes about MPU6050
// Line 25
// MPU6050 Accelerometer and Gyroscope
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
Adafruit_MPU6050 mpu;
...
// Lines 83-92
// MPU6050
sensors_event_t a, g, temp; // Get new sensor events with the readings
mpu.getEvent(&a, &g, &temp);
logToSerialAndSD("Acc");
logToSerialAndSD(a.acceleration.x);
logToSerialAndSD(a.acceleration.y);
logToSerialAndSD(a.acceleration.z);
logToSerialAndSD("Rot");
logToSerialAndSD(g.gyro.x);
logToSerialAndSD(g.gyro.y);
logToSerialAndSD(g.gyro.z);
Codes about pressure sensor
// Lines 96-97
// Pressure Sensor at Analog pin A1
logToSerialAndSD("V1");
logToSerialAndSD(analogRead(A1)*5.0/1024.0);
SDCardDataLogger.ino
will dump data onto SD immediately after the Arduino is powered, and the only way to stop is to power down the Arduino. Consider adding a push button to start and stop recording.SDCardDataLogger.ino
, creating a new file and recording.