I am new to IMP and Squirrel and trying to get some basic serial communications working. I am using UART57. I the IMP connected directly to a serial port on my pc. Imp pin 5(TX) goes to com port pin 2 (RX) and Imp pin 7 (RX) goes to com port pin 3 (TX) and Imp gnd tied to comport pin 5 (gnd). I am using Putty configured to 9600 8-N-1 and trying to send and receive simple strings but all I get is bogus chars. Here is my IMP squirrel code:
// electric imp device code
server.log("Device Started - ");
controller <- hardware.uart57;
local responseString = “>”;
local currentData = controller.read();
server.log( "Reading Response: ");
while (currentData != -1)
responseString = responseString + currentData.tochar();
currentData = controller.read();
server.log( "Response: " + responseString + “<”);
// Setup the communications with the controller
controller.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS, ControllerStatus);
local singleChar = 0;
server.log("Command: " + commandString);
foreach(singleChar, value in commandString)
server.log("letter:" + value);
// I have also tied this:
But I never see ACA in PuTTy on the PC and if I type ACA on Putty I get this on the IPM side.
2013-12-30 14:21:46 UTC-6: [Device] Reading Response: 2013-12-30 14:21:46 UTC-6: [Device] Response: >_< 2013-12-30 14:21:46 UTC-6: [Device] Response: >^_< 2013-12-30 14:21:46 UTC-6: [Device] Reading Response: 2013-12-30 14:21:46 UTC-6: [Device] Reading Response: 2013-12-30 14:21:46 UTC-6: [Device] Response: >y<
Please help with this, I’m sure, stupid mistake. As you can imagine I have tried a number of different input and output methods and cannot find the magic combo.
One problem may be the voltage differences between the imp and the PC RS232.
If you haven’t already damaged the imp, you should be using a MAX3232 device to handle the voltage conversions.
That breakout board has the necessary pump capacitors built on. The device will go between the imp’s pins 5,7 and the PC’s RX and TX. Ground is common. Board is powered by the imp 3.3v
Remember to swap RX and TX … imp out goes to PC in (RX) and likewise the other direction
Thanks I was thinking that it could be a voltage problem. But the rs232 spec said that the voltage range was 3 to 15 volts so I thought that I will see at least the info on the pc side. I will attempt to connect my two imps together to see if the imp was damaged. I have ordered the 3232 part. Thank again.
Yep, as mlseim says connecting an RS232 port (-12v/+12v signalling) to a imp’s logic level signalling (3v/0v) is not a good idea and may have damaged your imp.
The other thing is that mark is indicated by opposite voltages. RS232’s idle state (logic 1) is -12v. Logic level idle is 3v.
The max3232 inverts the logic as well as buffering the levels.
While you’re waiting for your max3232 breakout board, program your imp to blink the pins on and off (digital output configure: pins 1,2,5,7). Check each one with a meter or LED to make sure all 4 of those pins are functioning. You’ll be really frustrated if the max3232 chip doesn’t work because a pin has been fried. If all four of those pins look OK, you’re ready to try the max3232 when it arrives.
You probably only used pins 5 and 7, but check pins 1 and 2 (the other UART) while you’re at it.
Just a brief followup. I got the max3232 breakout board today and I am up and running taking to the PC. And it looks like hooking up directly to the PC did not smoke the IMP though it may have done some hidden damage but for now all is well. Thanks for you help.