Skip to content
Simple lib for UART on a variety of DROK Buck / Boost power supplies.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
.travis.yml
README.md
drok.go
drok_test.go
main.go

README.md

drok

GoDoc Build Status Go Report Card

A simple lib for interfacing with a variety of DROK Buck / Boost power supplies.

Thanks to Ben James for the supplementary writeup

Usage

Open a serial port @4800 baud and pass to the desired functions.

package examples

import (
    "fmt"

    drok "github.com/MrDoctorKovacic/drok"
    "github.com/tarm/serial"
)

func main() {
    c := &serial.Config{Name: "/dev/ttyUSB0", Baud: 4800}
    drokDevice, err := serial.OpenPort(c)
    if err != nil {
        panic("Failed to open serial port")
    }

    // Read output
    isOn, err := drok.IsOn(drokDevice)
    if err != nil {
        panic(err.Error())
    }
    if isOn {
        fmt.Println("DROK power supply is turned on")
    } else {
        fmt.Println("DROK power supply is turned off")
    }

    // Read output voltage
    voltage, err := drok.ReadVoltage(drokDevice)
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("Output voltage limit set to: %f\n", voltage)

    // Read output current
    current, err := drok.ReadCurrent(drokDevice)
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("Total output current is: %f\n", current)

    // Set output to true (enabling power output)
    err = drok.SetOutput(drokDevice, true)
    if err != nil {
        panic(err.Error())
    }

    // Set output voltage to 12.3v
    err = drok.SetVoltage(drokDevice, 12.3)
    if err != nil {
        panic(err.Error())
    }

    // Set output current limit to 0.95A
    err = drok.SetCurrent(drokDevice, 0.95)
    if err != nil {
        panic(err.Error())
    }

}
You can’t perform that action at this time.