### Install Build Tools Source: https://learn.sparkfun.com/tutorials/getting-started-with-the-a111-pulsed-radar-sensor If you encounter issues building the SDK, ensure you have the necessary build tools like 'make' and 'gcc' installed. Use this command to install them via apt-get. ```bash apt-get install make gcc ``` -------------------------------- ### Install Arduino IDE Source: https://learn.sparkfun.com/tutorials/installing-arduino-ide Once inside the Arduino program folder, execute this command in the terminal to begin the installation process. ```bash ./install.sh ``` -------------------------------- ### Run Power Bins Service Example Source: https://learn.sparkfun.com/tutorials/getting-started-with-the-a111-pulsed-radar-sensor Execute the power bins service example to demonstrate the usage of A111's power bins feature. ```bash example_service_power_bins_rpi_sparkfun_a111_r2c ``` -------------------------------- ### Build All SDK Examples Source: https://learn.sparkfun.com/tutorials/getting-started-with-the-a111-pulsed-radar-sensor Navigate to the top-level directory of the SDK (where the 'makefile' is located) and run this command to compile all board and example files. This command recursively uses makefile rules to build the project. ```bash make all ``` -------------------------------- ### Run IQ Service Example Source: https://learn.sparkfun.com/tutorials/getting-started-with-the-a111-pulsed-radar-sensor Execute the advanced IQ service example, which provides phase information for precise distance variations. Output is in polar coordinates. ```bash example_service_iq_rpi_sparkfun_a111_r2c ``` -------------------------------- ### MPU-9250 Basic Example Sketch Source: https://learn.sparkfun.com/tutorials/mpu-9250-hookup-guide A comprehensive example demonstrating MPU-9250 initialization, data reading, and optional LCD display output. ```cpp /* MPU9250 Basic Example Code by: Kris Winer date: April 1, 2014 license: Beerware - Use this code however you'd like. If you find it useful you can buy me a beer some time. Modified by Brent Wilkins July 19, 2016 Demonstrate basic MPU-9250 functionality including parameterizing the register addresses, initializing the sensor, getting properly scaled accelerometer, gyroscope, and magnetometer data out. Added display functions to allow display to on breadboard monitor. Addition of 9 DoF sensor fusion using open source Madgwick and Mahony filter algorithms. Sketch runs on the 3.3 V 8 MHz Pro Mini and the Teensy 3.1. SDA and SCL should have external pull-up resistors (to 3.3V). 10k resistors are on the EMSENSR-9250 breakout board. Hardware setup: MPU9250 Breakout --------- Arduino VDD ---------------------- 3.3V VDDI --------------------- 3.3V SDA ----------------------- A4 SCL ----------------------- A5 GND ---------------------- GND */ #include "quaternionFilters.h" #include "MPU9250.h" #ifdef LCD #include #include // Using NOKIA 5110 monochrome 84 x 48 pixel display // pin 9 - Serial clock out (SCLK) // pin 8 - Serial data out (DIN) // pin 7 - Data/Command select (D/C) // pin 5 - LCD chip select (CS) // pin 6 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(9, 8, 7, 5, 6); #endif // LCD #define AHRS false // Set to false for basic data read #define SerialDebug true // Set to true to get Serial output for debugging // Pin definitions int intPin = 12; // These can be changed, 2 and 3 are the Arduinos ext int pins int myLed = 13; // Set up pin 13 led for toggling #define I2Cclock 400000 #define I2Cport Wire #define MPU9250_ADDRESS MPU9250_ADDRESS_AD0 // Use either this line or the next to select which I2C address your device is using //#define MPU9250_ADDRESS MPU9250_ADDRESS_AD1 MPU9250 myIMU(MPU9250_ADDRESS, I2Cport, I2Cclock); void setup() { Wire.begin(); // TWBR = 12; // 400 kbit/sec I2C speed Serial.begin(38400); while(!Serial){}; // Set up the interrupt pin, its set as active high, push-pull pinMode(intPin, INPUT); digitalWrite(intPin, LOW); pinMode(myLed, OUTPUT); digitalWrite(myLed, HIGH); #ifdef LCD display.begin(); // Ini8ialize the display display.setContrast(58); // Set the contrast // Start device display with ID of sensor display.clearDisplay(); display.setTextSize(2); display.setCursor(0,0); display.print("MPU9250"); display.setTextSize(1); display.setCursor(0, 20); display.print("9-DOF 16-bit"); display.setCursor(0, 30); display.print("motion sensor"); display.setCursor(20,40); display.print("60 ug LSB"); display.display(); delay(1000); // Set up for data display display.setTextSize(1); // Set text size to normal, 2 is twice normal etc. display.setTextColor(BLACK); // Set pixel color; 1 on the monochrome screen display.clearDisplay(); // clears the screen and buffer #endif // LCD // Read the WHO_AM_I register, this is a good test of communication byte c = myIMU.readByte(MPU9250_ADDRESS, WHO_AM_I_MPU9250); Serial.print(F("MPU9250 I AM 0x")); Serial.print(c, HEX); Serial.print(F(" I should be 0x")); Serial.println(0x71, HEX); #ifdef LCD display.setCursor(20,0); display.print("MPU9250"); display.setCursor(0,10); display.print("I AM"); display.setCursor(0,20); display.print(c, HEX); display.setCursor(0,30); display.print("I Should Be"); display.setCursor(0,40); display.print(0x71, HEX); display.display(); delay(1000); #endif // LCD if (c == 0x71) // WHO_AM_I should always be 0x71 { Serial.println(F("MPU9250 is online...")); // Start by performing self test and reporting values myIMU.MPU9250SelfTest(myIMU.selfTest); Serial.print(F("x-axis self test: acceleration trim within : ")); Serial.print(myIMU.selfTest[0],1); Serial.println("% of factory value"); ``` -------------------------------- ### Basic Arduino Example Source: https://learn.sparkfun.com/tutorials/lsm9ds0-hookup-guide A simple Arduino sketch to initialize the LSM9DS0 sensor and print accelerometer data. Ensure the library is installed and the sensor is connected. ```arduino // Basic Arduino Example // Includes the library, initializes the sensor, and prints accelerometer data. #include #include #include "SparkFunLSM9DS0.h" // Instantiate the LSM9DS0 sensor object LSM9DS0 myIMU; void setup() { Serial.begin(9600); while (!Serial) { ; } Serial.println("LSM9DS0 Basic Example"); // Initialize the IMU // Use the default constructor for I2C communication // The default I2C address is 0x6B for the accelerometer/gyro and 0x1E for the magnetometer // If you are using the SPI interface, use the overloaded constructor: // LSM9DS0 myIMU(IMU_SPI, 0x6B, 0x1E); // (SPI, IMU_ADDRESS, WHO_AM_I_ADDRESS) if (myIMU.begin() == LSM9DS0_ERROR) { Serial.println("Could not find LSM9DS0. Check connections."); while (1) { ; } } Serial.println("IMU Initialized!"); } void loop() { // Check if new accelerometer data is available if (myIMU.accelerationAvailable()) { // Read accelerometer data myIMU.readAcceleration(); // Print the data Serial.print("Accel X: "); Serial.print(myIMU.ax); Serial.print(" \t Y: "); Serial.print(myIMU.ay); Serial.print(" \t Z: "); Serial.println(myIMU.az); } delay(100); } ``` -------------------------------- ### Setup CCS811 Sensor Source: https://learn.sparkfun.com/tutorials/ccs811-air-quality-breakout-hookup-guide Call the begin function within the setup block to initialize the sensor. ```cpp void setup() { myCCS811.begin(); } ``` -------------------------------- ### Example 1: Volume Control Source: https://learn.sparkfun.com/tutorials/audio-codec-breakout---wm8960-hookup-guide This example demonstrates how to control the volume of the audio output. The volume decreases every 5 seconds until muted. Ensure the audio source volume is turned up before playing. ```Arduino #include "SparkFun_WM8960_Audio.h" #include "Wire.h" SparkFunWM8960 audio = SparkFunWM8960(); void setup() { Serial.begin(115200); Wire.begin(); if (!audio.begin()) { Serial.println("Failed to initialize the WM8960"); while (1); } audio.setVolume(0.8, 0.8); // Set initial volume to 80% Serial.println("WM8960 Initialized. Volume set to 80%"); } void loop() { static float volume = 0.8; static unsigned long lastVolumeChange = 0; static bool decreasing = true; if (millis() - lastVolumeChange > 5000) // Change volume every 5 seconds { if (decreasing) { volume -= 0.1; if (volume <= 0.0) { volume = 0.0; decreasing = false; } } else { // Optionally, you could increase the volume back up here // For this example, we'll just keep it muted after reaching 0 } audio.setVolume(volume, volume); Serial.print("Volume set to: "); Serial.println(volume); lastVolumeChange = millis(); } // Other loop tasks can go here } ``` -------------------------------- ### Run Basic Distance Detector Example Source: https://learn.sparkfun.com/tutorials/getting-started-with-the-a111-pulsed-radar-sensor Execute the basic distance detector application from the out directory to measure object distances. This example takes 10 samples by default. ```bash ./example_detector_distance_basic_rpi_sparkfun_a111_r2c ``` -------------------------------- ### Example 2: Line Input 2 Source: https://learn.sparkfun.com/tutorials/audio-codec-breakout---wm8960-hookup-guide This example passes a line-level audio source into line input 2 of the WM8960. The audio is then sent to the headphones. This example sets the volume once. ```Arduino #include "SparkFun_WM8960_Audio.h" #include "Wire.h" SparkFunWM8960 audio = SparkFunWM8960(); void setup() { Serial.begin(115200); Wire.begin(); if (!audio.begin()) { Serial.println("Failed to initialize the WM8960"); while (1); } // Configure line input 2 and set volume audio.setInput(WM8960_INPUT_LINE2); audio.setVolume(0.7, 0.7); // Set volume to 70% Serial.println("WM8960 Initialized. Using Line Input 2. Volume set to 70%"); } void loop() { // The audio input is automatically routed to the output when configured. // No further code is needed in the loop for basic playback. // You can add other tasks here if needed. delay(100); } ``` -------------------------------- ### Setup Serial Port in Processing Source: https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing Initialize the Serial object in the setup() method to listen to the correct serial port and baud rate. Match the baud rate with the Arduino's Serial.begin() setting. ```processing void setup() { // I know that the first port in the serial list on my mac // is Serial.list()[0]. // On Windows machines, this generally opens COM1. // Open whatever port is the one you're using. String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port myPort = new Serial(this, portName, 9600); } ``` -------------------------------- ### Upload Example 14: Electret Mics Source: https://learn.sparkfun.com/tutorials/audio-codec-breakout---wm8960-hookup-guide Upload this example to test electret microphone input using a pseudo-differential configuration. Make noise near the microphones to hear audio output through the headphones. ```arduino #include #include "SparkFun_WM8960_AudioCodec.h" SparkFun_WM8960_AudioCodec wm8960; void setup() { Serial.begin(115200); Serial.println("WM8960 Electret Microphone Example"); // Initialize the WM8960 codec if (!wm8960.begin()) { Serial.println("Could not initialize WM8960. Check connections."); while (1); } Serial.println("WM8960 Initialized."); // Configure the PGA for differential microphones // The PGA gain can be set from 0dB to +39dB in 3dB steps wm8960.setPgagain(30.0); Serial.println("Set PGA Gain to 30.0dB"); // Enable the microphone input and set it to differential mode wm8960.enableMicInput(true, WM8960_MIC_DIFF); Serial.println("Microphone input enabled in differential mode."); // Enable the headphone output wm8960.enableHeadphoneOutput(true); Serial.println("Headphone output enabled."); } void loop() { // The loop can be used to process audio data or control other parameters // For this example, we are not changing anything in the loop delay(1000); } ``` -------------------------------- ### RedBot Motor Control Example Source: https://learn.sparkfun.com/tutorials/getting-started-with-the-redbot This Arduino sketch controls the left and right motors of the RedBot Mainboard. It requires no external libraries and defines all necessary pins. Ensure the RedBot is in a safe position before uploading, as it will start moving immediately. The code includes setup for serial communication and a debug LED on pin 13. ```arduino /******************************************************************************* / SimpleRedBotDrive Code - no libraries / / Simple example code showing how to spin the right and left motors and braking. / This example requires no libraries to run, and has all of the pins used on the / RedBot Mainboard defined. / / Before uploading this code to your RedBot, make sure that the RedBot is in a safe / place. It will start moving immediately after you upload the program. We suggest / placing the RedBot on it's end so that the wheels are up. / / Push the small reset button on the board to run the program again. / / Note: The RedBot Mainboard programs as an Arduino Uno /******************************************************************************/ // H-Bridge motor driver pins #define L_CTRL1 2 #define L_CTRL2 4 #define L_PWM 5 #define R_CTRL1 7 #define R_CTRL2 8 #define R_PWM 6 // XBee SW_Serial pins #define SW_SER_TX A0 #define SW_SER_RX A1 /******************* / setup function /*******************/ void setup() { Serial.begin(9600); pinMode(L_CTRL1, OUTPUT); // used as a debug pin for an LED. pinMode(L_CTRL2, OUTPUT); // used as a debug pin for an LED. pinMode(L_PWM, OUTPUT); // used as a debug pin for an LED. pinMode(R_CTRL1, OUTPUT); // used as a debug pin for an LED. pinMode(R_CTRL2, OUTPUT); // used as a debug pin for an LED. pinMode(R_PWM, OUTPUT); // used as a debug pin for an LED. pinMode(13, OUTPUT); // used as a debug pin for an LED. // spin the left Motor CW leftMotor(255); delay(2000); leftBrake(); delay(1000); // wait for 1000 milliseconds // spin the left Motor CCW leftMotor(-255); delay(2000); leftBrake(); delay(1000); // wait for 1000 milliseconds // spin both motors (drive forward) -- left CW, right CCW leftMotor(255); rightMotor(-255); delay(2000); // wait for 2000 milliseconds leftBrake(); rightBrake(); // spin both motors (drive in reverse) -- left CCW, right CW leftMotor(-255); rightMotor(255); delay(2000); // wait for 2000 milliseconds leftBrake(); rightBrake(); } /******************* / loop function /*******************/ void loop() { ``` -------------------------------- ### Initialize CCS811 Sensor in Setup Source: https://learn.sparkfun.com/tutorials/ccs811bme280-qwiic-environmental-combo-breakout-hookup-guide Call the `begin()` function within the `setup()` function to initialize the CCS811 sensor. This function handles starting I2C, checking the ID register, validating app data, starting the application, and establishing a drive mode. The `begin()` function returns a status code indicating success or failure. ```cpp void setup() { myCCS811.begin(); } ``` -------------------------------- ### Arduino Compilation Error Output Source: https://learn.sparkfun.com/tutorials/installing-an-arduino-library/discuss Example of error messages generated by the Arduino IDE when a library is not correctly installed or recognized. ```text CapacitiveSensorSketch:12: error: 'CapacitiveSensor' does not name a type CapacitiveSensorSketch:13: error: 'CapacitiveSensor' does not name a type CapacitiveSensorSketch:14: error: 'CapacitiveSensor' does not name a type CapacitiveSensorSketch.pde: In function 'void setup()': CapacitiveSensorSketch:18: error: 'cs_4_2' was not declared in this scope CapacitiveSensorSketch.pde: In function 'void loop()': CapacitiveSensorSketch:25: error: 'cs_4_2' was not declared in this scope CapacitiveSensorSketch:26: error: 'cs_4_6' was not declared in this scope CapacitiveSensorSketch:27: error: 'cs_4_8' was not declared in this scope ``` -------------------------------- ### Configure BME280 Settings Source: https://learn.sparkfun.com/tutorials/ccs811bme280-qwiic-environmental-combo-breakout-hookup-guide Example of setting communication interface, operation mode, and oversampling parameters within the Arduino setup function. ```cpp #include #include "SparkFunBME280.h" #include "Wire.h" #include "SPI.h" //Global sensor object BME280 mySensor; void setup() { //***Driver settings********************************// //commInterface can be I2C_MODE //specify I2C address. Can be 0x77(default) or 0x76 //For I2C, enable the following mySensor.settings.commInterface = I2C_MODE; mySensor.settings.I2CAddress = 0x77; //***Operation settings*****************************// //runMode can be: // 0, Sleep mode // 1 or 2, Forced mode // 3, Normal mode mySensor.settings.runMode = 3; //Forced mode //tStandby can be: // 0, 0.5ms // 1, 62.5ms // 2, 125ms // 3, 250ms // 4, 500ms // 5, 1000ms // 6, 10ms // 7, 20ms mySensor.settings.tStandby = 0; //filter can be off or number of FIR coefficients to use: // 0, filter off // 1, coefficients = 2 // 2, coefficients = 4 // 3, coefficients = 8 // 4, coefficients = 16 mySensor.settings.filter = 0; //tempOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively mySensor.settings.tempOverSample = 1; //pressOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively mySensor.settings.pressOverSample = 1; //humidOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively mySensor.settings.humidOverSample = 1; delay(10); //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up. Serial.begin(57600); Serial.print("Starting BME280... result of .begin(): 0x"); //Calling .begin() causes the settings to be loaded Serial.println(mySensor.begin(), HEX); } ``` -------------------------------- ### Combined Example A: Serial and Qwiic Micro OLED Source: https://learn.sparkfun.com/tutorials/lipo-fuel-gauge-max1704x-hookup-guide Displays battery voltage and state of charge on both the Serial Monitor and a Qwiic Micro OLED using the MAX17043. Requires a Qwiic setup and compatible microcontroller. ```Arduino #include "SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h" #include "SparkFun_Micro_OLED.h" #include "Wire.h" SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library fuelGauge; SparkFun_Micro_OLED oled; void setup() { Serial.begin(115200); Wire.begin(); // Initialize OLED if (!oled.begin()) { Serial.println("Failed to initialize OLED!"); while (1); } oled.clear(ALL); oled.display(); Serial.println("OLED Initialized!"); // Initialize Fuel Gauge if (!fuelGauge.begin()) { Serial.println("Device not found. Check connections."); while (1); } Serial.println("MAX17043 Fuel Gauge Found!"); } void loop() { // Get readings float voltage = fuelGauge.getVoltage(); float percentage = fuelGauge.getSOC(); // Print to Serial Monitor Serial.print("Voltage: "); Serial.print(voltage, 3); Serial.print(" V | State of Charge: "); Serial.print(percentage, 1); Serial.println(" %"); // Display on OLED oled.clear(ALL); oled.setCursor(0, 0); oled.print("Voltage: "); oled.print(voltage, 3); oled.println(" V"); oled.setCursor(0, 10); oled.print("SOC: "); oled.print(percentage, 1); oled.println(" %"); oled.display(); delay(2000); } ``` -------------------------------- ### Import Libraries and Initialize I2C Source: https://learn.sparkfun.com/tutorials/keyboard-shortcut-qwiic-keypad Import necessary libraries and set up the I2C communication bus. Define the I2C address for the Qwiic Keypad. ```python import time import board import busio i2c = busio.I2C(board.SCL, board.SDA) i2caddress = 75 #equals 0x4B in HEX ``` -------------------------------- ### Combined MAX17043 and Qwiic OLED Example Source: https://learn.sparkfun.com/tutorials/lipo-fuel-gauge-max1704x-hookup-guide This Arduino sketch initializes the MAX17043 fuel gauge and Qwiic Micro OLED, then continuously updates the display with battery voltage and charge percentage. Ensure the required libraries are installed via the Arduino Library Manager. ```cpp Copy Code/****************************************************************************** Combined Simple Serial and Qwiic Micro OLED Example Modified By: Ho Yun "Bobby" Chan SparkFun Electronics Date: February 10, 2023 License: MIT. See license file for more information but you can basically do whatever you want with this code. This is a combined example of Paul Clark's MAX17043 Fuel Guage simple serial example and Kirk Benell's Qwiic OLED Hello example. The example reads a single cell LiPo battery's voltage and state-of-charge (SOC) using the MAX1704X. The voltage, percent remaining (i.e. the SOC), and alert flag are displayed as an output on the Qwiic Micro OLED. By opening the Arduino Serial Monitor (115200 baud), the example will also print the gauge's voltage, state-of-charge (SOC) readings, alert status to Serial. Feel like supporting open source hardware? Buy a board from SparkFun! LiPo Fuel Gauge - MAX17043: https://www.sparkfun.com/products/20680 Qwiic Micro OLED: https://www.sparkfun.com/products/14532 Distributed as-is; no warranty is given. ******************************************************************************/ #include // Needed for I2C //////////LIPO FUEL GAUGE////////// #include // Click here to get the library: http://librarymanager/All#SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library SFE_MAX1704X lipo; // Defaults to the MAX17043 //SFE_MAX1704X lipo(MAX1704X_MAX17043); // Create a MAX17043 //SFE_MAX1704X lipo(MAX1704X_MAX17044); // Create a MAX17044 //SFE_MAX1704X lipo(MAX1704X_MAX17048); // Create a MAX17048 //SFE_MAX1704X lipo(MAX1704X_MAX17049); // Create a MAX17049 double voltage = 0; // Variable to keep track of LiPo voltage double soc = 0; // Variable to keep track of LiPo state-of-charge (SOC) bool alert; // Variable to keep track of whether alert has been triggered //////////QWIIC MICRO OLED////////// #include //http://librarymanager/All#SparkFun_Qwiic_Graphic_OLED // The Qwiic OLED Library supports three different types of SparkFun boards. The demo uses the following // defines to determine which device is being used. Uncomment the device being used for this demo. QwiicMicroOLED myOLED; // QwiicTransparentOLED myOLED; // QwiicNarrowOLED myOLED; // Fonts #include //#include , not used //#include , not used //#include , not used //#include , not used void setup() { Serial.begin(115200); // Start serial, to output debug data //while (!Serial) // ; //Wait for user to open terminal Serial.println(F("Combined MAX17043 Simple Serial Example & Qwiic OLED Example")); Wire.begin(); lipo.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial // Set up the MAX17043 LiPo fuel gauge: if (lipo.begin() == false) // Connect to the MAX17043 using the default wire port { Serial.println(F("MAX17043 not detected. Please check wiring. Freezing.")); while (1) ; } // Initalize the OLED device and related graphics system if (myOLED.begin() == false) { Serial.println("Device begin failed. Freezing..."); while (true) ; } // Quick start restarts the MAX17043 in hopes of getting a more accurate // guess for the SOC. lipo.quickStart(); // We can set an interrupt to alert when the battery SoC gets too low. // We can alert at anywhere between 1% - 32%: lipo.setThreshold(20); // Set alert threshold to 20%. }// end setup() void loop() { // lipo.getVoltage() returns a voltage value (e.g. 3.93) voltage = lipo.getVoltage(); // lipo.getSOC() returns the estimated state of charge (e.g. 79%) soc = lipo.getSOC(); // lipo.getAlert() clears the alert flag // Output: 0 on success, positive integer on fail. lipo.clearAlert(); // lipo.getAlert() returns a 0 or 1 (0=alert not triggered) alert = lipo.getAlert(); myOLED.erase(); //clear display //set font type, we'll use a character size of 5x7 myOLED.setFont(&QW_FONT_5X7); //myOLED.setFont(&QW_FONT_8X16); //not used //myOLED.setFont(&QW_FONT_31X48); //not used //myOLED.setFont(&QW_FONT_LARGENUM); //not used //myOLED.setFont(&QW_FONT_7SEGMENT); //not used //Print Voltage myOLED.setCursor(0, 0); myOLED.print(voltage, 2); myOLED.print(F("V")); //Print Battery % myOLED.setCursor(0, 10); myOLED.print(soc, 2); myOLED.print(F("%")); //Print Alert Status myOLED.setCursor(0, 20); myOLED.print(F("VBAT:")); //alert pin if (alert == HIGH) { myOLED.print("LOW"); //Flag was raised, battery is low!!! } else { ``` -------------------------------- ### ESP32 BLE Accelerometer Setup and Loop Source: https://learn.sparkfun.com/tutorials/displaying-sensor-data-with-bluetooth Initializes the KX13X sensor and BLE server, then broadcasts accelerometer data in the main loop. ```cpp #include // Click here to get the library: http://librarymanager/All#SparkFun_KX13X SparkFun_KX132 kxAccel; outputData myData; // Struct for the accelerometer's data // See the following for generating UUIDs: // https://www.uuidgenerator.net/ #define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b" #define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8" #define CHARACTERISTIC_ACCX_UUID "fb6cf981-31cc-4f36-af06-1f2f3e919840" #define CHARACTERISTIC_ACCY_UUID "35b17f66-73d1-4c92-92f6-9032ef1987d3" #define CHARACTERISTIC_ACCZ_UUID "3cab9341-e65b-46e9-83ed-c8a7f2f841c2" // makes the chracteristic globlal static BLECharacteristic *pCharacteristicAccX; static BLECharacteristic *pCharacteristicAccY; static BLECharacteristic *pCharacteristicAccZ; void setup() { Serial.begin(115200); Serial.println("Starting BLE work!"); Wire.begin(); //connect the accelerometer to the board using qwiic cables if (!kxAccel.begin()) { Serial.println("Could not communicate with the the KX13X."); while (1) ; } if (kxAccel.softwareReset()) Serial.println("Reset."); // Give some time for the accelerometer to reset. // It needs two, but give it five for good measure. delay(5); // Many settings for KX13X can only be // applied when the accelerometer is powered down. // However there are many that can be changed "on-the-fly" // check datasheet for more info, or the comments in the // "...regs.h" file which specify which can be changed when. kxAccel.enableAccel(false); kxAccel.setRange(SFE_KX132_RANGE16G); // 16g Range // kxAccel.setRange(SFE_KX134_RANGE16G); // 16g for the KX134 kxAccel.enableDataEngine(); // Enables the bit that indicates data is ready. // kxAccel.setOutputDataRate(); // Default is 50Hz kxAccel.enableAccel(); BLEDevice::init("Long name works now"); BLEServer *pServer = BLEDevice::createServer(); BLEService *pService = pServer->createService(SERVICE_UUID); BLECharacteristic *pCharacteristic = pService->createCharacteristic( CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicAccX = pService->createCharacteristic( CHARACTERISTIC_ACCX_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicAccY = pService->createCharacteristic( CHARACTERISTIC_ACCY_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicAccZ = pService->createCharacteristic( CHARACTERISTIC_ACCZ_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristic->setValue("Hello World says Neil"); pService->start(); // BLEAdvertising *pAdvertising = pServer->getAdvertising(); // this still is working for backward compatibility BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); pAdvertising->addServiceUUID(SERVICE_UUID); pAdvertising->setScanResponse(true); pAdvertising->setMinPreferred(0x06); pAdvertising->setMinPreferred(0x12); BLEDevice::startAdvertising(); Serial.println("Characteristic defined!"); } void loop() { // put your main code here, to run repeatedly: if (kxAccel.dataReady()) { float tempX = myData.xData;//gives the pCharacteristic the pointer insted of the value pCharacteristicAccX->setValue(tempX);//setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string float tempY =myData.yData; pCharacteristicAccY->setValue(tempY); float tempZ = myData.zData; pCharacteristicAccZ->setValue(tempZ); kxAccel.getAccelData(&myData); Serial.print(tempX, 4); Serial.print("\t"); Serial.print(tempY, 4); Serial.print("\t"); Serial.println(tempZ, 4); } delay(100);// 100 ms } ``` -------------------------------- ### Run Obstacle Detector Example Source: https://learn.sparkfun.com/tutorials/getting-started-with-the-a111-pulsed-radar-sensor Execute the obstacle detector application to check if there is an object in the sensor's path. ```bash example_detector_obstacle_rpi_sparkfun_a111_r2c ``` -------------------------------- ### Initialize ZED-F9P Communication Source: https://learn.sparkfun.com/tutorials/gnss-correction-data-receiver-neo-d9s-hookup-guide Initialize the module within the setup function using the default I2C address. ```cpp while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port and the default I2C address (0x42) { Serial.println(F("u-blox GNSS module not detected at default I2C address. Please check wiring.")); delay(2000); } Serial.println(F("u-blox GNSS module connected")); ``` -------------------------------- ### Install Arduino Library Source: https://learn.sparkfun.com/tutorials/lsm9ds0-hookup-guide Install the SFE_LSM9DS0 Arduino library to interface with the LSM9DS0 breakout board. This library simplifies reading sensor data. ```arduino #include #include #include "SparkFunLSM9DS0.h" // Instantiate the LSM9DS0 sensor object // Use the default constructor for I2C communication // LSM9DS0 myIMU; // Or, if you want to use SPI, use the following: // LSM9DS0 myIMU(IMU_SPI, 0x6B, 0x1E); // (SPI, IMU_ADDRESS, WHO_AM_I_ADDRESS) ``` -------------------------------- ### Configure WiFi Credentials Source: https://learn.sparkfun.com/tutorials/getting-started-with-u-blox-thingstream-and-pointperfect Replace the placeholder strings with your local network SSID and password. ```cpp const char ssid[] = ""; const char password[] = ""; ``` -------------------------------- ### Initialize MPU9250 and Handle Connection Errors Source: https://learn.sparkfun.com/tutorials/mpu-9250-hookup-guide Handles the initial connection check and displays factory calibration values on an optional LCD. ```cpp Serial.println(myIMU.factoryMagCalibration[2], 2); } #ifdef LCD display.clearDisplay(); display.setCursor(20,0); display.print("AK8963"); display.setCursor(0,10); display.print("ASAX "); display.setCursor(50,10); display.print(myIMU.factoryMagCalibration[0], 2); display.setCursor(0,20); display.print("ASAY "); display.setCursor(50,20); display.print(myIMU.factoryMagCalibration[1], 2); display.setCursor(0,30); display.print("ASAZ "); display.setCursor(50,30); display.print(myIMU.factoryMagCalibration[2], 2); display.display(); delay(1000); #endif // LCD } // if (c == 0x71) else { Serial.print("Could not connect to MPU9250: 0x"); Serial.println(c, HEX); // Communication failed, stop here Serial.println(F("Communication failed, abort!")); Serial.flush(); abort(); } } ```