...testing the code on a PIC18F45K20 and sensor works fine on PORTC or PORTD but can't seem to get any readings when configured using ports eithe port A, B or E
That's probably because many pins on ports A, B, and E are also analog pins so the digital input buffer is disabled by default.
See the ANSEL/ANSELH registers