I'm trying to get power readings from my electricity meter. My plan is to use that information to hit the API of my EV charger (which I haven't bought yet) to regulate how much power it tries to pull and avoid drawing more than my allotted amperes and plunging my house into darkness.
Apparently the meters will broadcast their current load on something called a HAN, a system they call B-Route. This is aimed at HEMS devices which you're supposed to buy from a professional but I'm a Linux user so that's not how I do things, so I filled in the form for TEPCO to send me the username and password for the meter and they did.
I went on Amazon and bought a USB dongle that's supposed to act like a serial device:
https://www.amazon.co.jp/RS-WSUHA-Wi-SUN-USB%E3%82%A2%E3%83%80%E3%83%97%E3%82%BF%E3%83%BC-RS-WSUHA%E3%82%B7%E3%83%AA%E3%83%BC%E3%82%BA-RS-WSUHA-P/dp/B0BZCSJN4T/ref=cm_cr_arp_d_product_top?ie=UTF8I can plug this into my Ubuntu laptop and it shows up as /dev/ttyUSB0. I added my user to the dialout group and it apparently will let me connect it.
Looking at articles like this it looks like I should be able to pull readings off my smart meter.
https://qiita.com/kanon700/items/d4df13d45c2a9d16b8b0But it doesn't seem like I'm managing to read anything back from the USB dongle at all. (Before it even tries to connect to the smart meter.) I can send it a command and its little LED flashes, but I don't seem to be able to read anything back. For example it looks like I should be able send it the command SKVER and get the dongle's version back, but when I send it the command then try to read something back it just hangs. For example this will get as far as printing "try echo" then just sit there.
# とりあえずバージョンを取得してみる(やらなくてもおk)
print("try write")
ser.write(str.encode("SKVER\r\n"))
print("try echo")
print(ser.readline(), end="") # エコーバック
print("try version")
print(ser.readline(), end="") # バージョン
Any idea what I'm doing wrong?
(These are the scripts I've tried running)
https://github.com/edmundedgar/smart-meter-tinker