Reading Serial Data from an Arduino Micro - Page 1
Forum section: electronics / projects

author: brims
author_rank: Contributor
timestamp: April 19, 2014, 03:12:24 am
content: Ok, I've been searching high and low to figure this out. I've only played with the Arduino a little bit leso I hope someone can tell me what I'm doing wrong.I've got an Arduino Micro that I've installed on my motorcycle to activate a few items, but it's not working properly and I need to get the serial output that I'm printing in my sketch to figure out what is wrong.The Micro is being powered off a 9VDC regulator which hooks into the Vin and ground pins on the Micro, the board powers up and works sporatically. If I hook my computer to the Micro via USB, the board powers from USB and it works 100%. So I unsoldered the polyfuse on the rear of the Micro after reading somewhere that this will allow USB communication without powering the board from USB. This was wrong, USB stopped working after I did that. So I soldered a new polyfuse in and USB works once again.I built a TTL to RS232 converter using a MAX232CPE+ chip, I've gotten sporatic data from it, anything I have received is gibberish. I used 1 uF capacitors for C1-C5 as the datasheet shows.http://datasheets.maximintegrated.com/en/ds/MAX220-MAX249.pdfon page 17. I go from TX on the Micro to pin 11 on the MAX232, MAX pin 14 to DB9 pin 2, RX on the Micro to MAX pin 12, MAX pin 13 to DB9 pin 3.Any help would be much appreciated.

author: Rerouter
author_rank: Super Contributor
timestamp: April 19, 2014, 03:23:18 am
content: you have left me a little bit confused here, you mention RS232 to TTL converter chip and USB, the 2 are not similar protocols,if your trying to talk to it over usb it should work fine assuming its still in the dev board, removing the polyfuse will allow you to run the micro without power from the usb, under the assumption that there is power fed in elsewhere (e.g. through Vin)Now please could we get some more detailed information on how we can help (schematics, what your trying to accomplish, etc)

author: LukeW
author_rank: Frequent Contributor
timestamp: April 19, 2014, 04:29:10 am
content: Here's the Arduino Micro schematic.http://arduino.cc/en/uploads/Main/arduino-micro-schematic.pdf(I hope you are actually using an actual Arduino and not a Wun Hung Lo knockoff from eBay, because then anything is possible with design changes.)Even if the board is powered independently of the USB power, the USB power still needs to be connected to the VBus pin on the ATmega32U4 so it can monitor when USB is connected. So the PPTC fuse connected to the USB power pin still needs to be in place for it to work.When external power is connected to VIn the USB power system is disconnected "automatically" from the +5V rail by the P-channel MOSFET. You don't need to do anything special.Just put the PPTC back on the board and plug it into your computer over USB to program it, even when external Vin is connected it's fine.

author: brims
author_rank: Contributor
timestamp: April 19, 2014, 05:53:30 am
content: With what little I could find, I believed the RX and TX pins were TTL, not compatible with RS232 that could be read with a PC serial port. If I'm wrong, I'd love to know if I can read anything I print with Serial.print() using a PC and the RX/TX pins, I belive they are pins 0 and 1, the Micro shows them as RX and TX.I am supplying power into the board through Vin, 9VDC to be exact, as the Arduino site states you can supply 5-15 VDC or something like that to Vin.I am using an official Arduino Micro board purchased from Mouser.I realize that the Micro automatically powers itself from USB when a USB cable is plugged in.My problem is that while powering the Micro from Vin off my motorcycle my sketch is not working the way it does on the bench. If I then plug my USB cable into my PC and Arduino, everything works fine so I can't see what's going wrong with my sketch. I'm trying to get the output of Serial.print() from my sketch on my PC while the board is running off of Vin power, not USB power. I read that pins 0 and 1 are the same serial bus as USB, so I was trying to connect my PC to pins 0 and 1 to read the data via the Arduino IDE or Cutecom without using USB.In the sketch I'm counting how many times a button input goes high, I am using a pull down resistor. Every time loop() starts I have a call Serial.print("presses: " + presses); which prints out "presses: <number of presses>" my guess is that the number of presses I'm getting is way to high even with messing with debounce delays. I need to see that output so I can figure out if I'm working in the right direction.

author: jancumps
author_rank: Unknown
timestamp: April 19, 2014, 06:25:10 am
content: Your program possibly works with USB connected because it's slower in that case. Serial.print() commands are slower when they are acually sending info over USB, then when the Arduino is unconnected.This may have influence on your program. It may have a de- bouncing effect or influence other timings that you rely on in your sketch.

author: djsb
author_rank: Super Contributor
timestamp: April 19, 2014, 07:48:38 am
content: Could you provide us with a top level block diagram of your sytem (drawn and scanned or done on software). Have you got a schematic of the voltage regulator you are using? Can you provide a picture of your arduino pinout. Just some of the things that will help us to help you.David.

author: David_AVD
author_rank: Super Contributor
timestamp: April 19, 2014, 08:03:10 am
content: Does the Arduino work when connected to the bike and with the bike motornotrunning?An accurate diagram of how you've implemented the 9V regulator and connections from bike to the Arduino would help.

author: electr_peter
author_rank: Unknown
timestamp: April 19, 2014, 01:58:25 pm
content: Do you connect ground pin to USB to TTL converter when you power Arduino from motocycle?Serial communication requires RX, TX and ground to be connected between communicating devices.

author: MickM
author_rank: Regular Contributor
timestamp: April 19, 2014, 06:34:13 pm
content: "My problem is that while powering the Micro from Vin off my motorcycle my sketch is not working the way it does on the bench."Your power source is probably very very noisy.Also are you grounding right to the battery?Mick M

author: brims
author_rank: Contributor
timestamp: April 26, 2014, 06:21:46 pm
content: Quote from: jancumps on April 19, 2014, 06:25:10 amThis turned out to be the exact issue. I added a 10 ms delay to the end of the loop and all of my issues went away. Thanks for everyone's help.

author: David_AVD
author_rank: Super Contributor
timestamp: April 26, 2014, 08:51:00 pm
content: Or it's masked the real underlying issue...