Translate
Monitor Suhu Sensor DS18b20 Interface 7segment
NRF24L01 Multiple Data Wireless Transmitter Receiver Suhu BPM SPO2 Sensor MAX30100 dan LM35
#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);
}
}
Monitor Suhu Tubuh, BPM, TENSIMETER ONLINE BLYNK + Fitur Suara DF PLAYER Mini
#include <LiquidCrystal_I2C.h>
#include <Adafruit_MLX90614.h>
#include <MAX30100_PulseOximeter.h>
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
#define REPORTING_PERIOD_MS 5000
#include "MAX30100.h" //library sensor
SoftwareSerial mySerial(10, 11); // RX, TX
LiquidCrystal_I2C lcd(0x27,16,2); //library lcd
MAX30100* pulseOxymeter; //library
int cacah; //membuat variabel
int spo;
float bpm;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
int btreset = 12;
float TargetC;
int motor = 8;
int solenoid = 9;
int dataadc;
int tombolx;
int hitung;
float vol;
float mmhg;
float mmhgx;
int sistole;
int diastole;
int sistolex;
int diastolex;
int mark = 0;
int bttensi = 3;
int suhunya;
int bpmku;
PulseOximeter pox;
uint32_t tsLastReport = 0;
String hrData = "";
void onBeatDetected()
{
// Serial.println("Beat!");
}
void setup() {
Serial.begin (9600);
mySerial.begin (9600);
mp3_set_serial (mySerial); //set softwareSerial for DFPlayer-mini mp3 module
delay(1); //wait 1ms for mp3 module to set volume
mp3_set_volume (30); //volume 0-30
Wire.begin();
mlx.begin();
// Serial.begin(9600);
lcd.begin();
lcd.clear();
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
pinMode(motor,OUTPUT);
pinMode(solenoid,OUTPUT);
pinMode(bttensi,INPUT_PULLUP);
digitalWrite(motor,LOW);
digitalWrite(solenoid,LOW);
//Serial.print("Initializing pulse oximeter..");
if (!pox.begin()) {
//Serial.println("FAILED");
for(;;);
} else {
//Serial.println("SUCCESS");
}
pox.setIRLedCurrent(MAX30100_LED_CURR_11MA);
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop(){
pox.update();
bpm = pox.getHeartRate();
spo = pox.getSpO2();
//bpmku = bpm;
if(bpm > 0){
bpmku = bpm;
}
lcd.setCursor(0,1);
lcd.print("Bpm: ");
lcd.print(bpmku);
lcd.print(" ");
mlx.begin();
TargetC = mlx.readObjectTempC();
suhunya = TargetC;
int bttensix = digitalRead(bttensi);
if(bttensix == 0){
lcd.clear();
delay(3000);
mulai();
}
lcd.setCursor(0,0);
lcd.print("S=");
lcd.print(suhunya);
lcd.print("/");
lcd.print(sistole);
lcd.print("/");
lcd.print(diastole);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Bpm: ");
lcd.print(bpmku);
lcd.print(" ");
if((suhunya > 0)&&(suhunya < 38)&&(bpmku > 60)&&(bpmku < 100)&&(sistole > 0)&&(diastole > 0)){
delay(3000);
kirimblynk();
lcd.clear();
delay(1000);
lcd.print("play music 1");
mp3_play (1); //play music file 0001.mp3
delay(20000);
mp3_stop ();
lcd.clear();
delay(1000);
bpmku = 0;
if((suhunya >= 38)&&(bpmku > 60)&&(bpmku < 100)&&(sistole > 0)&&(diastole > 0)){
delay(3000);
kirimblynk();
lcd.clear();
delay(1000);
lcd.print("play music 2");
mp3_play (2); //play music file 0002.mp3
delay(20000);
mp3_stop ();
lcd.clear();
delay(1000);
bpmku = 0;
delay(1);
cacah++;
if(cacah >= 10){
cacah = 0;
//internet blynk
Serial.print("*");
Serial.print(suhunya);
Serial.print(",");
Serial.print(bpmku);
Serial.print(",");
Serial.print(sistole);
Serial.print(",");
Serial.print(diastole);
Serial.println("#");
/*
//bluetooth
Serial.print("Suhu= ");
Serial.println(suhunya);
Serial.print("Bpm= ");
Serial.println(bpm);
Serial.print("Sistole= ");
Serial.println(sistole);
Serial.print("Diastole= ");
Serial.println(diastole);
*/
}
}
void mulai(){
void kirimblynk(){
//internet blynk
Serial.print("*");
Serial.print(suhunya);
Serial.print(",");
Serial.print(bpmku);
Serial.print(",");
Serial.print(sistole);
Serial.print(",");
Serial.print(diastole);
Serial.println("#");
}
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
int temp;
int x = 5;
int y;
int value1;
int value2;
int value3;
int value4;
int suhuku;
int bpmku;
int sistole;
int diastole;
float datain1;
float datain2;
float datain3;
float datain4;
String dataIn;
String dt[10];
int i;
boolean parsing=false;
char auth[] = "hgjhg768ghbjhhgd424gfhghgh98iuhgjhhvq";
char ssid[] = "Hotspot Wifiku";
char pass[] = "123456789";
SimpleTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
Blynk.virtualWrite(V4, suhuku);
Blynk.virtualWrite(V5, bpmku);
Blynk.virtualWrite(V6, sistole);
Blynk.virtualWrite(V7, diastole);
delay(1000);
}
void setup()
{
dataIn="";
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, sendSensor);
}
void loop()
{
while(Serial.available()>0) {
// dataIn="";
char inChar = (char)Serial.read();
dataIn += inChar;
if (inChar == '\n') {
parsing = true;
}
}
if(parsing){
parsingData();
Blynk.run();
timer.run();
}
}
void parsingData(){
int j=0;
//kirim data yang telah diterima sebelumnya
//Serial.print("data masuk : ");
//Serial.print(dataIn);
//Serial.print("\n");
//inisialisasi variabel, (reset isi variabel)
dt[j]="";
//proses parsing data
for(i=1;i<dataIn.length();i++){
//pengecekan tiap karakter dengan karakter (#) dan (,)
if ((dataIn[i] == '#') || (dataIn[i] == ','))
{
//increment variabel j, digunakan untuk merubah index array penampung
j++;
dt[j]=""; //inisialisasi variabel array dt[j]
}
else
{
//proses tampung data saat pengecekan karakter selesai.
dt[j] = dt[j] + dataIn[i];
}
}
datain1 = dt[0].toInt();
datain2 = dt[1].toInt();
datain3 = dt[2].toInt();
datain4 = dt[3].toInt();
//kirim data hasil parsing
Serial.print("data 1 : ");
Serial.print(datain1);
Serial.print("\n");
Serial.print("data 2 : ");
Serial.print(datain2);
Serial.print("\n");
Serial.print("data 3 : ");
Serial.print(datain3);
Serial.print("\n");
Serial.print("data 4 : ");
Serial.print(datain4);
Serial.print("\n");
suhuku = datain1 / 1;
bpmku = datain2 / 1;
sistole = datain3 / 1;
diastole = datain4 / 1;
}
Monitor Suhu Tubuh + BPM + TENSIMETER via Bluetooth Android Sensor MAX30100 dan MLX90614
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara
membuat sebuah alat yang dapat memonitor suhu tubuh, bpm dan tensi via
bluetooth android. alat ini memang sangat cocok untuk digunakan sebagai
alat pengecekan karena mudah dibawa dan juga terdapat fitur bluetooth
sehingga bisa dimonitor melalui HP Android. untuk lebih jelasnya berikut
adalah daftar komponen dan programnya.
h. Koding Android
I. Program Arduino IDE
#include <LiquidCrystal_I2C.h>
#include <Adafruit_MLX90614.h>
#include <MAX30100_PulseOximeter.h>
#define REPORTING_PERIOD_MS 5000
#include "MAX30100.h" //library sensor
LiquidCrystal_I2C lcd(0x27,16,2); //library lcd
MAX30100* pulseOxymeter; //library
int cacah; //membuat variabel
int spo;
float bpm;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
float TargetC;
int motor = 8;
int solenoid = 9;
int dataadc;
//int tombol = D4;
int tombolx;
int hitung;
float vol;
float mmhg;
float mmhgx;
int sistole;
int diastole;
int sistolex;
int diastolex;
int mark = 0;
int bttensi = 10;
int suhunya;
int bpmku;
PulseOximeter pox;
uint32_t tsLastReport = 0;
String hrData = "";
void onBeatDetected()
{
// Serial.println("Beat!");
}
void setup() {
Wire.begin();
mlx.begin();
Serial.begin(9600);
lcd.begin();
lcd.clear();
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
pinMode(motor,OUTPUT);
pinMode(solenoid,OUTPUT);
pinMode(bttensi,INPUT_PULLUP);
digitalWrite(motor,LOW);
digitalWrite(solenoid,LOW);
//Serial.print("Initializing pulse oximeter..");
if (!pox.begin()) {
//Serial.println("FAILED");
for(;;);
} else {
//Serial.println("SUCCESS");
}
pox.setIRLedCurrent(MAX30100_LED_CURR_11MA);
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop(){
pox.update();
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
bpm = pox.getHeartRate();
spo = pox.getSpO2();
bpmku = bpm;
lcd.setCursor(0,1);
lcd.print("Bpm: ");
lcd.print(pox.getHeartRate());
lcd.print(" ");
tsLastReport = millis();
}
mlx.begin();
TargetC = mlx.readObjectTempC();
suhunya = TargetC;
lcd.setCursor(0,0);
lcd.print("S=");
lcd.print(suhunya);
lcd.print("/");
lcd.print(sistole);
lcd.print("/");
lcd.print(diastole);
lcd.print(" ");
int bttensix = digitalRead(bttensi);
if(bttensix == 0){
lcd.clear();
delay(3000);
mulai();
}
delay(1);
cacah++;
if(cacah >= 10){
cacah = 0;
/*
Serial.print("*");
Serial.print(suhunya);
Serial.print(",");
Serial.print(bpmku);
Serial.print(",");
Serial.print(sistole);
Serial.print(",");
Serial.print(diastole);
Serial.println("#");
*/
Serial.print("Suhu= ");
Serial.println(suhunya);
Serial.print("Bpm= ");
Serial.println(bpm);
Serial.print("Sistole= ");
Serial.println(sistole);
Serial.print("Diastole= ");
Serial.println(diastole);
}
}
Monitor Suhu Tubuh + BPM + TENSIMETER via Bluetooth Android Sensor MAX30102 dan MLX90614
h. Koding Android
i. Program Arduino IDE
#include <Wire.h>
#include <SPI.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_MLX90614.h>
#include "MAX30105.h"
#include "heartRate.h"
LiquidCrystal_I2C lcd(0x27,16,2); //library lcd
int cacah; //membuat variabel
int spo;
float bpm;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
float TargetC;
int motor = 8;
int solenoid = 9;
int dataadc;
//int tombol = D4;
int tombolx;
int hitung;
float vol;
float mmhg;
float mmhgx;
int sistole;
int diastole;
int sistolex;
int diastolex;
int mark = 0;
int bttensi = 10;
int suhunya;
int bpmku;
MAX30105 particleSensor;
const byte RATE_SIZE = 4; //Increase this for more averaging. 4 is good.
byte rates[RATE_SIZE]; //Array of heart rates
byte rateSpot = 0;
long lastBeat = 0; //Time at which the last beat occurred
float beatsPerMinute;
int beatAvg;
int counter;
void setup() {
Wire.begin();
mlx.begin();
Serial.begin(9600);
lcd.begin();
lcd.clear();
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
pinMode(motor,OUTPUT);
pinMode(solenoid,OUTPUT);
pinMode(bttensi,INPUT_PULLUP);
digitalWrite(motor,LOW);
digitalWrite(solenoid,LOW);
//Serial.println("Initializing...");
// Initialize sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
{
//Serial.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
//Serial.println("Place your index finger on the sensor with steady pressure.");
particleSensor.setup(); //Configure sensor with default settings
particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running
particleSensor.setPulseAmplitudeGreen(0); //Turn off Green LED
}
void loop(){
long irValue = particleSensor.getIR();
if (checkForBeat(irValue) == true)
{
//We sensed a beat!
long delta = millis() - lastBeat;
lastBeat = millis();
beatsPerMinute = 60 / (delta / 1000.0);
if (beatsPerMinute < 255 && beatsPerMinute > 20)
{
rates[rateSpot++] = (byte)beatsPerMinute; //Store this reading in the array
rateSpot %= RATE_SIZE; //Wrap variable
//Take average of readings
beatAvg = 0;
for (byte x = 0 ; x < RATE_SIZE ; x++)
beatAvg += rates[x];
beatAvg /= RATE_SIZE;
}
}
mlx.begin();
TargetC = mlx.readObjectTempC();
suhunya = TargetC;
lcd.setCursor(0,0);
lcd.print("S=");
lcd.print(suhunya);
lcd.print("/");
lcd.print(sistole);
lcd.print("/");
lcd.print(diastole);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Bpm= ");
lcd.print(beatsPerMinute);
lcd.print(" ");
//lcd.print(cacah);
//delay(10);
int bttensix = digitalRead(bttensi);
if(bttensix == 0){
lcd.clear();
delay(3000);
mulai();
}
delay(1);
cacah++;
if(cacah >= 10){
cacah = 0;
/*
Serial.print("*");
Serial.print(suhunya);
Serial.print(",");
Serial.print(bpmku);
Serial.print(",");
Serial.print(sistole);
Serial.print(",");
Serial.print(diastole);
Serial.println("#");
*/
Serial.print("Suhu= ");
Serial.println(suhunya);
Serial.print("Bpm= ");
Serial.println(beatsPerMinute);
Serial.print("Sistole= ");
Serial.println(sistole);
Serial.print("Diastole= ");
Serial.println(diastole);
}
}
void mulai(){
Alat Kendali Servo dan Monitor Jarak HC-SRF04 + SMS Gateway
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Servo.h>
#define trigPin1 6
#define echoPin1 7
#include "sms.h"
SMSGSM sms;
long duration1, distance1;
Servo myservo1;
int relay1 = 4;
int relay2 = 5;
int buzzer = 10;
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
void setup() {
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(2400)) {
Serial.println("\nstatus=READY");
started=true;
} else Serial.println("\nstatus=IDLE");
if(started) {
//Enable this two lines if you want to send an SMS.
if (sms.SendSMS("085733400808", "Alat Ready"))
Serial.println("\nSMS sent OK");
}
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
myservo1.attach(9);
myservo1.write(100);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1,HIGH);
digitalWrite(relay2,HIGH);
pinMode(buzzer,OUTPUT);
digitalWrite(buzzer,HIGH);
}
void loop() {
//goreng krupuk
myservo1.write(100);
delay(3000);
digitalWrite(relay1,LOW);
delay(20000);
//angkat krupuk
digitalWrite(relay1,HIGH);
delay(1000);
myservo1.write(150);
delay(3000);
digitalWrite(trigPin1, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10); // Added this line
digitalWrite(trigPin1, LOW);
duration1 = pulseIn(echoPin1, HIGH);
distance1 = (duration1/2) / 29.1;
Serial.println(distance1);
if(distance1 < 10){
if (sms.SendSMS("085733400808", "Tempat Krupuk Penuh"))
Serial.println("\nSMS sent OK");
digitalWrite(buzzer,LOW);
berhenti();
}
if(distance1 > 10){
digitalWrite(buzzer,HIGH);
}
}
void berhenti(){
digitalWrite(trigPin1, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10); // Added this line
digitalWrite(trigPin1, LOW);
duration1 = pulseIn(echoPin1, HIGH);
distance1 = (duration1/2) / 29.1;
Serial.println(distance1);
myservo1.write(100);
digitalWrite(relay1,HIGH);
if(distance1 > 10){
return;
}
berhenti();
}
Monitor Water Flow dan Pressure Menggunakan SMS Gateway
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor flow air dan tekanan udara atau air secara bersamaan dengan menggunakan SMS gateway. alat ini menggunakan 2 buah sensor dan satu arduino serta modul sim900A. untuk lebih jelasnya berikut adalah proram dan daftar komponennya.
f. Program Arduino IDE
#include "SIM900.h"
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2);
int dataadc;
int x;
float v;
float kpa;
#include "sms.h"
SMSGSM sms;
byte sensorInterrupt = 0; // 0 = digital pin 2
byte sensorPin = 2;
float calibrationFactor = 4.5;
volatile byte pulseCount;
unsigned int frac;
float flowRate;
unsigned int flowMilliLitres;
float totalMilliLitres;
unsigned long oldTime;
float pressure_pascal;
float pressure_bar;
char string[160];
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
int presure;
char presstr[20];
void setup() {
Serial.begin(9600);
lcd.begin();
lcd.clear();
lcd.noCursor();
Serial.println("GSM Shield testing.");
if (gsm.begin(2400)) {
Serial.println("\nstatus=READY");
started=true;
} else Serial.println("\nstatus=IDLE");
if(started) {
// if (sms.SendSMS("085456789999", "Alat Ready"))
// Serial.println("\nSMS sent OK");
}
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void loop() {
if((millis() - oldTime) > 1000)
{
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
pulseCount = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
x = analogRead(A0);
v = x*(5.0/1023.0);
pressure_pascal = (3.0*(v-0.47))*1000000.0;
pressure_bar = pressure_pascal/10e5;
presure = pressure_bar;
lcd.setCursor(0, 0);
lcd.print("Bar= ");
lcd.print(pressure_bar);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("ml/s= ");
lcd.print(flowMilliLitres);
lcd.print(" ");
delay(200);
dtostrf(pressure_bar,5,2,presstr);
sprintf(string,"Flow: %d Pressure: %s", flowMilliLitres, presstr);
int pos=0;
pos=sms.IsSMSPresent(SMS_ALL);
if(pos){
sms.GetSMS(pos,n,smsbuffer,100);
if(!strcmp(smsbuffer,"monitor")){
sms.SendSMS(n,string);
}
if(!strcmp(smsbuffer,"Monitor")){
sms.SendSMS(n,string);
}
delsms();
}
delay(100);
}
void pulseCounter()
{
pulseCount++;
}
void delsms()
{
for (int i=0; i<10; i++)
{
int pos=sms.IsSMSPresent(SMS_ALL);
if (pos!=0)
{
if (sms.DeleteSMS(pos)==1){}else{}
}
}
}
g. VIDEO HASILNYA
Monitor Water Flow dan Pressure
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor flow air dan tekanan udara atau air secara bersamaan dengan menggunakan lcd. alat ini menggunakan 2 buah sensor dan satu arduino. untuk lebih jelasnya berikut adalah proram dan daftar komponennya.
e. Program Arduino IDE
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2);
int dataadc;
int x;
float v;
float kpa;
byte sensorInterrupt = 0; // 0 = digital pin 2
byte sensorPin = 2;
float calibrationFactor = 4.5;
volatile byte pulseCount;
unsigned int frac;
float flowRate;
unsigned int flowMilliLitres;
float totalMilliLitres;
unsigned long oldTime;
float pressure_pascal;
float pressure_bar;
void setup() {
lcd.begin();
lcd.clear();
lcd.noCursor();
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void loop() {
if((millis() - oldTime) > 1000)
{
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
pulseCount = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
x = analogRead(A0);
v = x*(5.0/1023.0);
pressure_pascal = (3.0*(v-0.47))*1000000.0;
pressure_bar = pressure_pascal/10e5;
lcd.setCursor(0, 0);
lcd.print("Bar= ");
lcd.print(pressure_bar);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("ml/s= ");
lcd.print(flowMilliLitres);
lcd.print(" ");
delay(200);
}
void pulseCounter()
{
pulseCount++;
}