#include <ArduinoJson.h>
int knockSensor0 = 7;
int val0 = 0;
void setup() {
pinMode(knockSensor0, INPUT);
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
val0 = digitalRead(knockSensor0);
// Create the JSON document
const size_t capacity = JSON_OBJECT_SIZE(48);
DynamicJsonDocument doc(capacity);
doc["val0"] = val0; // 100
//Send data to NodeMCU
serializeJson(doc, Serial);
}