Hi to all,
My name is Samuel and I am new to this forum.
Above all thank you for this forum because thanks to you , I learned a lot in programming arduino and I always find the answer in your posts , but this time I'm stuck and I need your help.
So I started programming and I'm trying to interface arduino sensor cloud that interacts with an already existing software.
The communication protocol of this software and free software is explained on the website designer , I give you the link.
rs232 protocol:
http://www.aagware.eu/aag_cloudwatchertechinfo.htm
the software is here:
http://www.aagware.eu/aag_cloudwatcher700.htm
Here is the code I made to react with the software
It aims at the moment to test the communication with the software and the data it returns is static ( no sensor connected ) .
The code works fine in test by the serial monitor, but I have no reaction of the software.
1 - I think it does not understand the character strings that my code returns it.
2 - The software sends serial data before the arduino serial port is ready . ( Seen with a serial port sniffer )
//DETECTEUR DE NUAGES AAG ARDUINO
void setup(){
Serial.begin(9600); // Démarrage du port série
String msg ="";
char lettre = '0';
establishContact(); // etablit le contact sur le port série en envoyant un handshaking block
}
void loop(){
String msg ="";
char hsb [16]= {'!', 0x11,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','0'}; // Déclaration Handshaking block
char lettre = '0';
if(Serial.available() > 0) // si donnée présente
{
while(Serial.available() > 0 ) // tant qu'il y a des données :
{
lettre = Serial.read(); // lire et stocker les données dans "lettre"
if (lettre == '!') // teste si '!' présent et arrete la lecture
{
msg += lettre;
delay(250);
break;
}
else // si pas de '!' continue la lecture
{
msg += lettre;
delay(250);
}
}
// ici on commence à tester toutes les commandes reçues
// et on retourne la chaine de caractère correspondante.
if (msg == "K!")
{
Serial.print("!K1234 "); // Serial number
Serial.print(hsb);
}
else if (msg == "A!")
{
Serial.print("!N Cloudwatcher"); // Internal name
Serial.print(hsb);
}
else if (msg == "B!")
{
Serial.print("!N 1.10"); // Firmware version
Serial.print(hsb);
}
else if (msg == "C!")
{
Serial.print("!6 0990"); // Zener voltage
Serial.print("!3 1000"); // Ambient Temperature
Serial.print("!4 1000"); // LDR voltage
Serial.print("!5 1000"); // Rain sensor Temperature
Serial.print(hsb);
}
else if (msg == "D!")
{
Serial.print("!E1 11111"); // 1st address byte errors
Serial.print("!E2 11111"); // Command byte errors
Serial.print("!E3 11111"); // 2nd address byte errors
Serial.print("!E4 11111"); // PEC byte errors
Serial.print(hsb);
}
else if (msg == "E!")
{
Serial.print("!R 1000"); // Rain frequency
Serial.print(hsb);
}
else if (msg == "F!")
{
Serial.print("!X "); // Switch Open
Serial.print(hsb);
//Serial.print("!Y "); // Switch Close
//Serial.print(hsb);
}
else if (msg == "G!")
{
Serial.print("!X "); // Switch Open
Serial.print(hsb);
}
else if (msg == "H!")
{
Serial.print("!Y "); // Switch Close
Serial.print(hsb);
}
else if (msg == "Ppppp!")
{
Serial.print("!Q 1000"); // PWM duty cycle
Serial.print(hsb);
}
else if (msg == "Q!")
{
Serial.print("!Q 1000"); // PWM duty cycle
Serial.print(hsb);
}
else if (msg == "S!")
{
Serial.print("!1 01200"); // IR sky temperature
Serial.print(hsb);
}
else if (msg == "T!")
{
Serial.print("!1 02000"); // IR sensor temperature
Serial.print(hsb);
}
else if (msg == "z!")
{
Serial.print(hsb);
}
else
{
Serial.print("Commande non reconnue !");
}
}
}
void establishContact() {
char hsb [16]= {'!', 0x11,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','0'}; // Déclaration Handshaking block
while (Serial.available() <= 0) {
Serial.print("!N 1.10"); // Firmware version
Serial.print(hsb); // send a handshaking block
delay(300);
}
}
Could you tell me where I 'm wrong in the code and give me some of your tps to help me run my interface with this software ?
thank you
Sam974