#include <Blynk.h>
#include <rgb_lcd.h>
int button = 3;
int LED = 7;
int a;
int del=1000;
float temperature;
int B=3975;
float Resistance;
int LED1=6;
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int colorR = 255;
const int colorG = 255;
const int colorB = 255;
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
//#define BLYNK_USE_DIRECT_CONNECT
#include <BlynkSimpleCurieBLE.h>
#include <CurieBLE.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "d617c296fb2c4227a9829b5f33eef636";
BLEPeripheral blePeripheral;
void setup() {
// put your setup code here, to run once:
pinMode(button,INPUT);
pinMode(LED,OUTPUT);
pinMode(LED1,OUTPUT);
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
// Print a message to the LCD.
delay(1000);
Serial.begin(9600);
delay(1000);
blePeripheral.setLocalName("rajat");
blePeripheral.setDeviceName("rajat");
blePeripheral.setAppearance(384);
Blynk.begin(blePeripheral, auth);
blePeripheral.begin();
Serial.println("Waiting for connections...");
}
void loop() {
// put your main code here, to run repeatedly:
int buttonState=digitalRead(button);
if(buttonState==1)
{
digitalWrite(LED,HIGH);
a=analogRead(A0);
Resistance=(float)(1023-a)*(10000/a);
temperature=1/(log(Resistance/10000)/B+1/298.15)-293.15;
lcd.print("TEMPERATURE:");
lcd.print(temperature);
delay(del);
if(temperature>20)
{
digitalWrite(LED1,HIGH);
delay(1000);
digitalWrite(LED1,LOW);
}
}
else
digitalWrite(LED,LOW);
lcd.setCursor(0, 1);
delay(100);
Blynk.run();
blePeripheral.poll();
}
Comments