SoftwareSerial listen

Hello,

I am struggling with SerialSoftware class.
I use a kind of 1 wire communicaion (not directly 1-Wire protocol).
It is necessary to have a square wave on this wire - 250ms HIGH, 250ms LOW state.
When I use SerialSoftware class (on pins 10,11) I always get true as a result of available method and when I use read method I always get 0 (zero) - everything is in loop function.
I do not understand because I thought that it is necessary to have a stop bit in a proper time so that available method would return true.

Anybody has an idea ?

Thank you.

Milan

mkotaska:
Anybody has an idea ?

How about "Post your code" ?

I am struggling with SerialSoftware class.
I use a kind of 1 wire communicaion (not directly 1-Wire protocol).
It is necessary to have a square wave on this wire - 250ms HIGH, 250ms LOW state.

I don't understand the connection between those three sentences.

My code is below:


#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

int led = 13;
int nCurrentState=HIGH;
unsigned long nPreviousMillis=0;
const long nInterval = 200;

void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
pinMode(10, INPUT);
Serial.begin (9600);
mySerial.begin(9600);

}

void loop() {

mySerial.listen();
if(mySerial.available())
{
Serial.println (mySerial.read(),HEX);
}

unsigned long nCurrentMillis = millis();
if (nCurrentMillis - nPreviousMillis > nInterval)
{
nPreviousMillis = nCurrentMillis;
if (nCurrentState == LOW)
nCurrentState = HIGH;
else
nCurrentState = LOW;

}
digitalWrite(led, nCurrentState); // turn the LED off by making the voltage LOW
}

A couple of things:

  1. CODE TAGS missing.
  2. You haven't explained what your problem is; what are your expectations? What does your code do that your didn't expect? What doesn't it do that you did expect?

It is necessary to have a square wave on this wire - 250ms HIGH, 250ms LOW state.

How is that square wave supposed to communicate anything? If you looked at real serial communication, using an oscilloscope, you would see that data is not transferred using equal length high and low states.

Sorry for no CODE TAGS ...

Just I little explanation:

The square wave is sent to another circuit - a special iButton reader.
I set Serial to 9600 Baud so that I expected that there will be no reaction on the wave by Serial.

When iButton is read then sends a serial like signal to the same wire.

... I thought that one byte have a strict time to receice - considering the baud rate, of course

mkotaska:
I do not understand because I thought that it is necessary to have a stop bit in a proper time so that available method would return true.

Anybody has an idea ?

What type of serial device is connected and sending to the mySerial-RX pin-10 on your Arduino?
Circuit schematics?

You don't have pin-10 'floating' and 'connected to nothing', do you?