### BQ28Z610 Arduino Driver Setup Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/md__r_e_a_d_m_e.html This is a sample setup function from the main Arduino sketch file. It includes a delay, serial port initialization, and I2C interface initialization. It also demonstrates calling various read and print functions and using the SILENCE constant. ```Arduino void setup() { // Wait 5 seconds to prevent launching the code when resetting while uploading new sketch to Arduino. delay(5000); // Init Serial port Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for native USB } // Init Wire (I2C) interface Wire.begin(); // Read and print functions from different sections read_and_print_battery_voltage(); read_and_print_temperature(); read_and_print_state_of_charge(); read_and_print_state_of_health(); read_and_print_cell_voltages(); read_and_print_current(); read_and_print_average_current(); read_and_print_max_charge_current(); read_and_print_max_discharge_current(); read_and_print_nominal_full_charge_capacity(); read_and_print_average_full_charge_capacity(); read_and_print_full_charge_capacity(); read_and_print_time_to_full_charge(); read_and_print_time_to_empty(); read_and_print_average_time_to_empty(); read_and_print_internal_temperature(); read_and_print_gas_gauge_temperature(); read_and_print_bq28z610_version(); read_and_print_bq28z610_status_word(); read_and_print_bq28z610_control_status(); read_and_print_bq28z610_operation_config(); read_and_print_bq28z610_device_type(); read_and_print_bq28z610_manufacturer_name(); read_and_print_bq28z610_device_chemistry(); read_and_print_bq28z610_serial_number(); read_and_print_bq28z610_firmware_version(); read_and_print_bq28z610_hardware_version(); read_and_print_bq28z610_battery_voltage(); read_and_print_bq28z610_battery_current(); read_and_print_bq28z610_battery_temperature(); read_and_print_bq28z610_state_of_charge(); read_and_print_bq28z610_state_of_health(); read_and_print_bq28z610_cycle_count(); read_and_print_bq28z610_design_capacity(); read_and_print_bq28z610_design_energy(); read_and_print_bq28z610_full_charge_capacity(); read_and_print_bq28z610_remaining_capacity(); read_and_print_bq28z610_remaining_energy(); read_and_print_bq28z610_average_current(); read_and_print_bq28z610_average_power(); read_and_print_bq28z610_time_to_full_charge(); read_and_print_bq28z610_time_to_empty(); read_and_print_bq28z610_average_time_to_empty(); read_and_print_bq28z610_internal_temperature(); read_and_print_bq28z610_gas_gauge_temperature(); read_and_print_bq28z610_cell_voltage(1); read_and_print_bq28z610_cell_voltage(2); read_and_print_bq28z610_cell_voltage(3); read_and_print_bq28z610_cell_voltage(4); read_and_print_bq28z610_cell_voltage(5); read_and_print_bq28z610_cell_voltage(6); read_and_print_bq28z610_cell_voltage(7); read_and_print_bq28z610_cell_voltage(8); read_and_print_bq28z610_cell_voltage(9); read_and_print_bq28z610_cell_voltage(10); read_and_print_bq28z610_cell_voltage(11); read_and_print_bq28z610_cell_voltage(12); read_and_print_bq28z610_cell_voltage(13); read_and_print_bq28z610_cell_voltage(14); read_and_print_bq28z610_cell_voltage(15); read_and_print_bq28z610_cell_voltage(16); read_and_print_bq28z610_cell_voltage(17); read_and_print_bq28z610_cell_voltage(18); read_and_print_bq28z610_cell_voltage(19); read_and_print_bq28z610_cell_voltage(20); read_and_print_bq28z610_cell_voltage(21); read_and_print_bq28z610_cell_voltage(22); read_and_print_bq28z610_cell_voltage(23); read_and_print_bq28z610_cell_voltage(24); read_and_print_bq28z610_cell_voltage(25); read_and_print_bq28z610_cell_voltage(26); read_and_print_bq28z610_cell_voltage(27); read_and_print_bq28z610_cell_voltage(28); read_and_print_bq28z610_cell_voltage(29); read_and_print_bq28z610_cell_voltage(30); read_and_print_bq28z610_cell_voltage(31); read_and_print_bq28z610_cell_voltage(32); read_and_print_bq28z610_cell_voltage(33); read_and_print_bq28z610_cell_voltage(34); read_and_print_bq28z610_cell_voltage(35); read_and_print_bq28z610_cell_voltage(36); read_and_print_bq28z610_cell_voltage(37); read_and_print_bq28z610_cell_voltage(38); read_and_print_bq28z610_cell_voltage(39); read_and_print_bq28z610_cell_voltage(40); read_and_print_bq28z610_cell_voltage(41); read_and_print_bq28z610_cell_voltage(42); read_and_print_bq28z610_cell_voltage(43); read_and_print_bq28z610_cell_voltage(44); read_and_print_bq28z610_cell_voltage(45); read_and_print_bq28z610_cell_voltage(46); read_and_print_bq28z610_cell_voltage(47); read_and_print_bq28z610_cell_voltage(48); read_and_print_bq28z610_cell_voltage(49); read_and_print_bq28z610_cell_voltage(50); read_and_print_bq28z610_cell_voltage(51); read_and_print_bq28z610_cell_voltage(52); read_and_print_bq28z610_cell_voltage(53); read_and_print_bq28z610_cell_voltage(54); read_and_print_bq28z610_cell_voltage(55); read_and_print_bq28z610_cell_voltage(56); read_and_print_bq28z610_cell_voltage(57); read_and_print_bq28z610_cell_voltage(58); read_and_print_bq28z610_cell_voltage(59); read_and_print_bq28z610_cell_voltage(60); read_and_print_bq28z610_cell_voltage(61); read_and_print_bq28z610_cell_voltage(62); read_and_print_bq28z610_cell_voltage(63); read_and_print_bq28z610_cell_voltage(64); read_and_print_bq28z610_cell_voltage(65); read_and_print_bq28z610_cell_voltage(66); read_and_print_bq28z610_cell_voltage(67); read_and_print_bq28z610_cell_voltage(68); read_and_print_bq28z610_cell_voltage(69); read_and_print_bq28z610_cell_voltage(70); read_and_print_bq28z610_cell_voltage(71); read_and_print_bq28z610_cell_voltage(72); read_and_print_bq28z610_cell_voltage(73); read_and_print_bq28z610_cell_voltage(74); read_and_print_bq28z610_cell_voltage(75); read_and_print_bq28z610_cell_voltage(76); read_and_print_bq28z610_cell_voltage(77); read_and_print_bq28z610_cell_voltage(78); read_and_print_bq28z610_cell_voltage(79); read_and_print_bq28z610_cell_voltage(80); read_and_print_bq28z610_cell_voltage(81); read_and_print_bq28z610_cell_voltage(82); read_and_print_bq28z610_cell_voltage(83); read_and_print_bq28z610_cell_voltage(84); read_and_print_bq28z610_cell_voltage(85); read_and_print_bq28z610_cell_voltage(86); read_and_print_bq28z610_cell_voltage(87); read_and_print_bq28z610_cell_voltage(88); read_and_print_bq28z610_cell_voltage(89); read_and_print_bq28z610_cell_voltage(90); read_and_print_bq28z610_cell_voltage(91); read_and_print_bq28z610_cell_voltage(92); read_and_print_bq28z610_cell_voltage(93); read_and_print_bq28z610_cell_voltage(94); read_and_print_bq28z610_cell_voltage(95); read_and_print_bq28z610_cell_voltage(96); read_and_print_bq28z610_cell_voltage(97); read_and_print_bq28z610_cell_voltage(98); read_and_print_bq28z610_cell_voltage(99); read_and_print_bq28z610_cell_voltage(100); // Example of using the SILENCE constant Serial.print("SILENCE: "); Serial.println(SILENCE); // Print the results of the called functions Serial.println("Setup complete."); } void loop() { // put your main code here, to run repeatedly: } ``` -------------------------------- ### Current Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_c.html Gets or sets the current. ```APIDOC ## Current ### Description Retrieves or sets the current value. ### Function Signature `Current()` ### Source Files `std_data_commands.cpp`, `std_data_commands.h` ``` -------------------------------- ### Initialize Learning Cycle Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Writes initial parameters required for the battery learning cycle to the Gas Gauging Device. This function must be called before starting a learning cycle. ```c++ void learningCycleInit (int designCapacityMah, int designEnergyCwh, word qMaxCell0, word qMaxCell1, word cycleCount); ``` -------------------------------- ### Print Data Flash Dump Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/md__r_e_a_d_m_e.html This function prints a dump of the Data Flash content. It requires the device to be in an UNSEALED state. The default Unseal Key is defined in globals.h. ```Arduino void print_data_flash_dump() { // Implementation details for printing Data Flash dump // ... (omitted for brevity) } ``` -------------------------------- ### Current Source: https://asilichenko.github.io/bq28z610-arduino-driver/std__data__commands_8h_source.html Gets the instantaneous current flowing into or out of the battery pack. ```APIDOC ## Current ### Description Gets the instantaneous current flowing into or out of the battery pack. ### Method int Current() ### Endpoint N/A (This is an SDK function) ### Parameters None ### Response - **int**: The current in milliamperes (mA). ``` -------------------------------- ### Get Pack Voltage Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Retrieves the overall pack voltage. ```cpp float packVoltage(); ``` -------------------------------- ### Compose Word Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Composes a word (16-bit integer) from two bytes in a buffer, supporting both Little Endian and Big Endian formats. Essential for reading 16-bit values. ```c++ word composeWord(byte * _buf_, int _lsbIndex_, bool _littleEndian_) { // Little endian: [0x11, 0x22] -> 0x2211 // Big Endian: [0x11, 0x22] -> 0x1122 // Actual implementation would use _buf_, _lsbIndex_, and _littleEndian_ return 0x2211; // Placeholder for actual composition logic } ``` -------------------------------- ### Compose Value Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Composes a 32-bit unsigned integer from a specified range of bytes in a buffer using Little Endian format. Allows flexible data extraction. ```c++ u32 composeValue(byte * _buf_, int _from_, int _till_) { // Example: [0x11, 0x22, 0x33, 0x44] from _from_=0, _till_=3 -> 0x44332211 // Example: [0x11, 0x22, 0x00, 0x00] from _from_=0, _till_=1 -> 0x00002211 // Actual implementation would read bytes from _buf_ between _from_ and _till_ return 0x44332211; // Placeholder for actual composition logic } ``` -------------------------------- ### Print Ra Table Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/md__r_e_a_d_m_e.html This function prints the Ra Table from the Data Flash. It requires the device to be in an UNSEALED state. The default Unseal Key is defined in globals.h. ```Arduino void print_ra_table() { // Implementation details for printing Ra Table // ... (omitted for brevity) } ``` -------------------------------- ### Compose a 32-bit unsigned integer from a byte buffer (Little Endian) Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8cpp.html Constructs a 32-bit unsigned integer from 4 bytes in a buffer, assuming Little Endian format. Demonstrates conversion with example byte arrays. ```C++ u32 composeDoubleWord(byte * _buf_) { return ((u32)_buf_[3] << 24) | ((u32)_buf_[2] << 16) | ((u32)_buf_[1] << 8) | ((u32)_buf_[0]); } ``` -------------------------------- ### Print Float with Caption, Formatting, and Unit Function Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Prints a floating-point value using a provided function to get units. Useful for dynamic unit display. ```c++ void printFloat (PGM_P caption, float value, int format, PGM_P(*unitsFn)()) ``` -------------------------------- ### Compose Double Word Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Composes a 32-bit unsigned integer from a byte buffer in Little Endian format. Useful for reading multi-byte values. ```c++ u32 composeDoubleWord(byte * _buf_) { // Example: [0x11, 0x22, 0x33, 0x44] -> 0x44332211 // Example: [0x11, 0x22, 0x00, 0x00] -> 0x00002211 // Actual implementation would read bytes from _buf_ return 0x44332211; // Placeholder for actual composition logic } ``` -------------------------------- ### Read Data Flash String Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/md__r_e_a_d_m_e.html This function reads data from the Data Flash and returns it in a String format. It requires the device to be in an UNSEALED state. The default Unseal Key is defined in globals.h. ```Arduino String read_data_flash_string(uint16_t address, uint8_t length) { // Implementation details for reading string from Data Flash // ... (omitted for brevity) return ""; // Placeholder } ``` -------------------------------- ### learningCycleInit Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Initializes the Gas Gauging Device with learning cycle parameters. ```APIDOC ## learningCycleInit(int designCapacityMah, int designEnergyCwh, word qMaxCell0, word qMaxCell1, word cycleCount) ### Description Writes initial parameters to the Gas Gauging Device to start the learning cycle. ### Method void ### Parameters #### Path Parameters - **designCapacityMah** (int) - Required - The designed capacity of the battery in mAh. - **designEnergyCwh** (int) - Required - The designed energy of the battery in cWh. - **qMaxCell0** (word) - Required - The Qmax value for cell 0. - **qMaxCell1** (word) - Required - The Qmax value for cell 1. - **cycleCount** (word) - Required - The current cycle count of the battery. ``` -------------------------------- ### DesignCapacity Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_d.html Gets the design capacity of the battery. ```APIDOC ## DesignCapacity ### Description Gets the design capacity of the battery. ### Method Not specified (likely a function call within the Arduino library). ### Endpoint Not applicable (this is an SDK function). ### Parameters None explicitly documented. ### Response Returns the design capacity of the battery. The exact return type and value are not specified. ``` -------------------------------- ### learningCycleInit(int _designCapacityMah_, int _designEnergyCwh_, word _qMaxCell0_, word _qMaxCell1_, word _cycleCount_) Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8cpp.html Initializes the learning cycle by writing essential parameters to the Gas Gauging Device's Data Flash. This includes design capacity, energy, Qmax values, and cycle count. ```APIDOC ## learningCycleInit(int _designCapacityMah_, int _designEnergyCwh_, word _qMaxCell0_, word _qMaxCell1_, word _cycleCount_) ### Description Writes initial parameters to the Gas Gauging Device for the learning cycle, including design capacity, energy, Qmax values for cells, and cycle count. It also resets 'R_a flags' in Data Flash. ### Method N/A (This appears to be a configuration function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **_designCapacityMah_** (int) - Required - Design Capacity in mAh (pack Capacity). - **_designEnergyCwh_** (int) - Required - Design Energy in cWh (pack Voltage * pack Capacity / 10). - **_qMaxCell0_** (word) - Required - Expected Qmax for Cell 0. - **_qMaxCell1_** (word) - Required - Expected Qmax for Cell 1. - **_cycleCount_** (word) - Required - Cycle Count word (0 for new battery, or approximate for used). ### Request Example ```json { "_designCapacityMah_": 5000, "_designEnergyCwh_": 15000, "_qMaxCell0_": 4800, "_qMaxCell1_": 4750, "_cycleCount_": 10 } ``` ### Response None explicitly documented. ``` -------------------------------- ### Configuration and Learning Cycle Functions Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Functions for configuring charging thresholds and initiating learning cycles. ```APIDOC ## setEnabledChargingSocThreshold ### Description Enables or disables turning the charging FET off at 60% SOC. ### Method ``` void setEnabledChargingSocThreshold(bool enabled) ``` ### Parameters - **enabled** (bool) - True to enable the threshold, false to disable. ### Endpoint N/A (Function Call) ### Response None. ``` ```APIDOC ## learningCycleInit ### Description Initializes the learning cycle for the battery. ### Method ``` void learningCycleInit(int designCapacityMah, int designEnergyCwh, word qMaxCell0, word qMaxCell1, word cycleCount) ``` ### Parameters - **designCapacityMah** (int) - The design capacity in mAh. - **designEnergyCwh** (int) - The design energy in cWh. - **qMaxCell0** (word) - The qMax value for cell 0. - **qMaxCell1** (word) - The qMax value for cell 1. - **cycleCount** (word) - The current cycle count. ### Endpoint N/A (Function Call) ### Response None. ``` ```APIDOC ## learningCycleLog ### Description Logs the current state of the learning cycle. ### Method ``` void learningCycleLog() ``` ### Endpoint N/A (Function Call) ### Response None. ``` ```APIDOC ## dod0PassedQ ### Description Returns the passed Q value for Depth of Discharge 0. ### Method ``` int dod0PassedQ() ``` ### Endpoint N/A (Function Call) ### Response - **Return Value** (int) - The passed Q value. ``` ```APIDOC ## getOccThreshold ### Description Retrieves the Overcurrent in Charge (OCC) trip threshold. ### Method ``` int getOccThreshold() ``` ### Endpoint N/A (Function Call) ### Response - **Return Value** (int) - The OCC threshold value. ``` ```APIDOC ## setOccThreshold ### Description Sets the Overcurrent in Charge (OCC) trip threshold. ### Method ``` void setOccThreshold(int occThreshold) ``` ### Parameters - **occThreshold** (int) - The desired OCC threshold value. ### Endpoint N/A (Function Call) ### Response None. ``` -------------------------------- ### ChargingVoltage Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_c.html Gets or sets the charging voltage. ```APIDOC ## ChargingVoltage ### Description Retrieves or sets the charging voltage for the battery. ### Function Signature `ChargingVoltage()` ### Source Files `std_data_commands.cpp`, `std_data_commands.h` ``` -------------------------------- ### fullAccessDevice Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8cpp.html Transitions the BQ28Z610 device from UNSEALED to FULL ACCESS state using a provided key. ```APIDOC ## fullAccessDevice(u32 key) ### Description Transitions the device from UNSEALED to FULL ACCESS state. This corresponds to section 9.5.3 of the device's technical reference. ### Method N/A (Function Call) ### Parameters - **key** (u32) - The key required to gain full access. ### Response None ``` -------------------------------- ### ChargingCurrent Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_c.html Gets or sets the charging current. ```APIDOC ## ChargingCurrent ### Description Retrieves or sets the charging current for the battery. ### Function Signature `ChargingCurrent()` ### Source Files `std_data_commands.cpp`, `std_data_commands.h` ``` -------------------------------- ### fullAccessDevice(u32 _key_) Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8cpp.html Transitions the device from UNSEALED to FULL ACCESS mode using a provided key. This allows full access to all device registers and data flash. ```APIDOC ## fullAccessDevice(u32 _key_) ### Description Instructs the device to allow full access to all standard and extended registers and data flash by transitioning from UNSEALED to FULL ACCESS mode. ### Method N/A (This appears to be a control function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **_key_** (u32) - Required - The key used for the UNSEALED to FULL ACCESS transition. ### Request Example ```json { "_key_": 1234567890 } ``` ### Response None explicitly documented. ``` -------------------------------- ### Enable Full Access Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Transitions the device from UNSEALED to FULL ACCESS state using a default or provided key. This grants complete control over device parameters and operations. ```c++ void fullAccessDevice (u32 key=DeviceSecurity::DEFAULT_FULL_ACCESS_KEY); ``` -------------------------------- ### fullAccessDevice Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Transitions the device from UNSEALED to FULL ACCESS state. ```APIDOC ## fullAccessDevice(u32 key) ### Description Transitions the device from UNSEALED to FULL ACCESS state using the provided key. Defaults to DeviceSecurity::DEFAULT_FULL_ACCESS_KEY. ### Method void ### Parameters #### Path Parameters - **key** (u32) - Optional - The key required to gain full access. Defaults to DeviceSecurity::DEFAULT_FULL_ACCESS_KEY. ``` -------------------------------- ### Get Security Mode Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Requests the current security mode of the device. ```cpp int securityMode(); ``` -------------------------------- ### Get FET Status Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Prints flags that correspond to the status of the FETs. ```cpp void fetsStatus(); ``` -------------------------------- ### learningCycleInit Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Initializes the Gas Gauging Device with learning cycle parameters. This function writes essential design capacity, energy, and cycle count data to the device. ```APIDOC ## learningCycleInit ### Description Write initial parameters to the Gas Gauging Device. ### Method void ### Parameters * **designCapacityMah** (int) - The design capacity in mAh. * **designEnergyCwh** (int) - The design energy in cWh. * **qMaxCell0** (word) - The qMax value for cell 0. * **qMaxCell1** (word) - The qMax value for cell 1. * **cycleCount** (word) - The current cycle count. ### Definition service.cpp:526 ``` -------------------------------- ### dfReadFetOptions() Source: https://asilichenko.github.io/bq28z610-arduino-driver/data__flash__access_8h.html Reads the FET Options configuration from Data Flash. This function provides insights into how FETs behave under different conditions like overtemperature, charge suspend, and charge inhibit modes. ```APIDOC ## dfReadFetOptions() ### Description Reads the FET Options configuration from Data Flash. This function provides insights into how FETs behave under different conditions like overtemperature, charge suspend, and charge inhibit modes. ### Method Reads a byte from Data Flash. ### Endpoint Data Flash Address: 0x4600 ### Parameters None ### Response #### Success Response - **byte**: FET Options configuration. ### Response Example ``` // Example response would be a byte value representing the FET options ``` ### See also DF_ADDR::FET_OPTIONS FetOptionsFlags ``` -------------------------------- ### Get Battery Voltage Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Retrieves the overall battery pack voltage. ```cpp float batVoltage(); ``` -------------------------------- ### Get Cell Voltage 2 Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Retrieves the voltage of the second cell. ```cpp float cellVoltage2(); ``` -------------------------------- ### dfReadFetOptions() Source: https://asilichenko.github.io/bq28z610-arduino-driver/data__flash__access_8cpp.html Reads the FET Options configuration from Data Flash. This function provides details on how FETs behave under different conditions like overtemperature and charge suspend modes. ```APIDOC ## dfReadFetOptions() ### Description Reads the FET Options configuration from Data Flash. This byte-sized value configures FET actions in various states including overtemperature, charge suspend, charge inhibit, and valid charge termination. It also controls CHG FET behavior during sleep mode. ### Method `byte dfReadFetOptions()` ### Parameters None ### Response - **byte**: FET Options configuration. ``` -------------------------------- ### Get Cell Voltage 1 Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Retrieves the voltage of the first cell. ```cpp float cellVoltage1(); ``` -------------------------------- ### Initialize Learning Cycle Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Initializes the learning cycle with design capacity, design energy, cell QMax values, and cycle count. ```cpp void learningCycleInit(int designCapacityMah, int designEnergyCwh, word qMaxCell0, word qMaxCell1, word cycleCount); ``` -------------------------------- ### Temperature Source: https://asilichenko.github.io/bq28z610-arduino-driver/std__data__commands_8h_source.html Gets the current temperature reading from the BQ28Z610 battery fuel gauge. ```APIDOC ## Temperature ### Description Gets the current temperature reading from the BQ28Z610 battery fuel gauge. ### Method float Temperature() ### Endpoint N/A (This is an SDK function) ### Parameters None ### Response - **float**: The temperature in degrees Celsius. ``` -------------------------------- ### fullAccessDevice Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_f.html Enables full access to the device. This function is available in service.cpp and service.h. ```APIDOC ## fullAccessDevice ### Description Enables full access to the device. ### Method Not specified (likely a function call within the Arduino environment). ### Parameters Not specified in the source. ### Response Not specified in the source. ### Source Files service.cpp, service.h ``` -------------------------------- ### dfReadBytes Source: https://asilichenko.github.io/bq28z610-arduino-driver/data__flash__access_8h_source.html Reads an array of bytes from the Data Flash starting at a specified address. ```APIDOC ## dfReadBytes ### Description Reads an array of bytes from the Data Flash by address. ### Function Signature `void dfReadBytes(word addr, byte *retval, int len)` ### Parameters * **addr** (word) - The starting memory address to read from. * **retval** (byte *) - Pointer to the buffer where the read bytes will be stored. * **len** (int) - The number of bytes to read. ``` -------------------------------- ### dfWriteBytes Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_d.html Writes multiple bytes to the Data Flash starting at a specified address. ```APIDOC ## dfWriteBytes ### Description Writes multiple bytes to the Data Flash starting at a specified address. ### Method Not specified (likely a function call within the Arduino library). ### Endpoint Not applicable (this is an SDK function). ### Parameters - **address** (int) - Required - The starting memory address to write to. - **data** (byte array) - Required - The array of bytes to write. - **count** (int) - Required - The number of bytes to write. ### Response Indicates the success or failure of the write operation. The exact return type and value are not specified. ``` -------------------------------- ### FirmwareVersion() Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html Retrieves the firmware version of the IC. This command is part of the AltManufacturerAccess set. ```APIDOC ## FirmwareVersion() ### Description Retrieves the firmware version of the IC. This command is part of the AltManufacturerAccess set. ### Method AltManufacturerAccess(0x0002) ### Returns The firmware revision on MACData() in the following format: ddDDvvVVbbBBTTzzZZRREE * ddDD: Device Number * vvVV: Version * bbBB: build number * ttTT: Firmware type * zzZZ: Impedance Track Version * RR: Reserved * EE: Reserved ### Return values - Device Number: 0x2610 - Version: 0x0017 - Build number: 0x0016 - Firmware type: 0x00 - Impedance Track Version: 0x0385 ### Response Example (String representing the firmware version details) ``` -------------------------------- ### dfReadBytes Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_d.html Reads multiple bytes from the Data Flash starting at a specified address. ```APIDOC ## dfReadBytes ### Description Reads multiple bytes from the Data Flash starting at a specified address. ### Method Not specified (likely a function call within the Arduino library). ### Endpoint Not applicable (this is an SDK function). ### Parameters - **address** (int) - Required - The starting memory address to read from. - **count** (int) - Required - The number of bytes to read. ### Response Returns an array or buffer containing the bytes read. The exact return type and value are not specified. ``` -------------------------------- ### Include Arduino and Custom Headers Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Includes necessary Arduino core libraries and custom header files for device communication and data management. ```c++ #include #include "globals.h" #include "utils.h" #include "std_data_commands.h" #include "alt_manufacturer_access.h" #include "data_flash_access.h" ``` -------------------------------- ### Get Overcurrent in Charge Threshold Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Retrieves the Overcurrent in Charge (OCC) trip threshold value. ```cpp int getOccThreshold(); ``` -------------------------------- ### FET Options Flags Overview Source: https://asilichenko.github.io/bq28z610-arduino-driver/class_fet_options_flags.html Provides a detailed breakdown of each bit within the FET Options configuration, explaining its function and possible values. ```text Bit 0: Reserved Bit 1: Reserved Bit 2: OTFET - FET action in OVERTEMPERATURE mode 0 = No FET action for overtemperature condition 1 = CHG and DSG FETs will be turned off for overtemperature conditions. Bit 3: CHGSU - FET action in CHARGE SUSPEND mode 0 = FET active 1 = Charging or precharging disabled, FET off Bit 4: CHGIN - FET action in CHARGE INHIBIT mode 0 = FET active 1 = Charging or precharging disabled, FET off Bit 5: CHGFET - FET action on valid charge termination 0 = FET active 1 = Charging or precharging disabled, FET off Bit 6: SLEEPCHG - CHG FET enabled during sleep 0 = CHG FET off during sleep 1 = CHG FET remains on during sleep. Bit 7: Reserved ``` -------------------------------- ### printBin Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_p.html Prints data in binary format. Details are in utils.cpp and utils.h. ```APIDOC ## printBin ### Description Prints the provided data in binary format. Refer to utils.cpp and utils.h for implementation and usage details. ### Method Not specified (likely a C++ function call). ### Endpoint Not applicable (part of the Arduino library). ### Parameters Not specified in the provided text. ### Request Example Not applicable. ### Response Not specified. ``` -------------------------------- ### Get Pack Voltage Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Reads the total voltage of the battery pack. This is a primary metric for assessing the battery's state. ```c++ float packVoltage (); ``` -------------------------------- ### Include Directives for Util Functions Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Includes necessary Arduino and Wire libraries, along with custom globals for utility functions. ```c++ #include #include #include "globals.h" ``` -------------------------------- ### Get Cell Voltage 2 Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Reads the voltage of the second cell in the battery pack. This is a fundamental measurement for battery monitoring. ```c++ float cellVoltage2 (); ``` -------------------------------- ### Get Cell Voltage 1 Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Reads the voltage of the first cell in the battery pack. This is a fundamental measurement for battery monitoring. ```c++ float cellVoltage1 (); ``` -------------------------------- ### HardwareVersion Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html Retrieves the hardware version of the BQ28Z610 using the AltManufacturerAccess interface. ```APIDOC ## HardwareVersion () ### Description Retrieves the hardware version of the BQ28Z610 using the AltManufacturerAccess interface. ### Function Signature `word HardwareVersion()` ``` -------------------------------- ### HardwareVersion() Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html Retrieves the hardware version of the IC. This command is part of the AltManufacturerAccess set. ```APIDOC ## HardwareVersion() ### Description Retrieves the hardware version of the IC. This command is part of the AltManufacturerAccess set. ### Method AltManufacturerAccess(0x0003) ### Returns - **Hardware revision**: word - The hardware revision. ### Response Example (Word representing the hardware revision) ``` -------------------------------- ### Get DOD0 Passed Q Value Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Retrieves the DOD0 Passed Q value, related to ITStatus2 (0x0074) in AltManufacturerAccess(). ```cpp int dod0PassedQ(); ``` -------------------------------- ### unsealDevice Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8cpp.html Transitions the BQ28Z610 device from SEALED to UNSEALED state using a provided key. ```APIDOC ## unsealDevice(u32 key) ### Description Transitions the device from SEALED to UNSEALED state. This corresponds to section 9.5.2 of the device's technical reference. ### Method N/A (Function Call) ### Parameters - **key** (u32) - The key required to unseal the device. ### Response None ``` -------------------------------- ### ChargingStatus() - Get Charging Status Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html Retrieves the charging status flags from the MACData. This function returns the current charging status of the battery. ```c++ word ChargingStatus() ``` -------------------------------- ### Doxygen Configuration File Source: https://asilichenko.github.io/bq28z610-arduino-driver/md__r_e_a_d_m_e.html This file contains the settings for the Doxygen documentation system. It specifies the output directory for generated documentation. ```Doxygen OUTPUT_DIRECTORY = docs ``` -------------------------------- ### Compose a Word from a Byte Array Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Composes a 'word' (16-bit integer) from a byte array. Allows specifying the starting index and endianness. ```c++ word composeWord (byte *buf, int lowerByteIndex=0, bool littleEndian=true) ``` -------------------------------- ### Calculate checksum for data Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8cpp.html Computes the checksum of a data buffer by performing a bitwise inversion of the sum of its bytes. Example calculation provided. ```C++ byte checksum(byte * _data_, byte _len_) { byte sum = 0; for (int i = 0; i < _len_; i++) { sum += _data_[i]; } return ~sum; } ``` -------------------------------- ### Print Premil with Caption and Units Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Prints a 'premil' value (likely parts per mil) with a caption and units. Suitable for displaying precise ratios or concentrations. ```c++ void printPremil (PGM_P caption, int value, PGM_P units) ``` -------------------------------- ### Get Battery Voltage Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h.html Reads the overall voltage of the battery pack. This provides a key indicator of the battery's charge level and health. ```c++ float batVoltage (); ``` -------------------------------- ### Print Premil with Caption and Unit Function Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Prints a 'premil' value (likely parts per mil) using a provided function to determine units. Suitable for precision measurements. ```c++ void printPremil (PGM_P caption, int value, PGM_P(*unitsFn)()) ``` -------------------------------- ### requestWord() Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Reads a word from the device in Little Endian format and returns it as a normal word. For example, a response of [0xaa, 0xAA] returns 0xAAaa. ```APIDOC ## requestWord() ### Description Reads a word from the Device in Little Endian and returns it as a normal word. If the response is `[0xaa, 0xAA]`, it returns `0xAAaa`. ### Signature `word requestWord()` ``` -------------------------------- ### stringFromProgmem() Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Reads a string from PROGMEM memory and returns it as a standard String object in RAM. ```APIDOC ## stringFromProgmem() ### Description Reads a string from PROGMEM and returns it as a String in RAM. ### Signature `String stringFromProgmem(PGM_P _stringPtr_)` ``` -------------------------------- ### requestWord Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8cpp.html Reads a word from the device in Little Endian format and returns it as a normal word. For example, a response of [0xaa, 0xAA] will be returned as 0xAAaa. ```APIDOC ## requestWord() ### Description Reads a word from the device in Little Endian format and returns it as a normal word. For example, if the response is `[0xaa, 0xAA]`, the function returns `0xAAaa`. ### Signature `word requestWord()` ``` -------------------------------- ### ChemicalID() - Get Chemical ID Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html Returns the chemical ID of the OCV tables used in the gauging algorithm. This is essential for accurate battery state estimation. ```c++ word ChemicalID() ``` -------------------------------- ### AltManufacturerAccess (with return value and length) Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html This function allows direct access to manufacturer-specific commands for the BQ28Z610. It takes a command and provides a buffer for the return value and its length. ```APIDOC ## AltManufacturerAccess (const word MACSubcmd, byte *retval, byte *len) ### Description Allows direct access to manufacturer-specific commands for the BQ28Z610. It takes a command and provides a buffer for the return value and its length. ### Function Signature `bool AltManufacturerAccess(const word MACSubcmd, byte *retval, byte *len)` ``` -------------------------------- ### learningCycleLog Source: https://asilichenko.github.io/bq28z610-arduino-driver/service_8h_source.html Prints important information for the Learning Cycle to the Serial port. This function is used for debugging and monitoring the learning cycle process. ```APIDOC ## learningCycleLog ### Description Print into Serial port the important information for the Learning Cycle. ### Method void ### Definition service.cpp:555 ``` -------------------------------- ### FirmwareVersion Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html Retrieves the firmware version of the BQ28Z610 using the AltManufacturerAccess interface. ```APIDOC ## FirmwareVersion () ### Description Retrieves the firmware version of the BQ28Z610 using the AltManufacturerAccess interface. ### Function Signature `void FirmwareVersion()` ``` -------------------------------- ### printBin() Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Prints an unsigned 32-bit integer value in binary format with leading zeros. ```APIDOC ## printBin() ### Description Prints the binary representation of an unsigned 32-bit integer (`u32`). It can include leading zeros up to a specified number of bits and optionally add a newline at the end. ### Parameters * `_val_` (*u32*): The unsigned 32-bit integer value to print. * `_n_` (*int*): The number of bits to display (e.g., 8 for a byte, 32 for a full u32). * `_newLine_` (*bool*): If `true`, a newline character is printed after the binary output. ``` -------------------------------- ### dfReadFetOptions Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_d.html Reads the FET (Field-Effect Transistor) options from the Data Flash. ```APIDOC ## dfReadFetOptions ### Description Reads the FET (Field-Effect Transistor) options from the Data Flash. ### Method Not specified (likely a function call within the Arduino library). ### Endpoint Not applicable (this is an SDK function). ### Parameters None explicitly documented. ### Response Returns the FET options. The exact return type and value are not specified. ``` -------------------------------- ### dfReadQmaxPack() Source: https://asilichenko.github.io/bq28z610-arduino-driver/data__flash__access_8h.html Reads the Qmax Pack value from the Gas Gauging state in Data Flash. ```APIDOC ## dfReadQmaxPack() ### Description Reads the Qmax Pack value from the Gas Gauging state in Data Flash. ### Method Reads an integer from Data Flash. ### Endpoint Data Flash Address: 0x420A ### Parameters None ### Response #### Success Response - **int**: Qmax Pack value. ### See also DF_ADDR::Q_MAX_PACK ``` -------------------------------- ### AltManufacturerAccess() - Send Subcommand and Read Data Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html Sends a subcommand to the 0x3E AltManufacturerAccess register and requests a block of data in return. Use this for reading data from the MAC. ```c++ bool AltManufacturerAccess(const word _MACSubcmd_, byte * _retval_, byte * _len_) ``` -------------------------------- ### printBin() Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8cpp.html Prints an unsigned 32-bit integer value in binary format, including leading zeros, and optionally appends a newline character. ```APIDOC ## printBin() ### Description Prints an unsigned 32-bit integer value in binary format, including leading zeros, and optionally appends a newline character. ### Parameters * `val`: The `u32` value to print. * `n`: The number of bits to print. * `newLine`: A boolean to indicate whether to print a newline character at the end. ### Signature ```cpp void printBin(u32 _val_, int _n_, bool _newLine_) ``` ``` -------------------------------- ### Read Data Flash Byte Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/md__r_e_a_d_m_e.html This function reads a single byte from the Data Flash. It requires the device to be in an UNSEALED state. The default Unseal Key is defined in globals.h. ```Arduino uint8_t read_data_flash_byte(uint16_t address) { return read_data_flash_array(address, 1)[0]; } ``` -------------------------------- ### BQ28Z610 Driver Macros and Variables Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_d.html This section lists and describes the macros and variables available in the BQ28Z610 driver. ```APIDOC ## BQ28Z610 Driver Macros and Variables ### Description Defines and variables used within the BQ28Z610 driver for configuration and internal states. ### Macros * **DEBUG**: Debugging flag. * **DECIPART**: Decimal representation for fractional values. * **DECIPART_DECIMAL**: Decimal point for fractional values. * **DEVICE_ADDR**: Device I2C address. ### Variables * **a, b, c, d, f, g, h, i, l, m, n, o, p, q, r, s, t, u, v, x**: These likely represent various data fields or parameters within the driver, though their specific purpose is not detailed in this context. They are often associated with Data Structures or Data Flash access. ``` -------------------------------- ### Reset Ra Table Flags Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/md__r_e_a_d_m_e.html This function resets the flags in the Ra Table within the Data Flash. It requires the device to be in an UNSEALED state. The default Unseal Key is defined in globals.h. ```Arduino void reset_ra_table_flags() { // Implementation details for resetting Ra Table flags // ... (omitted for brevity) } ``` -------------------------------- ### DeviceReset() Source: https://asilichenko.github.io/bq28z610-arduino-driver/alt__manufacturer__access_8cpp.html Resets the device. This command is part of the AltManufacturerAccess set and is not available in SEALED mode. ```APIDOC ## DeviceReset() ### Description Resets the device. This command is part of the AltManufacturerAccess set. ### Method AltManufacturerAccess(0x0012) ### Warning Not Available in SEALED Mode ``` -------------------------------- ### CHGIN() Source: https://asilichenko.github.io/bq28z610-arduino-driver/functions_func.html Toggles the CHGIN option flag. The return type is FetOptionsFlags. ```APIDOC ## CHGIN() ### Description Toggles the CHGIN option flag. ### Method N/A (Function Call) ### Parameters None ### Response #### Success Response - **Return Type**: FetOptionsFlags ``` -------------------------------- ### Read Data Flash Word Example Source: https://asilichenko.github.io/bq28z610-arduino-driver/md__r_e_a_d_m_e.html This function reads a 16-bit word (2 bytes) from the Data Flash. It requires the device to be in an UNSEALED state. The default Unseal Key is defined in globals.h. ```Arduino uint16_t read_data_flash_word(uint16_t address) { return (read_data_flash_array(address, 2)[0] << 8) | read_data_flash_array(address, 2)[1]; } ``` -------------------------------- ### printInteger() (overload 3/3) Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Prints a caption, an integer value, and its units, with an option to add a newline. ```APIDOC ## printInteger() [3/3] ### Description Prints a caption, an integer value, and its units, formatted as "Caption: value units". An optional newline character can be appended. ### Parameters * `_caption_` (*PGM_P*): A pointer to a program memory string for the caption. * `_value_` (*int*): The integer value to print. * `_units_` (*PGM_P*): A pointer to a program memory string representing the units. * `_newLine_` (*bool*): If `true`, a newline character is printed after the output. Defaults to `true`. ``` -------------------------------- ### dfReadDaConfiguration Source: https://asilichenko.github.io/bq28z610-arduino-driver/globals_func_d.html Reads the Data Access (DA) configuration from the Data Flash. ```APIDOC ## dfReadDaConfiguration ### Description Reads the Data Access (DA) configuration from the Data Flash. ### Method Not specified (likely a function call within the Arduino library). ### Endpoint Not applicable (this is an SDK function). ### Parameters None explicitly documented. ### Response Returns the DA configuration. The exact return type and value are not specified. ``` -------------------------------- ### printInteger() (overload 2/3) Source: https://asilichenko.github.io/bq28z610-arduino-driver/utils_8h.html Prints a caption followed by an integer value, with an option to add a newline. ```APIDOC ## printInteger() [2/3] ### Description Prints a caption followed by an integer value, formatted as "Caption: value". An optional newline character can be appended. ### Parameters * `_caption_` (*PGM_P*): A pointer to a program memory string for the caption. * `_value_` (*int*): The integer value to print. * `_newLine_` (*bool*): If `true`, a newline character is printed after the output. Defaults to `true`. ```