Table of Contents

5.2 Using BLOX with the Arduino IDE

The Arduino IDE provides a flexible and powerful environment for programming BLOX devices using traditional code-based methods. This guide will help you get started by installing the Arduino IDE, setting up the ESP32 cores, and adding the necessary libraries.


5.2.1 Requirements

Before getting started, ensure that you have the following:


5.2.2 Installing Arduino IDE 2

Download Arduino IDE 2:

Visit https://www.arduino.cc/en/software and select the appropriate version for your operating system.

Install the IDE:

Follow the installation instructions provided on the website. Once the installation is complete, launch the Arduino IDE.


5.2.3 Installing the ESP32 Cores

Open the Arduino IDE:

Launch the Arduino IDE and navigate to `File > Preferences`.

Add the ESP32 Board URL:

In the “Additional Boards Manager URLs” field, enter the following URL:

Click “OK” to save the preferences.

Install the ESP32 Core:

Go to `Tools > Board > Boards Manager`.

In the search bar, type “ESP32” and install the latest version of the ESP32 by Espressif Systems.


5.2.4 Installing the OpenBuilds BLOX Library

Open the Library Manager:

Go to `Sketch > Include Library > Manage Libraries`.

Search for the BLOX Library:

In the Library Manager, search for “OpenBuilds BLOX”.

Click “Install” to add the library to your Arduino IDE.

Alternatively, you can install the library manually by downloading it from the https://github.com/OpenBuilds/OpenBuildsBLOX/


5.2.5 Getting Started with BLOX on Arduino IDE

Select the ESP32-S3 Board:

Go to `Tools > Board` and select the ESP32-S3 Development board for your BLOX device.

Connect Your BLOX Device:

Connect the BLOX device to your computer via USB. Ensure the correct port is selected in `Tools > Port`.

Also set:

Upload a Sketch:

You can now write or upload a sketch to your BLOX device. Use the examples provided in the BLOX library to get started quickly. Including the OpenBuildsBLOX.h library will help you initialise all the onboard hardware with ease


5.2.6 Pinmap for custom firmware

If you are not planning on using our library to control the onboard devices as part of your code, you can use the Pin map below to get you started with your own code

// WS2812 LEDs
#define LED_PIN         48

// RC Servo
#define PIN_SERVO       47

// Stepper 1
#define DIR_1           8
#define STEP_1          9
#define ENABLE_1        10
#define FAULT_1         11
// Remember to setup MCP4725 I2C DAC (Addr 0x60) to set Stepper Driver Current

// Stepper 2
#define DIR_2           12
#define STEP_2          13
#define ENABLE_2        14
#define FAULT_2         15
// Remember to setup MCP4725 I2C DAC (Addr 0x61) to set Stepper Driver Current

// Limits Inputs
#define LIMIT_SENSOR_1  39
#define LIMIT_SENSOR_2  40

// Mosfets
#define PIN_MOSFET1     41
#define PIN_MOSFET2     42

// Beeper
#define BUZZER_PIN      7

// I2C
#define I2C_SDA         3
#define I2C_SCL         4

// SPI
#define SPI_MOSI        35
#define SPI_MISO        37
#define SPI_SCK         36

// SD Card
#define SD_CS           5

void setCurrent(float milliAmps) {
  // Calculate reference voltage: Convert milliAmps to mV output from DAC
  float millivolt = milliAmps / 5.0 / 0.22;

  // Map the millivolt value to the DAC range (0 to 3300 mV to 0 to 4096)
  int dacValue = map(millivolt, 0, 3300, 0, 4096);

  // Your own logic here to apply the dacValue to the correct DAC to set the current
}