This shows you the differences between two versions of the page.
pm:prj2023:apredescu:poligraph [2023/05/03 01:31] cosmin.bordea [List of parts:] |
pm:prj2023:apredescu:poligraph [2023/05/28 21:40] (current) cosmin.bordea [Download] |
||
---|---|---|---|
Line 19: | Line 19: | ||
* **HW-827 (Pulse sensor)** - is a well-designed low-power plug-and-play heart-rate sensor for the Arduino. Anyone who wants to incorporate real-time heart-rate data into their work—students, artists, athletes, makers, and game and mobile developers—can benefit from it. | * **HW-827 (Pulse sensor)** - is a well-designed low-power plug-and-play heart-rate sensor for the Arduino. Anyone who wants to incorporate real-time heart-rate data into their work—students, artists, athletes, makers, and game and mobile developers—can benefit from it. | ||
+ | {{ :pm:prj2023:apredescu:hw-827.jpg?direct&300 |}} | ||
* **GY-21 (Temperature and humidity sensor)** - is a module that combines both a humidity sensor and a temperature sensor. Specifically, it uses the Sensirion SHT21 sensor to measure temperature and relative humidity. The GY-21 sensor module communicates with a microcontroller using the I2C protocol. | * **GY-21 (Temperature and humidity sensor)** - is a module that combines both a humidity sensor and a temperature sensor. Specifically, it uses the Sensirion SHT21 sensor to measure temperature and relative humidity. The GY-21 sensor module communicates with a microcontroller using the I2C protocol. | ||
Line 43: | Line 43: | ||
===== Software Design ===== | ===== Software Design ===== | ||
+ | I utilized Visual Studio Code (Platform.io) for software development and only SoftwareSerial.h and Wire.h as third-party libraries. | ||
+ | Several constants are defined in the code, including the GY21 sensor address, temperature and humidity reading commands, and the threshold value for detecting heartbeats. It also specifies variables for recording the number of heartbeats, the period between heartbeats, and the latest heartbeat value. The threshold value is constantly adjusting itself in response to background noise. | ||
- | <note tip> | + | The code has an ISR (Interrupt Service Routine) that is triggered by a timer (every 100 milliseconds). Based on the signal threshold, the ISR reads the analog signal from the heart monitor and updates the heartbeat count and time between heartbeats. It also sends the analog signal and the last bpm value to the Bluetooth interface. If the Hearth monitor does not detect anything and goes high on LO+ and LO-, the interrupt will be terminated. |
- | Descrierea codului aplicaţiei (firmware): | + | |
- | * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) | + | <code> |
- | * librării şi surse 3rd-party (e.g. Procyon AVRlib) | + | ISR(TIMER1_COMPA_vect) { |
- | * algoritmi şi structuri pe care plănuiţi să le implementaţi | + | if((PINB & (1 << PB3)) || (PINB & (1 << PB2))) return; |
- | * (etapa 3) surse şi funcţii implementate | + | |
- | </note> | + | int signal = readADC(0); |
+ | |||
+ | Threshold = (Threshold + signal) / 2; | ||
+ | if(signal > Threshold && count == 0) { | ||
+ | count = 1; | ||
+ | if(beat == 0) | ||
+ | time = micros() / 1000; | ||
+ | } else if (signal < Threshold && count == 1) { | ||
+ | beat++; | ||
+ | count = 0; | ||
+ | if(beat == 6) { | ||
+ | time = micros() / 1000 - time; | ||
+ | lastBeat = !lastBeat ? 60000 * 2 / time : (lastBeat + 60000 * 2 / time) / 2; | ||
+ | lastBeat = lastBeat <= 0 ? 0 : lastBeat; | ||
+ | time = 0; | ||
+ | count = 0; | ||
+ | beat = 0; | ||
+ | } | ||
+ | } | ||
+ | signal = readADC(1); | ||
+ | char result[60]; | ||
+ | sprintf(result,"BMP %lu ECG %d",lastBeat,signal); | ||
+ | BTserial.println(result); | ||
+ | |||
+ | } | ||
+ | </code> | ||
+ | |||
+ | The loop() function uses I2C communication to read the temperature and humidity data from the GY21 sensor and displays them on the serial monitor and the Bluetooth terminal using the "USART0_transmit_string()" and "BTserial.println()" functions. It also incorporates a 5-second delay to prevent data overwhelming the Bluetooth interface. | ||
+ | |||
+ | <code> | ||
+ | void loop() { | ||
+ | Wire.beginTransmission(GY21_ADDR); | ||
+ | Wire.write(CMD_TEMP_HOLD); | ||
+ | Wire.endTransmission(); | ||
+ | delay(100); | ||
+ | |||
+ | Wire.requestFrom(GY21_ADDR, 3); | ||
+ | |||
+ | if (Wire.available() == 3) { | ||
+ | uint16_t rawTemp = (Wire.read() << 8) | Wire.read(); | ||
+ | rawTemp &= ~0x0003; | ||
+ | tempC = -46.85 + 175.72 * (rawTemp / 65536.0); | ||
+ | } | ||
+ | Wire.beginTransmission(GY21_ADDR); | ||
+ | Wire.write(CMD_HUMIDITY_HOLD); | ||
+ | Wire.endTransmission(); | ||
+ | delay(100); | ||
+ | |||
+ | Wire.requestFrom(GY21_ADDR, 3); | ||
+ | if (Wire.available() == 3) { | ||
+ | uint16_t rawHumidity = (Wire.read() << 8) | Wire.read(); | ||
+ | rawHumidity &= ~0x0003; | ||
+ | humidity = -6.0 + 125.0 * (rawHumidity / 65536.0); | ||
+ | } | ||
+ | |||
+ | | ||
+ | USART0_transmit_string(String("Temperature: " + String(tempC) + " C Humidity: " + String(humidity) + "%").c_str()); | ||
+ | BTserial.println(String("Temperature: " + String(tempC) + " C Humidity: " + String(humidity) + "%")); | ||
+ | delay(5000); | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Following that, all of the data received in real time via bluetooth on a phone can be interpreted on a simple terminal or even more than that can be viewed in a demo application written in react native that can observe the received parameters and process the data if they exceed a certain threshold in order to identify certain reactions of the monitored person that can lead to the verification of the truth said. | ||
===== Obtained results ===== | ===== Obtained results ===== | ||
- | <note tip> | + | Following the completion of the project, I was able to create, first and foremost, a device that can be used to monitor people's heart rates by analyzing the electrical activity of the heart as well as the temperature and humidity at the skin level, with the monitoring being able to be local directly on the serial or from a distance using the bluetooth module by communicating with a phone, which can save the received data locally. Second, an algorithm that can operate on a smartphone and assess the data received, generating probabilities about the watched person's truthfulness. |
- | Care au fost rezultatele obţinute în urma realizării proiectului vostru. | + | |
- | </note> | + | |
===== Conclusion ===== | ===== Conclusion ===== | ||
+ | In conclusion, through the successful completion of this project, I have accomplished several significant outcomes. Firstly, I have developed a device capable of monitoring individuals' heart rates by analyzing the electrical activity of their hearts, as well as measuring the temperature and humidity at the skin level. This monitoring can be conducted either locally, directly through the serial connection, or remotely using the Bluetooth module by communicating with a smartphone. Additionally, the smartphone is equipped with an algorithm that can process the received data and generate probabilities regarding the truthfulness of the individual being monitored. These achievements pave the way for enhanced monitoring capabilities and contribute to the advancement of data-driven assessments in various contexts. | ||
===== Download ===== | ===== Download ===== | ||
- | <note warning> | + | *{{:pm:prj2023:apredescu:poligraph.7z|}} |
- | O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectului: surse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-). | + | |
- | + | ||
- | Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:pm:prj20??:c?** sau **:pm:prj20??:c?:nume_student** (dacă este cazul). **Exemplu:** Dumitru Alin, 331CC -> **:pm:prj2009:cc:dumitru_alin**. | + | |
- | </note> | + | |
===== Journal ===== | ===== Journal ===== | ||
- | <note tip> | + | *03.05.2023 - So far, I've assembled all of the components, processing the received signals and testing serial data transmission over Bluetooth and locally. |
- | Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului. | + | |
- | </note> | + | |
+ | {{ :pm:prj2023:apredescu:03.05.2023bca.jpg?direct&300 |}} | ||
+ | *20.05.2023 - I have successfully completed the project and have also developed an Android application that connects an Android device to the Bluetooth module and processes the received data, thus becoming a monitoring interface. | ||
+ | {{ :pm:prj2023:apredescu:poligraph2.png?direct&300 |}} | ||
+ | {{ :pm:prj2023:apredescu:poligraph1.png?direct&300 |}} | ||
+ | {{ :pm:prj2023:apredescu:poligraph3.png?direct&300 |}} | ||
+ | {{ :pm:prj2023:apredescu:poligraph4.png?direct&300 |}} | ||
===== Bibliography / References ===== | ===== Bibliography / References ===== | ||
<note> | <note> | ||
- | Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**. | + | * <html><a class="media mediafile mf_pdf" href="?do=export_pdf">PDF</a></html> |
</note> | </note> | ||
- | |||
- | <html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> | ||