This shows you the differences between two versions of the page.
iothings:proiecte:2022:magneticauth [2023/06/02 20:04] carol.bontas [Hardware Description] |
iothings:proiecte:2022:magneticauth [2023/06/02 20:09] (current) carol.bontas |
||
---|---|---|---|
Line 64: | Line 64: | ||
- | ===== Software Description ===== | + | ===== Descriere software ===== |
Pentru stocarea, procesarea si afisarea datelor folosim InfluxDB. | Pentru stocarea, procesarea si afisarea datelor folosim InfluxDB. | ||
Line 93: | Line 93: | ||
Concret pentru a citi inregistrati de la senzorul Hall se apeleaza astfel <code> doUntilSerialInput(sampleHallSensor, NULL) </code> | Concret pentru a citi inregistrati de la senzorul Hall se apeleaza astfel <code> doUntilSerialInput(sampleHallSensor, NULL) </code> | ||
+ | 2. [[https://github.com/CSBonLaboratory/MagneticAuth/blob/main/magnetic_influx.cpp | magnetic_influx.cpp]] este o componenta auxiliara ce se ocupa exolicit cu interactiunea cu InfluxDB. | ||
+ | |||
+ | partea centrala este reprezentata de construirea query-ului de Flux care sa verifice daca id-ul dat apare sau nu in bucket-ul "Signatures". | ||
+ | |||
+ | Prezinta urmatorea interfata: | ||
+ | <code>int userExists(int id){ | ||
+ | String existQuery = String("from(bucket: \"") + String(BUCKET_USERS) + String("\")"); | ||
+ | existQuery += String("|> range(start: 2021-05-22T23:30:00Z)"); | ||
+ | existQuery += String("|> filter(fn: (r) => r._measurement == \"") + String(MEASUREMENT) + String("\" and r.id == \"") + String(id) + String("\")"); | ||
+ | existQuery += String("|> count()"); | ||
+ | |||
+ | Serial.println(existQuery); | ||
+ | int userFound = 0; | ||
+ | FluxQueryResult result = clients[USERS_INDEX].query(existQuery); | ||
+ | |||
+ | while(result.next()){ | ||
+ | if(result.getValueByName("_value").getLong() > 0){ | ||
+ | Serial.println("User was registered in the past"); | ||
+ | userFound = 1; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if(result.getError() != ""){ | ||
+ | Serial.print("Query result error: "); | ||
+ | Serial.println(result.getError()); | ||
+ | return -1; | ||
+ | } | ||
+ | |||
+ | Serial.print("User id"); | ||
+ | Serial.println(id); | ||
+ | Serial.println(" is available."); | ||
+ | result.close(); | ||
+ | return userFound; | ||
+ | |||
+ | } | ||
+ | </code> | ||
- | ===== InfluxDB ===== | ||
- | {{:iothings:proiecte:2022sric:screenshot_5.png?800|}} | ||
- | ===== Grafana ===== | ||
- | {{:iothings:proiecte:2022sric:screenshot_4.png?800|}} | ||
===== Bibliografie ===== | ===== Bibliografie ===== | ||
- | * https://randomnerdtutorials.com/esp32-influxdb/ | + | * https://www.wallstreetmojo.com/pearson-correlation-coefficient/ |
- | * https://randomnerdtutorials.com/esp32-web-server-with-bme280-mini-weather-station/ | + | * https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino |
- | * https://megma.ma/wp-content/uploads/2021/08/Wemos-ESP32-Lolin32-Board-BOOK-ENGLISH.pdf | + | |
- | * https://www.mischianti.org/wp-content/uploads/2020/11/ESP32-WeMos-LOLIN32-pinout-mischianti.png | + |