# I am getting a 'utf-8' codec can't decode byte - unexpected end of data error

**URL:** <https://community.openenergymonitor.org/t/i-am-getting-a-utf-8-codec-cant-decode-byte-unexpected-end-of-data-error/14893>\
**Category:** emonHub\
**Created:** [26 July 2020 07:39 UTC](https://community.openenergymonitor.org/t/i-am-getting-a-utf-8-codec-cant-decode-byte-unexpected-end-of-data-error/14893 "2020-07-26T07:39:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Adeyinka](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/thomas_adeyinka/32/14796_2.png) [@Thomas\_Adeyinka](https://community.openenergymonitor.org/u/Thomas_Adeyinka)\
**Post date:** [26 July 2020 07:39 UTC](https://community.openenergymonitor.org/t/i-am-getting-a-utf-8-codec-cant-decode-byte-unexpected-end-of-data-error/14893/1 "2020-07-26T07:39:57Z")

</div>

Hi guys  
restarted my emonpi (after over 3 months uptime) and noticed that one of my interfacer was throwing an error.

For context I am using a vedirect to usb interface for emonhub (written for the victron Battery Monitor (BMV 700)

The exact error I am getting from emonhun.log is  
`2020-07-26 03:59:03,559 ERROR VEDirectBMV 'utf-8' codec can't decode byte 0xda in position 0: unexpected end of data`

My the emonhun interfacer and node configurations are

```
[[VEDirectBMV]]
    Type = EmonHubVEDirectInterfacer
    [[[init_settings]]]
        com_port = /dev/BMV0
        com_baud = 19200
        toextract = SOC,CE,TTG,V,I,Relay,Alarm,H1,H2,H3,H4,H5,H6,H7,H8,H9,H10,H11,H12,H17,H18,P,AR  
        poll_interval = 10 
    [[[runtimesettings]]]
        nodeoffset = 21 #make sure this matches with nodename below
        pubchannels = ToEmonCMS,
        subchannels = ToBMV,
        basetopic = emonhub/

[[21]]
    nodename = emonDC
# firmware =V1_6_emonTxV3_4_DiscreteSampling
# hardware = emonTx_(NodeID_DIP_Switch1:ON)
    [[[rx]]]
       names = SOC,CE,TTG,V,I,Relay,Alarm,H1,H2,H3,H4,H5,H6,H7,H8,H9,H10,H11,H12,H17,H18,P,AR
       datacode = 0
       scales = 0.1,1,1,0.001,1,1,1,0.001,1,0.001,1,1,0.001,0.001,0.001,1,1,1,0.001,0.001,1,1
       units =p,Ah,s,V,A,S,S 

```

when I run a screen to interface with the victron Bmv device directly, I get the following out put from the device (this is the output from the victron monitor directly:

PID 0x203  
V 25159  
I -9938  
P -250  
CE -23060  
SOC 959  
TTG 997  
Alarm OFF  
Relay ON  
AR 0  
BMV 700  
FW 0310  
Checksum z  
H1 -233715  
H2 -23531  
H3 -105550  
H4 74  
H5 0  
H6 -74944579  
H7 12799  
H8 32326  
H9 50658  
H10 930  
H11 437  
H12 1  
H17 186278  
H18 220913  
Checksum

can anyone help what could be the issue? everyone worked fine before the restart and I have been using this configuration since December last year. It is what powers this dashboard [Emoncms - dashboard view](http://energy.bobby.com.ng/dashboard/view?id=14)

I am using the EmonSD17Oct2019 image of emonpi on a rasberrypi 3B+

---

<div class="post-metadata">

**Author:** ![pb66](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/pb66/32/27_2.png) [@pb66](https://community.openenergymonitor.org/u/pb66)\
**Post date:** [26 July 2020 09:48 UTC](https://community.openenergymonitor.org/t/i-am-getting-a-utf-8-codec-cant-decode-byte-unexpected-end-of-data-error/14893/2 "2020-07-26T09:48:17Z")

</div>

While I’m afraid I cannot offer any useful help in resolving your issue, this does look related to some recent discussions around recent changes to OEM emonhub.

A forum search of “[codec can’t decode](https://community.openenergymonitor.org/search?q=codec%20can%27t%20decode)” currently turns up 2 other threads.

and there’s this on github

> <https://github.com/openenergymonitor/emonhub/issues/113>
>
> From the log:
> 
> 2020-06-23 03:21:27,792 DEBUG VEDirect Starting Serial re…ad
> 2020-06-23 03:21:27,812 ERROR VEDirect 'utf-8' codec can't decode byte 0xa5 in position 0: invalid start byte

> <https://github.com/openenergymonitor/emonhub/pull/121>
>
> The main problem was trying to decode the checksum byte (0-255) as utf-8
> (0-127… plus continuation bytes), so we have to store everything as bytes
> until we are ready to decode it.
> 
> I also took the opportunity to rewrite a few things in a simpler / more
> pythonic style. This might raise different exceptions when things go
> wrong, but it is shorter and it should be simpler to understand. I
> tried to add some helpful comments!
> 
> It's now 1am and I don't have hardware to test this. I would appreciate anyone looking over this with a beady eye!

---

<div class="post-metadata">

**Author:** ![Thomas\_Adeyinka](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/thomas_adeyinka/32/14796_2.png) [@Thomas\_Adeyinka](https://community.openenergymonitor.org/u/Thomas_Adeyinka)\
**Post date:** [26 July 2020 10:41 UTC](https://community.openenergymonitor.org/t/i-am-getting-a-utf-8-codec-cant-decode-byte-unexpected-end-of-data-error/14893/3 "2020-07-26T10:41:47Z")

</div>

Thanks for the pointers. I would follow the lead. I see that I fix has been released. I might not need to reinstall actually

---

<div class="post-metadata">

**Author:** ![Thomas\_Adeyinka](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/thomas_adeyinka/32/14796_2.png) [@Thomas\_Adeyinka](https://community.openenergymonitor.org/u/Thomas_Adeyinka)\
**Post date:** [28 July 2020 10:48 UTC](https://community.openenergymonitor.org/t/i-am-getting-a-utf-8-codec-cant-decode-byte-unexpected-end-of-data-error/14893/4 "2020-07-28T10:48:09Z")

</div>

Eventually what solved this for me was to reflash the emonpi image to oct172019 and disable update. This issue was most likely a regression caused by some recent updates. since the older release was stable for me and the emonpi is in a private network behind a firewall… the principle of if it is not broken don’t fix it was used and everything is working fine now.

---

<div class="post-metadata">

**Author:** ![Bill.Thomson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/bill.thomson/32/1834_2.png) [@Bill.Thomson](https://community.openenergymonitor.org/u/Bill.Thomson)\
**Post date:** [29 July 2020 00:10 UTC](https://community.openenergymonitor.org/t/i-am-getting-a-utf-8-codec-cant-decode-byte-unexpected-end-of-data-error/14893/5 "2020-07-29T00:10:42Z")

</div>

> [@Thomas\_Adeyinka](#):
>
> if it is not broken don’t fix it

![thumbsup](https://community.openenergymonitor.org/uploads/default/original/2X/3/3c587556c0cc11389317c03a60788d77ceebd307.gif)
