CAN Receiver

Introduction

This tutorial covers how to use the CAN (Controller Area Network) port on the NEXTuino BASE to receive data. CAN is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate without a host computer.

Prerequisites

  • Installed Arduino IDE
  • NEXTuino BASE board

Example Code

CAN Receiver Example on GitHub

Overview

The example initializes the CAN bus at 500 kbps and continuously checks for incoming CAN packets. When a packet is received, its details and data are printed to the Serial Monitor.

Key Functions

  • CAN.begin(speed) — Initializes the CAN bus at the specified speed
  • CAN.parsePacket() — Checks for incoming packets and returns their size
  • CAN.packetId() — Returns the ID of the received packet
  • CAN.packetExtended() — Checks if the packet uses an extended ID
  • CAN.packetRtr() — Checks if the packet is a Remote Transmission Request (RTR)
  • CAN.read() — Reads a byte of data from the received packet

Step-by-Step Guide

Step 1: Set Up Your Environment

  1. Connect your NEXTuino BASE to your computer
  2. Open the Arduino IDE and select the correct board and port

Step 2: Understand the Code

  • Serial.begin(115200) — starts serial communication for debugging
  • CAN.begin(500E3) — initializes the CAN bus at 500 kbps
  • In loop(), CAN.parsePacket() checks for incoming packets and prints their details

Step 3: Upload and Test

  1. Copy the example code into a new Arduino IDE sketch
  2. Upload to your NEXTuino BASE
  3. Open the Serial Monitor (115200 baud) to view output

Troubleshooting

  • Verify CAN bus wiring and that all devices are properly connected
  • Check baud rate and CAN bus speed settings match between devices

Conclusion

You now have a basic understanding of how to use the CAN port on the NEXTuino BASE to receive data, as a foundation for vehicle network or industrial automation applications.