Created
January 25, 2021 04:11
-
-
Save HectorTorres/9f4e31d871396db8f427ce15be97bffc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long randNumber; | |
String inputString; | |
void setup(){ | |
Serial.begin(115200); | |
randomSeed(analogRead(0)); | |
} | |
void loop(){ | |
delay(100); | |
SerialEvent(); | |
} | |
void SerialEvent(){ | |
while(Serial.available()){ | |
char inputChar = Serial.read(); | |
inputString += inputChar; | |
} | |
if(inputString.indexOf("getValue")>=0){ | |
randNumber = random(100); | |
String json_data = "{\"Sensor_id\":\"3E24R\",\"Value\":" + (String)randNumber + "}"; | |
Serial.println(json_data); | |
} | |
inputString = ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment