I want the arduino to turn a switch on or off depending on the state of charge of a laptop battery. Any ideas about how to export this information to the arduino while the laptop is functioning to control the switch?
Write an app on the laptop to monitor the state of the battery - send a serial message to the Arduino.
many questions pop up.
- does the laptop battery has a hardware indicator? e.g. a LED on the battery
- does the laptop battery has some software interface?
- do you run windows or linux?
if (1) then you could check if all leds are on, or the color or intensity.
if (2) then you could write a application on the laptop that reads the battery status e.g. once per minute and send it to the Arduino.
If your OS is windows you could have a look at win32 battery class - Win32_Battery class - Win32 apps | Microsoft Learn -
On my windows laptop I can do powershell gwmi -Class batterystatus -Namespace root\wmi
If your OS is linux check acpi -b See also - Check battery life from command line -
should get you started, please let us know how your project continues.
There's a few problems here. One of which is that the connector for the laptop battery is generally deeply embedded within the laptop when in use. Another is that the battery itself is almost definitely not a dumb battery.
If you were to smash your laptop battery open you'll find there's a small circuit board in there that controls the battery charging circuits and output. So you're not necessarily going to get a clean reading of the state of your batteries. (there'll be a pack of rechargeables inside that plastic case)