Hello,
I am new to Arduino programming, and I am attempting to read a P1-telegram from a smart meter. It has been done before, but I like to know the code, and have the fun of writing it.
The message is:
error: ISO C++ forbids comparison between pointer and integer
My code (for readability I have removed a lot of lines that did not create the error, I have checked this smaller code and it still gives me the error):
#include <AltSoftSerial.h>
AltSoftSerial altSerial;
char c;
String inputString;
int interpret = 0;
void setup() {
Serial.begin(9600);
altSerial.begin(9600);
Serial.print("void setup run");
}
void loop() {
while (altSerial.available() > 0) {
c = altSerial.read();
c &= ~(1 << 7);
char inChar = (char)c;
Serial.print(inChar);
inputString += c;
if((char)c == "!"){
interpret = 1;
}
}
if (interpret == 1) {
// do something
interpret = 0;
}
}
When I check the code it highlights the line "if((char)c == "!"){"
I have also tried the following variations of that line:
if(c == "!"){
if(inChar == "!"){
I've searched Google and this forum, but all of the topics I've found had problems with a single "=" insead of a double "==".
The point of this check is that a P1-message is always closed by an "!", and I want to defer the second part of the code to when the message is completely loaded in. If I don't have a check on this, it will execute that piece of code every time it adds a character to inputString.
Could somebody point me in the right direction, because I've run out of ideas on this one.