NRF24L01 Multiple Data Wireless Transmitter Receiver Suhu BPM SPO2 Sensor MAX30100 dan LM35
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengirimkan data secara wireless dengan menggunakan modul NRF24L01, data yang dikirim adalah data suhu, bpm, spo2 dari sensor LM35 dan max30100. jadi ada alat yang diposisikan sebagai transmitter dan ada alat yang sebagai receiver. untuk lebih jelasnya berikut adalah skema dan programnya.
a. Pin NRF24L01
b. Skema Transmitter
c. Skema Receiver
d. Program Arduino IDE Transmitter
#include <Wire.h>
#include <MAX30100_PulseOximeter.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
LiquidCrystal_I2C lcd(0x27,16,2); //library lcd
MAX30100* pulseOxymeter; //library
float sensorValue;
float tegangan;
int bpmku;
int counter;
float spo;
float bpm;
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
int cacah;
float b,s,t;
PulseOximeter pox;
uint32_t tsLastReport = 0;
String hrData = "";
void onBeatDetected()
{
// Serial.println("Beat!");
}
RF24 radio(9, 10); // CE, CSN
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void) {
lcd.begin();
lcd.clear();
lcd.noCursor();
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
pulseOxymeter = new MAX30100();
if (!pox.begin()) {
//Serial.println("FAILED");
for(;;);
} else {
//Serial.println("SUCCESS");
}
pox.setIRLedCurrent(MAX30100_LED_CURR_11MA);
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop(void){
sensorValue = analogRead(A0);
tegangan = sensorValue * (5.0 / 1023.0);
celsius = tegangan * 100.0 ;
t = celsius;
pox.update();
b = pox.getHeartRate();
s = pox.getSpO2();
radio.write(&t, sizeof(t));
radio.write(&b, sizeof(b));
radio.write(&s, sizeof(s));
}
e. Program Arduino IDE Receiver
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); //library lcd
int msg[1];
float b,s,t;
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void){
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
lcd.begin();
lcd.clear();
lcd.noCursor();
}
void loop(void){
if (radio.available()) {
radio.read(&t, sizeof(t));
lcd.setCursor(0,0);
lcd.print("T:");
lcd.print(t,1);
lcd.print(" ");
radio.read(&b, sizeof(b));
lcd.setCursor(0,1);
lcd.print("B/S:");
lcd.print(b,1);
radio.read(&s, sizeof(s));
lcd.print("/");
lcd.print(s,1);
lcd.print(" ");
//Serial.println(t);
//Serial.println(b);
//Serial.println(s);
}
}
#include <MAX30100_PulseOximeter.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
LiquidCrystal_I2C lcd(0x27,16,2); //library lcd
MAX30100* pulseOxymeter; //library
float sensorValue;
float tegangan;
int bpmku;
int counter;
float spo;
float bpm;
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
int cacah;
float b,s,t;
PulseOximeter pox;
uint32_t tsLastReport = 0;
String hrData = "";
void onBeatDetected()
{
// Serial.println("Beat!");
}
RF24 radio(9, 10); // CE, CSN
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void) {
lcd.begin();
lcd.clear();
lcd.noCursor();
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
pulseOxymeter = new MAX30100();
if (!pox.begin()) {
//Serial.println("FAILED");
for(;;);
} else {
//Serial.println("SUCCESS");
}
pox.setIRLedCurrent(MAX30100_LED_CURR_11MA);
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop(void){
sensorValue = analogRead(A0);
tegangan = sensorValue * (5.0 / 1023.0);
celsius = tegangan * 100.0 ;
t = celsius;
pox.update();
b = pox.getHeartRate();
s = pox.getSpO2();
radio.write(&t, sizeof(t));
radio.write(&b, sizeof(b));
radio.write(&s, sizeof(s));
}
e. Program Arduino IDE Receiver
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); //library lcd
int msg[1];
float b,s,t;
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void){
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
lcd.begin();
lcd.clear();
lcd.noCursor();
}
void loop(void){
if (radio.available()) {
radio.read(&t, sizeof(t));
lcd.setCursor(0,0);
lcd.print("T:");
lcd.print(t,1);
lcd.print(" ");
radio.read(&b, sizeof(b));
lcd.setCursor(0,1);
lcd.print("B/S:");
lcd.print(b,1);
radio.read(&s, sizeof(s));
lcd.print("/");
lcd.print(s,1);
lcd.print(" ");
//Serial.println(t);
//Serial.println(b);
//Serial.println(s);
}
}
f. VIDEO HASILNYA
No comments:
Post a Comment