Skip to content

Monitor your sensor data on Windows with Kotlin

Notifications You must be signed in to change notification settings

vasll/ktSensors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is very WIP, use at your own risk

How does the library work?

For now the library only works on Windows
A Powershell script is ran with sample code from the LibreHardwareMonitor library's README.md, that script then periodically sends sensor data to the Powershell console's output stream, the stream is then parsed into Kotlin objects like Hardware and Sensor and then they can be used into a Kotlin/Java program

Example usage

If you are on windows you have to use the LibreStream Object, then you need to add a streamUpdateListener to it which is toggled each time a sensor data stream from the LibreHardwareMonitor library ends, making it safe to use the given Sensor and Component Objects

fun main(){
    val libreStream = LibreStream(1.0)

    libreStream.addStreamUpdateListener {
        for(component in it){
            println("${component.name} ${component.type}")
            for(sensor in component.sensors){
                println("\t${sensor.type} | ${sensor.name} | ${sensor.value}")
            }
        }
    }

    libreStream.startStream()
}