After hours of debugging, it appears that a longer sleep is required inside the connect() method so the Arduino has time to process its setup() function.  Also added a failsafe for refreshAnalogPins and refreshDigitalPins.  If the Arduino doesnt respond, the 'read pins' command will be sent again for a maximum of 4 times