summaryrefslogtreecommitdiff
path: root/julia-arduino-master/energy meter/readVoltage.jl
blob: f609ddd6ed1dd84dc239cd9cbba30bf9804bdba4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using SerialPorts
using ArduinoTools

function readVoltage()
  str = string(Char(1))*string(Char(3))*string(Char(15))*string(Char(86))*string(Char(0))*string(Char(2))*string(Char(39))*string(Char(15))
  ser = connectBoard(9600)
  write(ser,str)
  sleep(0.1)
  s = readavailable(ser)
  close(ser)
  s = s[end-7:end]
  voltage = hex2num(s)
  println("The Voltage in V is:")
  println(voltage)
end

readVoltage()