Here's information about your error:
Class for error 5xxyy: Network connection error. »yy« is interface-specific.
Device for error 5xx31: Interface WLAN2.
Error for error 513yy: WLAN connection to access point failed.
Solution for error 513yy: Check WLAN settings at console and access point (router).
All information is from Wiimmfi unless noted.