The Arduino Mega is a development board from Arduino based on the ATmega2560 microcontroller and features 54 digital I/O pins, 16 analog inputs, and ample space for creating complex projects. This enables the board to be used in collaboration with a wide variety of shields and other add-on boards to expand its functionality.
The Arduino Mega doesn’t include connectivity on its own, so with use in Atmosphere you can either print its data into a debug console, or give it some form of connectivity by connecting it to an Arduino-compatible shield. Atmosphere supports the Adafruit WINC1500 Wi-Fi Shield, which features the Microchip WINC1500 Wi-Fi module that includes with a corresponding element by the same name in Atmosphere Studio’s Element Library. The Arduino Mega is also compatible with the Digi XBee3 Zigbee Mesh Kit.
There are no imported sensors or specialized elements or tools native to Arduino Mega projects.
Some devices may have limitations or design restrictions that cause unexpected behavior when used with Atmosphere. Specific information and details pertaining to the Arduino Mega and its performance on Atmosphere is noted below.
- This platform does not have PWM support
Default Pin Mapping
Atmosphere configures each peripheral to a default pin for every supported device, based on ideal pairing of pins and their usage. The default pin configuration is set for convenience and enables each peripheral to work naturally without needing to be modified.
All pins can be used as general purpose input/output (GPIO) unless otherwise specified.
Arduino Mega projects start with the following pin configuration:
||Arduino Connector D0|
||Arduino Connector D1|
||Arduino Connector D2|
||Arduino Connector D3|
||Arduino Connector D4|
||Arduino Connector D5|
||Arduino Connector D6|
||Arduino Connector D7|
||Arduino Connector D8|
||Arduino Connector D9|
||Arduino Connector D10|
||Arduino Connector D11|
||Arduino Connector D12|
||Arduino Connector D13|
||Arduino Connector Analog 0|
||Arduino Connector Analog 1|
||Arduino Connector Analog 2|
||Arduino Connector Analog 3|
||Arduino Connector Analog 4|
||Arduino Connector Analog 5|
Internal Arduino Mega Pins
The Arduino Mega is compiled using the Arduino SDK, so any functions and pin mappings can also be used within Atmosphere Studio.
The default pin for any peripheral can be changed within an element's properties, from an element that references that particular peripheral.
Below is information regarding the Arduino Mega’s exposed peripherals.
This I2C bus is exposed via the SDA and SCL pins on the Arduino header.
This SPI bus is exposed via the MOSI, MISO, and CLK pins on the Arduino SPI connector.
UART1 (USB Debug Console)
This UART is exposed via the USB connector.
This UART is exposed via pins 19(RX) and 18(TX).
This UART is exposed via pins 17(RX) and 16(TX).
This UART is exposed via pins 15(RX) and 14(TX).
The Arduino Mega does not have PWM support.
Programming the Arduino Mega involves using the programmer interface in Atmosphere Studio to install embedded firmware.
Prior to programming an Arduino Mega, ensure you have the following setup configuration:
- The Arduino Mega is connected to the computer via USB to an available communication port.
- The Atmosphere IoT Agent is installed on the computer and running. This is a local application that runs in the system tray and acts as an intermediary between the computer’s connectivity protocol drivers and the browser running Atmosphere.
- An Internet connection is maintained.
- The project to be programmed has been compiled.
With setup complete, you can program the Arduino Mega:
- From Atmosphere Studio’s Embedded tab, click the button from the tab’s toolbar. This displays the Program Firmware window.
- Under Device Port, select the communication port the device is connected to.
- Click Program to start programming. When complete, you’ll be notified that the device is programmed with the project’s embedded firmware.
Guides and Tutorials
Get started using the Arduino Mega with Atmosphere by walking through the following guides:
|Arduino Mega Guides|
|Getting Started with Arduino Mega|
|Creating a Zigbee Mesh Network with Atmosphere|
|Using Cellular Modems with Atmosphere|
Atmosphere includes a variety of Arduino Mega demo projects for users of all levels. Check them out by clicking the demo’s name to open the project in Atmosphere.
|ADXL343 Arduino Mega Demo||Demonstrates the functionality of the ADXL343 accelerometer. Reads acceleration, detects taps, and detects freefall data.|
|Adafruit WINC1500 Wi-Fi Shield Demo||A complete demo that showcases the Adafruit WINC1500 with the Arduino Mega as host. An integer is sent to the cloud every five seconds. The app then sends the current time to the device.|
|KMA36 Rotation Demo||Measure the current angle from the KMA36 rotation sensor and Arduino Mega. Read the angle value and it’s printed to the debug console.|
|TE Weather Shield Demo||Measure various weather values with sensors from the TE Connectivity MEAS weather shield and the Arduino Mega. Read temperature, pressure, and humidity data, and print the values to the debug console.|
|Weather Shield + Cellular Demo||Measure temperature data from the TSYS01 on the TE Connectivity MEAS Weather Shield and send it to the cloud via the Digi XBee3 LTE Cat 1 cellular modem.|
|Arduino Mega Function Demo||The function element is used within this demo project with some basic code to change the brightness of the Arduino Mega’s LED.|
|Counter Element Arduino Demo||The counter element is used within this demo project by incrementing and decrementing values and printing them on the debug console.|
|PWM Pin Arduino Demo||The PWM pin element is used within this demo project by increasing the brightness of the Arduino Mega’s LED alongside counter and mathematical operation elements.|
|Data Type Conversion Arduino Demo||The data type conversion element is used within this demo project by converting the temperature value from float to integer and printing both the values on the debug console.|
|Mathematical Operation Arduino Demo||The operation element is used within this demo project by converting the temperature in Celsius to Fahrenheit and printing both the values on the debug console.|
|ADC Pin Arduino Demo||The ADC pin element is used within this demo project by reading the voltage from the analog pin and printing it on the debug console.|
|Digi XBee3 Zigbee Sender Demo||Demonstrates the Digi XBee3 Zigbee module by using the Arduino Mega as an end node device that sends temperature data to the HUZZAH32 coordinator device of the Zigbee network every second. Designed to work with the Digi XBee3 Zigbee Receiver Demo.|
|UART Element Demo||The UART element is used within this demo project that sends “Hello123” one byte at a time over UART while also demonstrating the buffering and RegEx capabilities of Atmosphere’s UART driver. Note this demo uses UART2, and connect IO18 and IO19 on the Arduino Mega to send TX back to RX.|
The Atmosphere video library contains the following videos on the Arduino Mega:
The following additional resources and downloadable files are available for the Arduino Mega: