Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BLYNK_PRINT Serial // Comment this out to disable prints and save space
- #include <SPI.h>
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- #include <SimpleTimer.h>
- // You should get Auth Token in the Blynk App.
- // Go to the Project Settings (nut icon).
- char auth[] = "YOUR AUTH CODE";
- // Your WiFi credentials.
- // Set password to "" for open networks.
- char ssid[] = "YOUR_SSID"; //Enter your WIFI Name
- char pass[] = "YOUR_PASSWORD"; //Enter your WIFI Password
- int ThermistorPin = 0; //USE Analog Pin A0 for the input of thermistor value [0 or A0 both works]
- int Vo;
- float R1 = 10000;
- float logR2, R2, T, Tc, Tf;
- float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
- SimpleTimer timer;
- void sendSensor()
- {
- Vo = analogRead(ThermistorPin); // Analog Value read from thermistor pin A0
- R2 = R1 * (1023.0 / (float)Vo - 1.0); //Mapping of the Data
- logR2 = log(R2); // Log of Mapped Data
- T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2)); // Convert data to temperature relevant data
- Tc = T - 273.15; //Temperature in Celcius
- Tf = (Tc * 9.0)/ 5.0 + 32.0; //Temperature in Fareinheit
- Serial.print("Temperature: ");
- Serial.print(Tc);
- Serial.println(" C");
- Blynk.virtualWrite(V4, Tc); //Virtual Pin for the data display in the APP
- }
- void setup()
- {
- Serial.begin(115200); // See the connection status in Serial Monitor
- Blynk.begin(auth, ssid, pass);
- // Setup a function to be called every second
- timer.setInterval(1000L, sendSensor);
- }
- void loop()
- {
- Blynk.run(); // Initiates Blynk
- timer.run(); // Initiates SimpleTimer
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement