UART troubles

I am trying to read from my Velleman PS3005D power supply. Between the Imp and the power supply, I got one of these

The code I am trying looks like this
`server.log(“Device Started”);

function powersupplyData()
local b =;
while(b != -1)
// As long as UART read value is not -1, we’re getting data
b =;

powersupply <- hardware.uart57;
powersupply.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS, powersupplyData);

function psuGetID()
server.log(“Device identification:”);
//imp.wakeup(5, pingPsu);
psuGetID();And according to that should return the identicifcation for the power supply, but instead I get2014-11-24 18:31:57 UTC+1 [Device] -1
2014-11-24 18:31:57 UTC+1 [Device] -1
2014-11-24 18:31:57 UTC+1 [Device] -1`

Are my code wrong, or could I use something wrong?

try logging your byte before you read a new one. I think one byte is discarded by your existing code

// As long as UART read value is not -1, we’re getting data
server.log(b); //first
b =;//next


Tried to use another function instead.

function powersupplyData() { local b = powersupply.readstring(500); server.log(b); }

This gives me stuff like
2014-11-24 19:52:44 UTC+1 [Device] binary: ff 2014-11-24 19:52:44 UTC+1 [Device] binary: 8e 2014-11-24 19:52:45 UTC+1 [Device] ~ 2014-11-24 19:52:45 UTC+1 [Device] binary: fe
Seems to never be the same.

Can you put a scope on the receive line and look at the data that the power supply is sending back? Values like 0xff and 0x7E often indicate a data-rate problem (although the documentation clearly states 9600 is correct).

No, I don’t have one.

Also trying to send to the power supply does nothing, so it could more than just a receiving problem.

Hi MikeyDK,
attached is sample code I am using to read Arduino text string one byte at a time using the Imp UART and then parsing the string in the Imp. This is parsing temperature and barometric pressure and then sending to agent code and onto Sparkfun Phant server [and then to ].

My arduino is setup to send out data at 9600 baud.

POST EDIT: I just realised that my comments and code are not going to help you at all, and I can’t find any way to delete my post. Sorry!

So, as mjkuwp94 says you are overwriting the byte every time you enter the handler. 3 bytes are being received, but each time you’re overwriting the received data and logging the next read data, which is the empty buffer (-1).

How is the buffer board wired up? Without seeing the bottom of the PCB too I can’t tell this for sure, but TX on the buffer board is likely the TX input of the MAX3232 which needs to be connected to TX on the imp (NOT swapped over as you would with another host).

What about the readstring function? Isnt that doing all the work with storing it?