Final code for energy metering on nano130