This commit is contained in:
Sergio Pernas 2022-03-23 16:58:30 -03:00
parent c4cd7cd9b1
commit 01043e1739

View file

@ -1,9 +1,30 @@
int inData; int inData;
const char* valueSensor; const char* valueSensor;
const byte devID = 0x01; const byte devID = 0x01;
int errCode;
char sendData[3];
typedef struct {
char senType;
char senValue;
char senUnit;
} senFrame;
void newFrame (senFrame *pt, char sensor) {
pt-> senType = "hum";
pt-> senValue = "10.5";
pt-> senUnit = "%";
for ( byte i = 0; i < 4; i++) sendData[i] = ( ((byte *)pt)[i] );
Serial.println (sendData[sensor]);
}
@ -11,48 +32,45 @@ const byte devID = 0x01;
void setup() { void setup() {
Serial.begin(14400); Serial.begin(14400);
} }
void loop() {
void loop() {
if ( Serial.available() > 0) { if ( Serial.available() > 0) {
inData = Serial.read();
switch (inData) { switch (inData) {
case devID: case devID:
Serial.write("0x01"); newFrame();
Serial.write(" ");
Serial.write("hum");
Serial.write(" ");
Serial.write("78");
Serial.write(" ");
Serial.write("P");
Serial.write(" ");
Serial.write("99");
Serial.write(" ");
Serial.write("pre");
Serial.write(" ");
Serial.write("100");
Serial.write(" ");
Serial.write("Hpa");
Serial.write(" ");
Serial.write("98");
Serial.write(" ");
break; break;
} }
} }
} }
/*if ( Serial.available() > 0) {
inData = Serial.read();
switch (inData) {
case devID:
Serial.write("0x01");
Serial.write(" ");
Serial.write("hum");
Serial.write(" ");
Serial.write("78");
Serial.write(" ");
Serial.write("P");
Serial.write(" ");
Serial.write("99");
Serial.write(" ");
Serial.write("pre");
Serial.write(" ");
Serial.write("100");
Serial.write(" ");
Serial.write("Hpa");
Serial.write(" ");
Serial.write("98");
Serial.write(" ");
break;
}
} */