strange behaviour using hardware serial

hi,

i am having trouble finishing a simple project to read a P1 port of a "smart energy meter" (DSMR v4) and publishing the result with a small html page on an arduino ethernet.

i am using posted information about existing projects and was able to create a working setup within mere hours. but then came the headaches!

when i power the project through USB from a computer (laptop) all is fine. as soon as i disconnect the USB cable (and power the arduino externally through the DC plug) the project hangs at reading the P1 port of the meter.

the hardware setup i used has been posted here: http://iproto.nl/uploads/Ian/p1_uitlezen_arduino_BS170.jpg. i have to invert the signal because the meter outputs the serial signal invertedly (why?), but that works just fine!

the code is based on code posted on this website: http://thinkpad.tweakblogs.net/blog/10673/uitlezen-van-de-slimme-meter-p1-poort-met-een-arduino-en-waarden-opslaan-in-mysql-database. i have slightly modified the code to fit my requirements

i have attached my code, a sample telegram from my smart meter and the html page hosted on the arduino ethernet (on the SD card).

in the code i set pin 5 high. this was intended to be the trigger for the P1 port, but during testing i have only used the wiring scheme as posted above, so just ignore that piece of code.

now here comes the really crazy part. although i have not been able to get the project working with the USB cable disconnected (the w5100 chipset connects to the network on layer 2 and 3 succesfully and i am able to ping the arduino though) it all works fine when i "ground" the ethernet connector on the arduino with my body (!)

i am looking for a stable way of powering my project without the need for a computer in the fusebox and i would like to know why the project suddenly works when i "ground" the ethernet connector on the board with my finger

any insight and/or help would be greatly appreciated!

kaspar

energiemeter.cpp (7.92 KB)

telegram.txt (887 Bytes)

index.htm.txt (1.9 KB)