Imp -> Arduino through serial port works fine, yet other way around doesn't?

Hi guys, I’ve searched high and low for the answer and tried several things but I just can’t figure it out. So here’s my problem: I want to output a certain string from the Arduino to the Electric Imp. I can receive Electric Imp’s strings using Arduino, but not the other way around. My Arduino is of the type Mega 2560, and I use a Sparkfun Imp Shield for the connection between Imp and Arduino. Also, I’m using the Serial1 port (pins 18 and 19) to communicate with the Imp shield (as pins 8 and 9 cannot be used for softwareserial). I don’t understand what is wrong, could you guys enlighten me on this? I have provided the code here:

Arduino Code: http://pastebin.com/rTEqQLr1
Imp Code: http://pastebin.com/k9LmpnCm

Help would be much appreciated, thank you all

P.S. Assume that I want “Hello World” to show up in server log.

So you should just do imp.wakeup(0.001, pollUart);

The bindenv bit is when the function is part of a class. I’m not sure if this is your problem, but it could be. Really you ought to be registering pollUart as the data ready callback (see API docs) as then you’re not constantly polling - the system will call you when bytes are ready to be read.

I have tried using the following code, to no avail:

function initUart() { hardware.configure(UART_57); // Using UART on pins 5 and 7 hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS, pollUart); //Setting up a channel between Arduino and EI }

While pollUart() does the following:
`function pollUart()
{
local s = “”;
local byte = hardware.uart57.read();

while(byte != -1) {
s+=byte.tochar();
byte = hardware.uart57.read();
server.log(“reading byte”);
}

if(s.len())server.show(s);
if(s.len())server.log(s);
}`

Still, I cannot get anything to show up in server log concerning the data received from the Arduino. I have edited my code as follows:

http://pastebin.com/KWRfd6Jd (Electric Imp)
http://pastebin.com/t4BTHcYQ (Arduino)

Basically, the Arduino should print “Hello World” to both Serial and Serial1. I can see the text perfectly in Serial monitor, yet the Electric Imp’s server log shows nothing D:

Try moving your function definition above the configure command.

just a thought.

Do you have a scope or other tool to see if the signal is properly reaching the imp?

I don’t have an oscilloscope if that’s what you mean. Not sure if I can do the same with a multimeter?? :s I’m not too good in this advanced stuff. Will definately try your suggestion later tonight, maybe it’ll work. Thanks!

Yes, move

hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS, pollUart);

after the polluart() function in the squirrel code.
hardware.configure(UART_57) is depreciated, just use hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS, pollUart);