arduino 0x01

This commit is contained in:
Sergio Pernas 2022-03-25 17:09:45 -03:00
parent 2c3df9d549
commit f45f27b254

View file

@ -1,30 +1,16 @@
int inData;
const char* valueSensor;
char sensorValue = "10";
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]);
}
char *senData[] {
"T", // Tipo de sensor
"s", // Lectura del sensor
"C"
};
@ -34,12 +20,21 @@ void setup() {
}
void loop() {
if ( Serial.available() > 0) {
inData = Serial.read();
switch (inData) {
case devID:
newFrame();
Serial.write(devID);
for (int i = 0; i <= 3; i++) {
Serial.write(senData[i]);
}
Serial.write("99");
break;
}