Pinout explanation

Table of Contents

    Pinout diagram

    Boboduino uses the ATMEGA328PB-AU chip and is pin-compatible with the official Arduino Uno R3. The detailed pin functions can be referred to in the diagram below. Since it is relatively easy to find online resources about the pinouts of our best teacher, official Arduino UNO, the following introduction will focus only on the additional features compared to Uno.

    Untitled

    Interface and variable names

    Please refer to the pinout diagram below if you want to know what is the difference between the interface of Boboduino and Arduino. To utilize the extra set of SPI, Serial, or I2C interfaces, use the variable names SPI1, Serial1, or Wire1.

    Boboduino Uno R3UNO R3
    SPI* 2 sets
    * SPI, SPI1
    * 1 set
    * SPI
    Serial* 2 sets
    * Serial, Serial1
    * 1 set
    * Serial
    IIC* 2 set
    * Wire, Wire1
    * 1 set
    * Wire

    Fore example, we can initiate the Serial1 with:

     Serial1.begin(9600);

    After that, we can read the each character by:

      if (Serial1.available()) {
        // Read the incoming byte from Serial1
        char receivedByte = Serial1.read();
    }

    Actually, the only difference is just the variable name and the pin locations.


    A6/A7 pins

    Compared to the UNO board Rev3, Boboduino has added two additional analog pins, A6 and A7. These two pins can be used not only as ADC (Analog-to-Digital Converter) functionality but also as digital input/output pins.

    To , the A6 and A7 pins have the following functions:

    • ADC (Analog-to-Digital Converter)
    • Digital input/output

    SPI

    SPI, which stands for Serial Peripheral Interface, is a synchronous serial communication protocol used for communication between microcontrollers, sensors, and other peripheral devices. It allows multiple devices to be connected to a single bus and enables full-duplex communication, meaning data can be sent and received simultaneously.

    On the Boboduino Uno R3 board, there are two SPI interfaces available. Most of the time, you may not need to use both simultaneously. However, having two interfaces provides an alternative choice if you need to use D10 and D11 as the PWM pins. In such cases, you can choose SPI1 as your SPI interface.

    Additionally, it’s important to note that MOSI0 and SS0 have been overlapped with Tx1 and Rx1, respectively. If you intend to use both serial communication channels simultaneously, you will need to choose SPI1 instead of SPI0 as your SPI interface.

    SPI
    MISO: D12
    MOSI: D11
    SCK: D13
    SS: D10
    SPI1
    MISO1: A0
    MOSI1: A7
    SCK1: A1
    SS1: A6

    Example code

    Here is âme example of using SPI1 instead of SPI as the communication interface.

    #include <SPI.h>
    
    void setup() {
      // Initialize SPI1
      SPI1.begin();
      
      // Set the Slave Select (SS) pin as an output
      pinMode(SS1, OUTPUT);
      
      // Start Serial communication for debugging
      Serial.begin(9600);
    }
    
    void loop() {
      // Select the SPI slave device by bringing SS1 pin LOW
      digitalWrite(SS1, LOW);
      
      // Send data to the SPI slave and receive data back
      byte dataToSend = 0x55; // Example data to send
      byte dataReceived = SPI1.transfer(dataToSend);
      
      // Deselect the SPI slave device by bringing SS1 pin HIGH
      digitalWrite(SS1, HIGH);
      
      // Print received data
      Serial.print("Received: 0x");
      Serial.println(dataReceived, HEX);
      
      // Wait for a while before sending the next SPI transaction
      delay(1000);
    }


    UART

    UART, which stands for Universal Asynchronous Receiver/Transmitter, is a hardware communication protocol used for serial communication between devices. It’s a widely used protocol for transmitting and receiving data between devices, such as microcontrollers, sensors, and computers.

    Two Serial interfaces can work together at the Boboduino Uno board. I generally use Serial as the one communicate with computer for debugging, and Serial1 as the one to communicate with other devices. The Arduino Uno board itself does not have built-in hardware debugging features like more advanced microcontrollers or development platforms might have. However, Arduino Uno allows for a form of software debugging through the use of the Serial communication. It is great if you can have two Serial, one for communication with device, the other for debugging.

    Serial
    Rx: D0
    Tx: D1
    Serial1
    Rx1: D10
    Tx1: D11

    Example code

    Here’s an example code that uses Serial for debugging purposes and Serial1 to read data from a serial communication using the Atmega328PB microcontroller with the Boboduino MiniCore core. In this example, Serial is used to print messages and sensor values to the Serial Monitor, while Serial1 reads data from an external device connected to the UART communication pins.

    void setup() {
      // Start Serial communication at 9600 baud for debugging
      Serial.begin(9600);
      
      // Start Serial1 communication at 9600 baud for external device communication
      Serial1.begin(9600);
    }
    
    void loop() {
      // Check if there is data available to read from Serial1
      if (Serial1.available()) {
        // Read the incoming byte from Serial1
        char receivedByte = Serial1.read();
        
        // Print the received byte to Serial for debugging
        Serial.print("Received: ");
        Serial.println(receivedByte);
      }
      
      // Read a sensor value (for example, from analog pin A0)
      int sensorValue = analogRead(A0);
      
      // Print sensor value to Serial Monitor for debugging
      Serial.print("Sensor Value: ");
      Serial.println(sensorValue);
      
      delay(1000);  // Wait for 1 second before the next iteration
    }

    IIC

    I2C, also known as Inter-Integrated Circuit or IIC (pronounced “I-squared-C”), is a popular serial communication protocol used to connect multiple electronic devices together on a common bus.

    You can use them with the variable name of Wire and Wire, respectively.

    Wire
    SDA: A4(D18)
    SCL: A5(D19)
    Wire1
    SDA1: PE0
    SCL1: PE1

    Most of the time, you can use one I2C interface to communicate with multiple devices. The only two reasons you may need two I2C interfaces instead of one are:

    1. Pins conflict: If you want to use A4 and A5 as the analog pins.
    2. Address conflict: If you happen to have I2C devices with the same address. You can then use both I2C interfaces to communicate with devices having the same address, respectively.

    Example code

    Here is an example to use both IIC device at the same time.

    #include <Wire.h>
    #include <Wire1.h>
    
    void setup() {
      Serial.begin(9600);
      Wire.begin();  // Initialize the first I2C bus (Wire)
      Wire1.begin(); // Initialize the second I2C bus (Wire1)
    }
    
    void loop() {
      // Communication on the first I2C bus (Wire)
      Wire.beginTransmission(0x50); // Address of the first device
      Wire.write("Hello from Wire!");
      Wire.endTransmission();
      delay(1000); // Wait for a moment
      
      // Communication on the second I2C bus (Wire1)
      Wire1.beginTransmission(0x50); // Address of the second device
      Wire1.write("Hello from Wire1!");
      Wire1.endTransmission();
      delay(1000); // Wait for a moment
      
      // Read data from the first device on Wire
      Wire.requestFrom(0x50, 10); // Request 10 bytes of data from the first device
      while (Wire.available()) {
        char c = Wire.read();
        Serial.print(c);
      }
      Serial.println();
      delay(1000); // Wait for a moment
      
      // Read data from the second device on Wire1
      Wire1.requestFrom(0x50, 10); // Request 10 bytes of data from the second device
      while (Wire1.available()) {
        char c = Wire1.read();
        Serial.print(c);
      }
      Serial.println();
      delay(1000); // Wait for a moment
    }

    Overlapping pins

    • The Rx and Tx pins of UART1  is overlapped with some pins of SPI0. If you need to simultaneously use SPI and both sets of UART, it is recommended to choose SPI1 instead of SPI0.
    • The pins A4 and A5 are overlapped with the SDA and SCL pins of the IIC. Use IIC2 if you need to use A4 and A5 as the analog pins

    Regarding the way to use UART, SPI, and I2C, we will provide further explanations in the upcoming chapters.


    Further reading