https://shorturl.at/vbzOx
url
interface lm35 using uno
const int lm35_pin = A1; /* LM35 O/P pin */
void setup() {
Serial.begin(9600);
}
void loop() {
int temp_adc_val;
float temp_val;
temp_adc_val = analogRead(lm35_pin); /* Read Temperature */
temp_val = (temp_adc_val * 4.88); /* Convert adc value to equivalent voltage */
temp_val = (temp_val/10); /* LM35 gives output of 10mv/°C */
Serial.print("Temperature = ");
Serial.print(temp_val);
Serial.print(" Degree Celsius\n");
delay(1000);
}
lm35 esp8266
#include <ESP8266WiFi.h>
String apiWritekey = "XX_YOUR_API_KEY_XX";
const char* ssid = "YOUR WIFI NAME (SSID)";
const char* password = "YOUR WIFI PASSWORD" ;
const char* server = "api.thingspeak.com";
float resolution=3.3/1023;
WiFiClient client;
void setup() {
Serial.begin(115200);
WiFi.disconnect();
delay(10);
WiFi.begin(ssid, password);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("NodeMcu connected to wifi...");
Serial.println(ssid);
Serial.println();
}
void loop() {
float temp = ((analogRead(A0) * resolution) * 100)+23.89;
if (client.connect(server,80)) {
String tsData = apiWritekey;
tsData +="&field1=";
tsData += String(temp);
tsData += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiWritekey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");
client.print(tsData);
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println("uploaded to Thingspeak server....");
}
client.stop();
Serial.println("Waiting to upload next reading...");
Serial.println();
delay(15000);
}
/// lcd display to scroll
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize LCD (I2C address: 0x27)
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.begin(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
}
void loop() {
lcd.setCursor(0, 0); // Start at the first row
lcd.print("Scrolling Text"); // Print text
delay(500); // Pause for readability
lcd.scrollDisplayLeft(); // Scroll the text left
}
LM35 sensor
const int lm35_pin = A1; /* LM35 O/P pin */
void setup() {
Serial.begin(9600);
}
void loop() {
int temp_adc_val;
float temp_val;
temp_adc_val = analogRead(lm35_pin); /* Read Temperature */
temp_val = (temp_adc_val * 4.88); /* Convert adc value to equivalent voltage */
temp_val = (temp_val/10); /* LM35 gives output of 10mv/°C */
Serial.print("Temperature = ");
Serial.print(temp_val);
Serial.print(" Degree Celsius\n");
delay(1000);
}
LM35 Using ESP8266
#include <ESP8266WiFi.h>
String apiWritekey = "XX_YOUR_API_KEY_XX";
const char* ssid = "YOUR WIFI NAME (SSID)";
const char* password = "YOUR WIFI PASSWORD" ;
const char* server = "api.thingspeak.com";
float resolution=3.3/1023;
WiFiClient client;
void setup() {
Serial.begin(115200);
WiFi.disconnect();
delay(10);
WiFi.begin(ssid, password);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("NodeMcu connected to wifi...");
Serial.println(ssid);
Serial.println();
}
void loop() {
float temp = ((analogRead(A0) * resolution) * 100)+23.89;
if (client.connect(server,80)) {
String tsData = apiWritekey;
tsData +="&field1=";
tsData += String(temp);
tsData += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiWritekey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");
client.print(tsData);
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println("uploaded to Thingspeak server....");
}
client.stop();
Serial.println("Waiting to upload next reading...");
Serial.println();
delay(15000);
}
Interface of ir sensor
const int irSensorPin = 7; // IR sensor output pin connected to digital pin 7
void setup() {
pinMode(irSensorPin, INPUT); // Set IR sensor pin as input
Serial.begin(9600); // Begin serial communication for debugging
}
void loop() {
int sensorValue = digitalRead(irSensorPin); // Read the value from the IR sensor
if (sensorValue == LOW) {
Serial.println("Object detected!");
} else {
Serial.println("No object Detected.");
}
delay(1000); // Small delay for stability
}
16*2 interface
//sketch created by Akshay Joseph
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
lcd.begin();
lcd.backlight();
lcd.clear();
lcd.setCursor(4,0);
lcd.print("Hackster");
}
void loop()
{
}
Ultrasonic Sensor
#define echoPin 6
#define trigPin 7
long duration;
int distance;
void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
}
HC-05 Bluetooth
#include<SoftwareSerial.h>
/* Create object named bt of the class SoftwareSerial */
SoftwareSerial bt(2,3); /* (Rx,Tx) */
void setup() {
bt.begin(9600); /* Define baud rate for software serial communication */
Serial.begin(9600); /* Define baud rate for serial communication */
}
void loop() {
if (bt.available()) /* If data is available on serial port */
{
Serial.write(bt.read()); /* Print character received on to the serial monitor */
}
}
Blinking LED
#define led_pin 3
void setup()
{
pinMode(led_pin, OUTPUT);
}
void loop()
{
digitalWrite(led_pin, HIGH);
delay(1000);
digitalWrite(led_pin, LOW);
delay(1000);
}