Hello everyone'
today i am gone show you how to build this analog temperature meter with help of Arduino, temperature sensor and servo motor. if you like that old school analog meters that looks cooler than digital once than this project surly for you
So,Let,s make it
I am using an Arduino nano as main processing board to drive servo , the display needle is attached to the head of the servo which so the approx temperature of the room where you putting it.
Here is the connection diagram of the project
Source Code
So then i write simple source code for it in Arduino Ide, here it is
#include <Servo.h>
#include "DHT.h"
#define DHTPIN 4
#define DHTTYPE DHT11
Servo myservo;
DHT dht(DHTPIN, DHTTYPE);
int val=0;
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
myservo.attach(9);
dht.begin();
myservo.write(10);
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.println(" *F");
val = map(t, 0, 50, 180, 0);
myservo.write(val);
Files
here it is the temperature meter template so you can easily use it
Video
for detail making video check out my video on YouTube and please like share and subscribe to my YouTube channel
https://youtu.be/mZg6IZmhew4
Comments
Post a Comment