Main Content

Set up and Configure Arduino Hardware

Once you have installed the MATLAB® Support Package for Arduino® Hardware, as described in Install the Support Package, you can configure communication between the host computer and the Arduino board. Type arduinosetup in the MATLAB Command window and choose one of the following connection types:

Connection over USB

The Arduino hardware communicates with the host computer via a USB cable as shown.

To configure your Arduino hardware to communicate via USB:

  1. Connect the Arduino hardware via USB, by choosing the connection type USB.

  2. Choose the board type and the port number from the Choose board and Choose port menus. Then, select the libraries that you want to include in your Arduino server. Click Program to begin uploading the server to your Arduino board.

  3. After the upload is complete, click Test connection to test the connection between your host computer and the Arduino board.

  4. Click Finish to complete the hardware setup. To connect to your Arduino board, see Connect to Arduino Hardware.

Connection over Bluetooth

Arduino hardware communicates with the host computer via Bluetooth®, as shown.

To configure your Arduino hardware to communicate via Bluetooth:

  1. Connect the Arduino hardware via USB, and choose the connection type Bluetooth.

  2. Choose the board type and the port number from the Choose board and Choose port menus.

  3. Select the libraries that you want to include in your Arduino server. Click Program to begin uploading the server to your Arduino board.

    If you are using MKR1010, Nano 33 IoT, Nano 33 BLE, or the Nano 33 BLE Sense board, on the Upload Arduino Server screen:

    • Use the Enter the name of the device or select from a list of available device menu to select an Arduino device.

    • Use the Select libraries to be included in the server drop-down menu to upload libraries to the hardware.

    • Click Program to complete uploading libraries to the Arduino device and retrieve the Bluetooth Device address from the Arduino board.

  4. If you are using the Uno, Due, Mega2560, Leonardo, Micro, or the Nano3 board, select the Bluetooth device that you want to use to communicate with the Arduino board. If you are using the HC-05 or HC-06 boards and you have not configured the device using the arduinosetup interface, click No to first configure your Bluetooth device.

  5. If you are using the Uno, Due, Mega2560, Leonardo, Micro, or the Nano3 board, to configure your Bluetooth device, follow the on-screen links in the arduinosetup interface to pair your Bluetooth Classic device and to get your Bluetooth serial port or address.

    Note

    If you are using a Windows® desktop computer, connect a Bluetooth dongle to your computer. You should use a dongle supporting Bluetooth 4.0 or higher to connect to the MKR1010, Nano33 IoT, Nano 33 BLE, or, Nano 33 BLE Sense boards over Bluetooth.

  6. If you are using ESP32-DevKitV1 or ESP32-DevKitC boards, see Configure ESP32 Hardware over Bluetooth.

  7. Click Test connection to test the connection between your host computer and the Arduino board and click Next.

    Note

    If you are using the MKR1010, Nano 33 IoT, Nano 33 BLE, or the Nano 33 BLE Sense board, your computer running MATLAB can detect Bluetooth. This computer acts as a Bluetooth central.

  8. Click Finish to complete the hardware setup.

Connection over Wi-Fi

Arduino hardware communicates with the host computer via Wi-Fi®, as shown.

To configure your Arduino hardware to communicate via Wi-Fi:

  1. Connect the Arduino hardware via USB by choosing the connection type WiFi. Choose the encryption type of your WiFi network, and enter the necessary credentials.

    • If you have previously configured your Arduino board using Wi-Fi via the arduinosetup interface, you can select the Retrieve last configuration from Arduino board option, which retrieves the necessary credentials from your previous configuration.

    • If you select the Use static IP address box, make sure that you use an available static IP address and that your router allows the usage of static IP.

      Note

      Ensure that the Subnet Mask is 255.255.255.0 and the Default Gateway is the IP address of the network gateway.

  2. Choose the board type as MKR1000, MKR1010, or Nano 33 IoT and its port number. Also, select the libraries that you want to include in your Arduino board. Click Program to begin uploading the server to your Arduino board.

    Note

    If you are using ESP32-DevKitV1 or ESP32-DevKitC boards, see Configure ESP32 Hardware over WiFi.

  3. After the upload is complete, click Test connection to test the connection between the host computer and the Arduino board.

  4. Click Finish to complete the hardware setup.

See Also

Related Topics