Please feel free to take a look at my custom driver for the IoTaWatt power monitoring device. It should help get you started with a possible design to achieve your goals. Good luck with your project!