Close

Well now it's 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/23/2016 at 00:081 Comment

Wow it is some kind of addictive ;)

This is the latest Code:

/*
  Software serial multple 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(19200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  
  Serial.print("Ready for commands \r\n");
}

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

   while (mySerial.available()>0)
   {
      inputChar = mySerial.read();
      charbuffer[inCount] = inputChar;    
      
      // If there is a new line, there shall also be a new row
      if(inputChar == '\n')
      {
        inCount++;
        charbuffer[inCount] = '\r';
      }
      
      inCount++;
      
      // Print if buffer is full
      if(inCount > 250)
      {
        Serial.print(charbuffer);
        inCount = 0;
        
        while (inCount > 0)
        {
          inCount--;
          charbuffer[inCount] = 0;
        }
      }
   }  
  
  if(inCount > 0)
  {
    Serial.print(charbuffer);
    inCount = 0;
    
    while (inCount > 0)
    {
      inCount--;
      charbuffer[inCount] = 0;
    }
  }
   
  if (Serial.available())
    switch(Serial.read())

    {
    case '?':
       Serial.print("Send At...");
       mySerial.print("AT+CIPSTATUS\r\n");
       break;
       
    case '1':
       Serial.print("Send At...");
       mySerial.print("AT+CIPSTART=\"TCP\",\"retro.hackaday.com\",80\r\n");
       break;  
       
    case '2':
       Serial.print("Send At...");
       mySerial.print("AT+CIPSENDBUF=48\r\n");
       break;   
   
    case '3':
       Serial.print("Send At...");
       mySerial.print("GET / HTTP/1.1\r\nHost: retro.hackaday.com:80\r\n\r\n");
       break;  
              
    case '5':
       Serial.print("Send At...");
       mySerial.print("+IPD,100\r\n");
       break;  
}

Still not that pretty but it works more or less if you send 1,2,3,5 :-D

It seems there are still some characters missing... but it is already to late for "today".

BTW: After i increased the Baudrate of mySerial, i got less missing characters.

I think somebody who is more experienced will find this code a piece of crap. Sorry for this.

Discussions

davedarko wrote 11/23/2016 at 07:55 point

don't apologise for code that works :) I never did the actual AT command stuff, only arduino and lua. 

  Are you sure? yes | no