Go Down

Topic: NewSoftSerial Library: An AFSoftSerial update (Read 18 times) previous topic - next topic


If only the register naming of inline assembler didn't suck that much... I swear I've read more than one manual regarding this and it still is pretty obscure stuff.
• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!


I wonder if the best solution for NewSoftSerial would be to abandon this little tunedDelay() function and migrate over to DelayMicroseconds().




sorry for this "necro post", but I'm running out of ideas.
I'm trying to interface an arduino with a bluetooth chip, enabling the arduino to talk to my computer (over bluetooth).
I'd like to describe the situation / problem first, I'll give a short list of technical data at the bottom. All help is appreciated.

I have an arduino that I have hooked up to a bluetooth device, I'm trying to make the arduino talk to my computer (which also has a bluetooth device, obviously). I have tried the SoftwareSerial library, which doesn't appear to ever see anything it can read, a custom method that is based on a interrupt on the rx pin, trying to read the bits as the fly past (to my understanding this is also how NewSoftSerial reads data), aswell as the SoftwareSerial library.
I can send data to my laptop without problems, it arrives just as I send it (with a quirk of inverted linebreak/newline characters, but thats a quirk of the bluetooth chip I reckon), the receiving data on the arduino side is the problem.
SoftwareSerial denies the existance of ever seeing anything arrive.
The NewSoftSerial however, shows promise.
While calls to the available() method say that it has nothing to read, pure calls to the read() method give back invalid values (-1, no byte found). But this is the part where I see promise, because it will print a number of error bytes based on the number of characters I sent to the arduino (bluetooth device).
ie: I send a message "hello" to the arduino, the arduino would print 5 times a -1 value to the computer through its hardware serial.
This tells me that it is receiving something, but I have the feeling it doesn't know what it is it is trying to read..
Any insights and help regarding the matter would be most appreciated!

The sketch(es), in case it yields any information regarding the issue:
Code: [Select]
#include <NewSoftSerial.h>

NewSoftSerial mySerial = NewSoftSerial(2, 3, false);

void setup()
 pinMode(2, INPUT);  //softserial rx
 pinMode(3, OUTPUT); //softserial tx
 pinMode(4, OUTPUT); //reset pin of the bluetooth module
 pinMode(5, INPUT);  //"has a connection" pin of the bluetooth module
 pinMode(8, OUTPUT); //led
 digitalWrite(4, LOW);
 delay(1800); //reset the bluetooth module for at least 1500ms
 digitalWrite(4, HIGH);

void loop()
//most basic attempt, which prints a number of -1's equal to the number of characters sent to the arduino

//basic test attempt, doesn't print anything on Serial
 if(!digitalRead(5)) //this pin goes HIGH if the bluetooth device has a connection
   digitalWrite(8, HIGH); //light up a LED
   digitalWrite(8, LOW); //no connection, turn off the LED

Technical details:
- OS of computer: ubuntu 9.10
    - class2 transmitter
- Arduino IDE version 16
- NewSoftSerial version 10
- DFRduino duemilanove with atmega328 chip
- promi-ESD bluetooth chip
    - 9600bps baud (baud rate of 9600, I assume?)
    - 8 data bit, no parity, stop bit 1
    - H/W flow control
    - 3.3v input voltage (a custom chip drops the arduino voltages for safe interfacing)
    - pulls 73mA in its most power hungry state
    - class1 transmitter


Hi, running your example program:

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);

void setup()  
 Serial.println("Goodnight moon!");

 // set the data rate for the NewSoftSerial port
 mySerial.println("Hello, world?");

void loop()                     // run over and over again
 if (mySerial.available()) {
 if (Serial.available()) {

I've got two PUTTY windows open, the hardware uart is on COM3, and the SoftSerial is on COM4 on pins 2, 3.  Both windows print out their greetings fine.  When I type on COM3, I see the characters echoed on COM4 tty.  However, when I type on COM4, I don't see anything echoed back to COM3.  

COM3 is going to a tested FTDI, COM4 is a Modern Device P4, going to a Profile RS232->USB cable. Both have been tested for uploads with Arduino.


Hard to say for sure, but the appearance of that RS-232 worries me.  I suspect either a voltage level problem (RS-232 is different than TTL) or perhaps the RX wire is not correctly connected to pin 2.


Go Up