Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:proiecte:2022sric:babymonitor [2023/06/02 01:47]
andreea.ciocaianu [Screens]
iothings:proiecte:2022sric:babymonitor [2023/06/02 09:14] (current)
andreea.ciocaianu [Demo]
Line 6: Line 6:
  
 ==== Introduction ==== ==== Introduction ====
- 
 Created for parents everywhere, the smart monitor aims to offer an overview of the baby's sleeping environment,​ measuring the light and sound levels of the room and alerting the parents in case something is not right. Created for parents everywhere, the smart monitor aims to offer an overview of the baby's sleeping environment,​ measuring the light and sound levels of the room and alerting the parents in case something is not right.
 In order to do so, this project combines the functionalities offered by the ESP32 board with Blynk, a very handy app for IoT projects. ​ In order to do so, this project combines the functionalities offered by the ESP32 board with Blynk, a very handy app for IoT projects. ​
  
-==== Hardware ​Components ​====+---- 
 + 
 + 
 +==== Hardware ​Design ​====
  
 +== Bill of materials ==
   * ESP-WROOM-32 board   * ESP-WROOM-32 board
   * Analog sound sensor module   * Analog sound sensor module
Line 20: Line 23:
   * Jumper cables   * Jumper cables
  
-Create a hardware circuit system similar to the one below: 
  
 == Simulator view == == Simulator view ==
Line 30: Line 32:
 \\ \\
 {{ :​iothings:​proiecte:​2022sric:​real-circuit-babymonitor-2.jpg?​700 |}}  {{ :​iothings:​proiecte:​2022sric:​real-circuit-babymonitor-2.jpg?​700 |}} 
-==== Software Components ==== 
  
 +----
 +
 +==== Software Design====
 +== Components ==
   * Arduino IDE   * Arduino IDE
   * Blynk App* (Desktop and/or Mobile)   * Blynk App* (Desktop and/or Mobile)
Line 41: Line 46:
 Users can leverage Blynk to build and set up virtual buttons, sliders, gauges, and other widgets on their smartphone screen, allowing them to remotely control and monitor their connected devices. The software makes use of the WiFi'​s capacity to establish a secure link between the user's smartphone/​desktop and the hardware, enabling real-time data monitoring, device control, and automation. Users can leverage Blynk to build and set up virtual buttons, sliders, gauges, and other widgets on their smartphone screen, allowing them to remotely control and monitor their connected devices. The software makes use of the WiFi'​s capacity to establish a secure link between the user's smartphone/​desktop and the hardware, enabling real-time data monitoring, device control, and automation.
  
-  ​+ 
 +== Code Logic == 
 + 
 +There are 3 main functions present in this code: 
 +  * measureLight() - determines the brightness of the ambient light and sends all the alerts in case the thresholds are being breached 
 +<​code>​ 
 +void measureLight() { 
 +  long sum = measureSound();​ 
 +  int analogValue = analogRead(LIGHT_SENSOR_PIN);​ 
 +  if (analogValue < 40 && sum > 50 && isMusic == 0) { 
 +    Serial.println("​DAR AND CRY"​);​ 
 +    Blynk.logEvent("​sound_alert",​ String("​Baby crying in the dark"​));​ 
 +  } else if (analogValue > 40 && analogValue < 3200 && sum > 50 && isMusic == 0) { 
 +    Blynk.logEvent("​sound_alert",​ String("​Baby crying"​));​ 
 +  } else if (analogValue > 3200) { 
 +    Blynk.logEvent("​light_alert",​ String("​Too bright for baby to sleep"​));​ 
 +  } 
 +  Blynk.virtualWrite(virtualPin,​ analogValue);​ 
 +  delay(100);  
 +
 +</​code>​ 
 +  * measureSound() - measures the level of sound for around 300 miliseconds and computes an average of all the values to compare with the threshold 
 +<​code>​ 
 +long measureSound() { 
 +  long sum = 0; 
 +  for(int i = 0; i < 300; i++) {  
 +    sum += analogRead(SOUND_SENSOR_PIN);​ 
 +  } 
 +  sum = sum/300;  
 +  Blynk.virtualWrite(virtualPinSound,​ sum); 
 +  delay(100);  
 +  return sum; 
 +
 +</​code>​ 
 +  * music() - the function that makes the buzzer sing a melody similar to //Twinkle, twinkle, little star// (source in References section) and sends input to the RGB according to the musical note 
 +<​code>​ 
 +void music() { 
 +  isMusic = 1; 
 +  for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 
 +    if (thisNote % 3 == 0) { 
 +        color_red();​ 
 +        color_green();​ 
 +        color_blue();​ 
 +        color_purple();​ 
 +        color_light_green();​ 
 +        color_light_blue();​ 
 +        color_red();​ 
 +    } 
 +    else if (thisNote % 3 == 1) { 
 +        color_purple();​ 
 +        color_light_green();​ 
 +        color_light_blue();​ 
 +        color_red();​ 
 +        color_green();​ 
 +        color_blue();​ 
 +        color_green();​ 
 +    } 
 +    else if (thisNote % 3 == 2) { 
 +        color_light_green();​ 
 +        color_light_blue();​ 
 +        color_purple();​ 
 +        color_blue();​ 
 +        color_red();​ 
 +        color_green();​ 
 +        color_blue();​ 
 +    } 
 +    divider = melody[thisNote + 1]; 
 +    if (divider > 0) { 
 +      noteDuration = (wholenote) / divider; 
 +    } else if (divider < 0) { 
 +      noteDuration = (wholenote) / abs(divider);​ 
 +      noteDuration *= 1.5; 
 +    } 
 +    tone(BUZZER_PIN,​ melody[thisNote],​ noteDuration * 0.9); 
 +    delay(noteDuration);​ 
 +    noTone(BUZZER_PIN);​ 
 +    isMusic = 0; 
 +  } 
 +
 +</​code>​ \\ 
 + 
 +\\ 
 +There are also small utility functions to color the RGB and specific functions to interface with Blynk API. For more details check the //Download code// section below\\ 
 + 
 +\\ 
 + 
 +---- 
 +\\
 ==== Functionalities ==== ==== Functionalities ====
  
Line 56: Line 148:
 {{ :​iothings:​proiecte:​2022sric:​baby-monitor-flow.png?​700 |}} {{ :​iothings:​proiecte:​2022sric:​baby-monitor-flow.png?​700 |}}
 ==== Demo ==== ==== Demo ====
 +//
 +[[https://​www.veed.io/​view/​d1a2abe9-60b4-4b66-9e4c-2ef3066508c3?​panel=share]|Demo Video]]
 +//
 +
 +----
  
 ==== Screens ==== ==== Screens ====
Line 76: Line 173:
 //  // 
 // //
 +
 +----
 +
  
 ==== Download code==== ==== Download code====
 +//
 +{{:​iothings:​proiecte:​2022sric:​babymonitor.zip|}}
 +//
 +
 +----
 +
 ==== References ==== ==== References ====
  
iothings/proiecte/2022sric/babymonitor.1685659674.txt.gz · Last modified: 2023/06/02 01:47 by andreea.ciocaianu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0