Help !!! Serial.println break lines !!!!!

Hi,
I´m really a newbie on arduino and stuck on this part .
Please help a friend here !! :slight_smile:

What he does is connect to a program called BitVoicer and receive the commands that i make him pass when say a word.

So if i say “Turn on TV”, in BitVoicer he send the command TV1:1

I now can receive over WiFi with my arduino and CC3000 module, but the word that i receive appears
in this way:

T
V
1
:
1

And i need receive the complete word TV1:1
Can a expert in this forum please help me !!!

Also after receive the correct word my arduino will see and make something like send a IR command.

Thanks alot for helping !

That´s the code:

/*

  • Simple WiFi Arduino, & the CC3000 chip
  • Part of the code is based on the work done by Adafruit on the CC3000 chip
  • Writtent by Marco Schwartz for Open Home Automation (I copy from that :slight_smile: )
    */

// Include required libraries
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include “utility/debug.h”
//#include “DHT.h”
#include<stdlib.h>

// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10

// WiFi network (change with your settings !)
#define WLAN_SSID “ImHere” // cannot be longer than 32 characters!
#define WLAN_PASS “45331204”
#define WLAN_SECURITY WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2

// Create CC3000

Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIV2);

// Local server IP, port, and repository (change with your settings !)
uint32_t ip = cc3000.IP2U32(192,168,77,10);
int port =4194;

void setup(void)
{

Serial.begin(9600);

// Initialise the CC3000 module
if (!cc3000.begin())
{
while(1);
}

// Connect to WiFi network
cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
Serial.println(“Connected to WiFi network!”);

// Check DHCP
Serial.println(F(“Request DHCP”));
while (!cc3000.checkDHCP())
{
delay(100);
}

/* Display the IP address DNS, Gateway, etc. */
while (! displayConnectionDetails()) {
delay(100);
}

}

void loop(void)
{
// Print data
Serial.println("");

// Send request
String request = "GET ";
send_request(request);

// Update every second
delay(20);
}

// Function to send a TCP request and get the result as a string
void send_request (String request) {

// Connect
Serial.println(“Starting connection to server…”);
Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);

// Send request
if (client.connected()) {
delay(500);
client.println(request);
Serial.println(“Connected”);
}
else {
Serial.println(F(“Connection failed”));
}

while (client.connected()) {
while (client.available()) {

// Read answer and do something i hope
char c = client.read();
//if (c == ‘\n’) { //if HTTP request has ended
//}

//output chars to serial port
Serial.println(c);

}
}

Serial.println(“Closing connection”);
client.close();

}

//
/*!
@brief Tries to read the IP address and other connection details
*/
/
/
bool displayConnectionDetails(void)
{
uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;

if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
{
Serial.println(F(“Unable to retrieve the IP Address!\r\n”));
return false;
}
else
{
Serial.print(F("\nIP Addr: “)); cc3000.printIPdotsRev(ipAddress);
Serial.print(F(”\nNetmask: “)); cc3000.printIPdotsRev(netmask);
Serial.print(F(”\nGateway: “)); cc3000.printIPdotsRev(gateway);
Serial.print(F(”\nDHCPsrv: “)); cc3000.printIPdotsRev(dhcpserv);
Serial.print(F(”\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
Serial.println();
return true;
}
}

Thanks alot

Did not look at your code but you can use Serial.print instead of Serial.println.

Please edit your post and use code tags. Before the code, type [code]. After the code, type [/code]

So it will look like

code here

So sorry.

/*
* Simple WiFi Arduino, & the CC3000 chip
* Part of the code is based on the work done by Adafruit on the CC3000 chip
* Writtent by Marco Schwartz for Open Home Automation (I copy from that  :)  )
*/

// Include required libraries
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
//#include "DHT.h"
#include<stdlib.h>

// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10

// WiFi network (change with your settings !)
#define WLAN_SSID "ImHere" // cannot be longer than 32 characters!
#define WLAN_PASS "45331204"
#define WLAN_SECURITY WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2


// Create CC3000

Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                        SPI_CLOCK_DIV2);
                                        
// Local server IP, port, and repository (change with your settings !)
uint32_t ip = cc3000.IP2U32(192,168,77,10);
int port =4194;

void setup(void)
{
  
 Serial.begin(9600);
   
 // Initialise the CC3000 module
 if (!cc3000.begin())
 {
   while(1);
 }

 // Connect to WiFi network
 cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
 Serial.println("Connected to WiFi network!");
   
 // Check DHCP
 Serial.println(F("Request DHCP"));
 while (!cc3000.checkDHCP())
 {
   delay(100);
 }
 
 /* Display the IP address DNS, Gateway, etc. */  
 while (! displayConnectionDetails()) {
   delay(100);
 }
 
}

void loop(void)
{
   // Print data
   Serial.println("");
   
   // Send request
   String request = "GET ";
   send_request(request);
   
   // Update every second
   delay(20);
}

// Function to send a TCP request and get the result as a string
void send_request (String request) {
    
   // Connect
   Serial.println("Starting connection to server...");
   Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);
  
   // Send request
   if (client.connected()) {
     delay(500);
     client.println(request);
     Serial.println("Connected");
   }
   else {
     Serial.println(F("Connection failed"));
   }

   while (client.connected()) {
     while (client.available()) {

     // Read answer and do something i hope
     char c = client.read();
     //if (c == '\n') { //if HTTP request has ended
     //} 

     //output chars to serial port
     Serial.println(c);
         
      }
   }
   
   Serial.println("Closing connection");
   client.close();
   
}

/**************************************************************************/
/*!
   @brief  Tries to read the IP address and other connection details
*/
/**************************************************************************/
bool displayConnectionDetails(void)
{
 uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
 
 if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
 {
   Serial.println(F("Unable to retrieve the IP Address!\r\n"));
   return false;
 }
 else
 {
   Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
   Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
   Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
   Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
   Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
   Serial.println();
   return true;
 }
}

I try will only serial.print without ln doest appear the word :frowning:

Thanks

Yep !
That´s perfect !

Now how read and make an action based on the word?
Like IRsend ?

Thanks alot !!

Now code is like that:

/*
* Simple WiFi weather station with Arduino, the DHT22 sensor & the CC3000 chip
* Part of the code is based on the work done by Adafruit on the CC3000 chip & the DHT11 sensor
* Writtent by Marco Schwartz for Open Home Automation
*/

// Include required libraries
//#include <WString.h>
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
//#include "DHT.h"
#include<stdlib.h>

// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10

// WiFi network (change with your settings !)
#define WLAN_SSID "RioVirtual" // cannot be longer than 32 characters!
#define WLAN_PASS "22052008"
#define WLAN_SECURITY WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2

// DHT11 sensor pins
//#define DHTPIN 7
//#define DHTTYPE DHT22

// Create CC3000 & DHT instances
//DHT dht(DHTPIN, DHTTYPE);
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIV2);
                                         
// Local server IP, port, and repository (change with your settings !)
uint32_t ip = cc3000.IP2U32(192,168,77,10);
int port =4194;

void setup(void)
{
 
  // Initialize DHT sensor
 // dht.begin();
  
  Serial.begin(9600);
    
  // Initialise the CC3000 module
  if (!cc3000.begin())
  {
    while(1);
  }

  // Connect to WiFi network
  cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
  Serial.println("Connected to WiFi network!");
    
  // Check DHCP
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100);
  }
  
  /* Display the IP address DNS, Gateway, etc. */  
  while (! displayConnectionDetails()) {
    delay(100);
  }
  
}

void loop(void)
{
    // Print data
    Serial.println("");
    
    // Send request
    String request = "GET ";
    send_request(request);
    
    // Update every second
    delay(20);
}

// Function to send a TCP request and get the result as a string
void send_request (String request) {
     
    // Connect
    Serial.println("Starting connection to server...");
    Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);
   
    // Send request
    if (client.connected()) {
      delay(500);
      client.println(request);
      Serial.println("Connected");
    }
    else {
      Serial.println(F("Connection failed"));
    }

    while (client.connected()) {
      while (client.available()) {

      // Read answer
      char c = client.read();
      //if (c == '\n') { //if HTTP request has ended
      //} 

      //output chars to serial port
      Serial.print(c);
            
       }
    }
    Serial.println("");
    Serial.println("\n");
    Serial.println("Closing connection");
    client.close();
    
}

/**************************************************************************/
/*!
    @brief  Tries to read the IP address and other connection details
*/
/**************************************************************************/
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}

Thanks alot, simple answer solve alot

Well first part ok.
Now i must read the word that come and make an action based on it.

Any tip? I looking alot, trying alot none resolv.

The word now appear in console correct but how make an action ???

Really thanks

Put each byte received in an array and increment the array index. When you get a newline, terminate the char array with a zero then you can compare the string in the array with a fixed string using the strncmp() function.

ok.
I'm new on this, can you help?

Thanks alot

Welcome,

Read:

http://www.gammon.com.au/serial