Arduino Mega (Sensor Reading Device)
This page provides instructions for setting up and using the Arduino Mega.
Dependencies
- Git
- Repository
- Arduino IDE
- VSCode
- Bash
- Arduino CLi
Hardware
- Arduino Mega
Setup Steps
- Clone the Repository:
git clone `git@github.com:BCIT-Reseach-Long-Term-ISSP/device-firmware-refactor.git`
-
Install Arduino CLI:
Refrence: Official Arduino CLI Installation Docuemnt - Update Arduino Core:
arduino-cli core update-index --additional-urls https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
- Connect Arduino Mega:
- Connect Arduino Mega yo your laptop and open Arduino IDE Make sure your IDE is able to recognize the device.
- If and when you try to upload any code to the mega, it just stops responsing sometimes. Mega would still be working but you’ll see some sort of
timeout
when uploading code. Example:Device or resource busy ioctl("TIOCMGET"): Inappropriate ioctl for device
- There are other kind of timeour erros as well. Usually restarting the Arduino IDE helps. I know it’s very annoying.
- If that doesn’t work, after closing the IDE, try to find the process that is maybe still using the port that the mega is connected on. Sometimes the Arduino IDE’s serial monitor doesn’t detatch itself. So, for example, on linux, I usually do this:
kill -9 $(lsof -t <PORT>)
Example:
kill -9 $(lsof -t /dev/ttyACM1)
- Upload Code:
- Please use git bash for this.
- cd mega/
-
chmod +x arduino_upload.sh
- For help:
./arduino_uplaod.sh -h
- To install core, compile and upload code:
./arduino_upload.sh -i -c -u PORT=[Arduino port]
Example:
./arduino_upload.sh -i -c -u PORT="dev/ttyACM1"
Now your Arduino Mega should be ready to read sensor data.