Close

How it is not working

A project log for Alarmierungsuhr

This is a Clock Build which will switch to a Counter if a alert is received.

stefan-xpStefan-Xp 11/22/2016 at 21:475 Comments

I tested this Program:


/*
  Software serial test
  
 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX
char charbuffer[255];
int inCount;

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(115200);
}

void loop() // run over and over
{
   byte inputChar;
  int iCount;

  if (mySerial.available()>0)
  {
    inputChar = mySerial.read();
    charbuffer[inCount] = inputChar;
    inCount++;
  }  
 

  if (Serial.available())
    switch(Serial.read())

    {
    case '?':
       Serial.print("Send At...");
       mySerial.print("AT\n\r");
       break;  
    case '!':
      Serial.print(charbuffer); 
      while (inCount > 0)
      {
        charbuffer[inCount] = 0;
        inCount--;
      }
      break;
    }
}

Result:

--> ?
<-- Send At...
--> !
<-- AªCQÔ¤*IIOR†…
Too bad..

Discussions

Leonard wrote 11/22/2016 at 23:07 point

Hey hello, I was reading through this. You have two ints, one is called inCount, and one is not used and called iCount. I would start to give inCount an initial value of zero. Does this work better?

  Are you sure? yes | no

Stefan-Xp wrote 11/22/2016 at 23:58 point

Thank you. I just about to add the next log :)

It is not a great example of programming.. sorry.

  Are you sure? yes | no

davedarko wrote 11/22/2016 at 22:01 point

not sure the Softserial is capable of 115200 bps, taken from https://www.arduino.cc/en/Reference/SoftwareSerial :
  "On Arduino or Genuino 101 the current maximum RX speed is 57600bps"

You should use the softserial for debug and the hardware serial for talking to the ESP, although that might complicate things again.

  Are you sure? yes | no

davedarko wrote 11/22/2016 at 22:03 point

Ahh nevermind again. "It is possible to have multiple software serial ports with speeds up to 115200 bps"

  Are you sure? yes | no

Stefan-Xp wrote 11/22/2016 at 22:06 point

Thank you. It was a bit strange.. i have tried to talk to the Arduino with a FTDI RL232FT and it worked but not with the ESP.. I changed the Baudrate to 9600 and now it works much better.

  Are you sure? yes | no