ICP_2 - akkipant/IoT-Fall-2019 GitHub Wiki
Introduction :
The second session was about the implementation of heartbeat monitoring over the internet using Arduino and ThinkSpeak. In this session, the importance of heartbeat monitoring was discussed and how interfacing it with the internet helps in accessing the data remotely. We had to implement hardware consisting of Pulse Sensor, interface it with Arduino and upload the data on the IoT cloud: ThinkSpeak. This ICP had 4 parts. 3 of which were for full assessment and 4th for bonus points.
Objectives :
Part1: Assemble hardware on a breadboard for heartbeat monitoring using Pulse Sensor, LCD, and Arduino. Part2: Connect the WiFi module (ESP8266) to Arduino. Create an account on ThinkSpeak cloud and write the heartbeat data on the cloud. Vary the delay and plot the graph from the data on ThinkSpeak. Part3: Connect Red LED to indicate if the heartbeat goes above threshold and Green LED to indicate if heartbeat goes below the threshold. Part4 (Bonus): When there is no finger on the sensor, the reading must show zero.
Approaches/Methods :
Our approach was to first interface LCD with the Arduino. Check if the interface is correct. Then, to connect the Pulse Sensor and display the reading on the LCD. For executing this we had to write a simple code just to interface LCD and the sensor. Next, we had planned to interface WiFi module and connect the module to the mobile Hotspot by configuring the SSID and password in the code. Then, do the code modifications to implement the threshold and indications through LEDs.
Workflow:
- First, we interfaced the LCD module having I2C adapter (PCF8574) with the Arduino using SCL, SDA, VCC=5V, and GND.
- Then we executed the "Hello World" program to check if LCD is working.
- The Pulse Sensor was interfaced with the Arduino at Pin A0. The red wire connected to 5V, Black to GND and blue to the A0 Analog Pin.
- Using AnalogRead function we displayed the heartbeat data onto the LCD.
- Next step was to interface the WiFi module using Software Serial. We checked for the pin diagram and connected the TX of the module to the GPIO pin 9 (Customized as RX) and RX of the module through the voltage divider to the 10 (Customized as TX).
- We then created the ThinkSpeak account, and on Channels tab we created a new Channel. Named the field "Heart_Beat" and saved the channel.
- We then had to create the hotspot for the module using a mobile phone. We were not seeing any devices connected on the hotspot and had to debug the connections. There was some issue with the code.
- We modified code given by professor by removing the code related to switches, the setting threshold for rest logic (reset if the value goes below 50 and above 150), changing the threshold levels for red and green LEDs and to include the SSID and password of our hotspot.
- We verified the functionality by programming the Arduino and were able to upload the data on ThinkSpeak and plot graph.
Pin Diagram :
Fig. 1. ESP8266
Fig. 2. Arduino Uno
LCD Connection Diagram :
Circuit Diagram :
Video :
Parameters :
Resistors used for voltage divider=220ohm.
Heartbeat average value displayed: 84
Reset threshold: below 50 and above 150
Upper threshold to glow Red LED:110
Lower threshold to glow Green LED:90
Evaluation and Discussion:
- We were initially trying to get the heartbeat data onto the LCD but had not installed the library for liquid Crystal. We then downloaded the "LiquidCrystal_PCF8574.h" library and were able to display data to LCD using "lcd.print" function.
- At a later stage, we had connected the TX/RX of the WiFi module to the TX/RX of the Arduino but, the code had used Software Serial i.e. customized GPIO pins 9 and 10 for the TX/RX functions. Hence, we were unable to connect the WiFi module to the Arduino. We then corrected the connections, but still were not able to connect the WiFi module on the phone Hotspot.
- We debugged the code and modified the latest code given professor to meet our requirements.
Conclusion :
Through this practical session, we learned the interface between LCD and Arduino, to read analog input and send data to LCD through I2C. We also learned the interfacing of the WiFi module and how to load data on ThinkSpeak.