I2C con i comandi "standard" che ho trovato qui.
https://sbs-forum.org/specs/sbdat110.pdf
Reset contatore cicli ricarica batteria DJI mini.
14 messaggi
• Pagina 2 di 2 • 1, 2
0
voti
...guarda qui. Mi è chiaro in senso generale ma nonsaprei come farlo in pratica.
To write to a smart battery, you'll need to use an I2C or SMBus interface and a compatible host device (like an Arduino or microcontroller) to send commands and data. The process involves setting up the I2C/SMBus connection, defining the target address, specifying the register address (or command), and then sending the data. You'll also need to account for the PEC (Packet Error Checking) byte if required by the specific protocol or device.
Here's a more detailed breakdown:
1. Establish the I2C/SMBus connection:
Hardware Setup: Connect the host device's SDA (Serial Data) and SCL (Serial Clock) lines to the smart battery's corresponding pins.
Software Setup: Configure the host device's I2C/SMBus library (like the Wire library on Arduino) to communicate at the appropriate speed and address.
2. Define the Target Address:
Smart Battery's Address: Smart batteries typically have an 7-bit address, and you'll need to find the correct address for your specific battery. The address might be 0x58 or 0x59 in some cases.
Host Device Configuration: Set the target address in the I2C/SMBus library configuration on the host device.
3. Specify the Register Address (or SMBus Command):
Registers: The smart battery has internal registers that store information like voltage, current, state of charge, etc. You'll need to find the specific register address you want to write to based on the smart battery's datasheet.
SMBus Commands: In SMBus, instead of register addresses, you might use SMBus commands to access the appropriate registers.
4. Send the Data:
Data Format: The data you send will depend on what you're trying to write (e.g., a new charge current limit, a new voltage target, etc.).
I2C/SMBus Write Function: Use the I2C/SMBus library's write function to send the data to the specified address and register.
PEC Byte (if required): Some SMBus protocols require a PEC byte for error checking. Ensure you calculate and include the PEC byte in your write operation if necessary.
Example (using a hypothetical scenario):
Let's say you want to set a new charge current limit for a smart battery with the address 0x58. You need to write the new current value to register address 0x02.
1. Setup:
Configure your I2C library on your Arduino (or other host device) for a 7-bit address of 0x58.
2. Write:
Use the I2C write function to send the following:
Target address: 0x58 (or 0x58 if you are using an 8-bit address and need to right-shift)
Register address: 0x02 (to write to the current register)
Data (new current value in the appropriate format)
PEC Byte (if required by your protocol)
Key Considerations:
Datasheet:
Always consult the smart battery's datasheet for specific instructions on register addresses, SMBus commands, and data formats.
To write to a smart battery, you'll need to use an I2C or SMBus interface and a compatible host device (like an Arduino or microcontroller) to send commands and data. The process involves setting up the I2C/SMBus connection, defining the target address, specifying the register address (or command), and then sending the data. You'll also need to account for the PEC (Packet Error Checking) byte if required by the specific protocol or device.
Here's a more detailed breakdown:
1. Establish the I2C/SMBus connection:
Hardware Setup: Connect the host device's SDA (Serial Data) and SCL (Serial Clock) lines to the smart battery's corresponding pins.
Software Setup: Configure the host device's I2C/SMBus library (like the Wire library on Arduino) to communicate at the appropriate speed and address.
2. Define the Target Address:
Smart Battery's Address: Smart batteries typically have an 7-bit address, and you'll need to find the correct address for your specific battery. The address might be 0x58 or 0x59 in some cases.
Host Device Configuration: Set the target address in the I2C/SMBus library configuration on the host device.
3. Specify the Register Address (or SMBus Command):
Registers: The smart battery has internal registers that store information like voltage, current, state of charge, etc. You'll need to find the specific register address you want to write to based on the smart battery's datasheet.
SMBus Commands: In SMBus, instead of register addresses, you might use SMBus commands to access the appropriate registers.
4. Send the Data:
Data Format: The data you send will depend on what you're trying to write (e.g., a new charge current limit, a new voltage target, etc.).
I2C/SMBus Write Function: Use the I2C/SMBus library's write function to send the data to the specified address and register.
PEC Byte (if required): Some SMBus protocols require a PEC byte for error checking. Ensure you calculate and include the PEC byte in your write operation if necessary.
Example (using a hypothetical scenario):
Let's say you want to set a new charge current limit for a smart battery with the address 0x58. You need to write the new current value to register address 0x02.
1. Setup:
Configure your I2C library on your Arduino (or other host device) for a 7-bit address of 0x58.
2. Write:
Use the I2C write function to send the following:
Target address: 0x58 (or 0x58 if you are using an 8-bit address and need to right-shift)
Register address: 0x02 (to write to the current register)
Data (new current value in the appropriate format)
PEC Byte (if required by your protocol)
Key Considerations:
Datasheet:
Always consult the smart battery's datasheet for specific instructions on register addresses, SMBus commands, and data formats.
0
voti
Beh, io direi una cosa del genere:
- Codice: Seleziona tutto
#include <Wire.h>
#define I2C_ADDRESS 0x58
#define REG_CURRENT 0x02
void setup() {
Wire.begin();
delay(100);
byte currentValue = 0x01;
Wire.beginTransmission(I2C_ADDRESS);
Wire.write(REG_CURRENT);
Wire.write(currentValue);
Wire.endTransmission();
}
void loop() {}
14 messaggi
• Pagina 2 di 2 • 1, 2
Torna a Costruzione, riparazione, riutilizzo
Chi c’è in linea
Visitano il forum: Nessuno e 11 ospiti

Elettrotecnica e non solo (admin)
Un gatto tra gli elettroni (IsidoroKZ)
Esperienza e simulazioni (g.schgor)
Moleskine di un idraulico (RenzoDF)
Il Blog di ElectroYou (webmaster)
Idee microcontrollate (TardoFreak)
PICcoli grandi PICMicro (Paolino)
Il blog elettrico di carloc (carloc)
DirtEYblooog (dirtydeeds)
Di tutto... un po' (jordan20)
AK47 (lillo)
Esperienze elettroniche (marco438)
Telecomunicazioni musicali (clavicordo)
Automazione ed Elettronica (gustavo)
Direttive per la sicurezza (ErnestoCappelletti)
EYnfo dall'Alaska (mir)
Apriamo il quadro! (attilio)
H7-25 (asdf)
Passione Elettrica (massimob)
Elettroni a spasso (guidob)
Bloguerra (guerra)


