Friday, 19 July 2019

DHT11 thingspeak



#include <DHT.h>  // Including library for dht

#include <ESP8266WiFi.h>

String apiKey = "10OEANZL1113P0WS9JF";     //  Enter your Write API key from ThingSpeak

const char *ssid =  "Connectify-me";     // replace with your wifi ssid and wpa2 key
const char *pass =  "123456";
const char* server = "api.thingspeak.com";

#define DHTPIN 0          //pin where the dht11 is connected//d3

DHT dht(DHTPIN, DHT11);

WiFiClient client;

void setup()
{
       Serial.begin(115200);
       delay(10);
       dht.begin();

       Serial.println("Connecting to ");
       Serial.println(ssid);

       WiFi.begin(ssid, pass);

      while (WiFi.status() != WL_CONNECTED)
     {
            delay(500);
            Serial.print(".");
     }
      Serial.println("");
      Serial.println("WiFi connected");
   
}

void loop()
{

      float h = dht.readHumidity();
      float t = dht.readTemperature();
 
              if (isnan(h) || isnan(t))
               {
                     Serial.println("Failed to read from DHT sensor!");
                      return;
                 }

                         if (client.connect(server,80))   //   "184.106.153.149" or api.thingspeak.com
                      {
                       
                             String postStr = apiKey;
                              postStr +="&field1=";
                             postStr += String(t);
                             postStr +="&field2=";
                             postStr += String(h);
                             postStr += "\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: "+apiKey+"\n");
                             client.print("Content-Type: application/x-www-form-urlencoded\n");
                             client.print("Content-Length: ");
                             client.print(postStr.length());
                             client.print("\n\n");
                             client.print(postStr);

                             Serial.print("Temperature: ");
                             Serial.print(t);
                               Serial.print(" degrees Celcius, Humidity: ");
                             Serial.print(h);
                             Serial.println("%. Send to Thingspeak.");
                        }
          client.stop();
 Serial.println("Waiting...");

  // thingspeak needs minimum 15 sec delay between updates, i've set it to 30 seconds
  delay(10000);
}

Wifi

#include <ESP8266WiFi.h>
  const char* wifiName = "SSID";
  const char* wifiPass = "PASSWORD";
void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(wifiName);
  WiFi.begin(wifiName, wifiPass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP()); 
}
void loop() {
}

Thursday, 18 July 2019

DHT11 new

#include "dht.h"
#define dht_apin A0 // Analog Pin sensor is connected to
 
dht DHT;
 
void setup(){
 
  Serial.begin(9600);
  delay(500);//Delay to let system boot
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  delay(1000);//Wait before accessing Sensor
 
}//end "setup()"
 
void loop(){
  //Start of Program 
 
    DHT.read11(dht_apin);
    
    Serial.print("Current humidity = ");
    Serial.print(DHT.humidity);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(DHT.temperature); 
    Serial.println("C  ");
    
    delay(5000);//Wait 5 seconds before accessing sensor again.
 
  //Fastest should be once every two seconds.
 
}// end loop() 

DHT11


const int LM_35 = A0;  // Assigning Pin to LM35
int input_val = 0;     // TO store input value
float temp = 0;        // To store final temperature output

void setup() {
   Serial.begin(115200);
}

void loop() { 
   input_val = analogRead(LM_35);             // Reading analog input
   temp = (5.0 * input_val * 100.0) / 1024;   // Some calculation to convert analog value to temperature
   Serial.print("Temperature is : " );                      
   Serial.println(temp);
   delay(1000);      
}

sound

int soundSensor = 7;
int LED = 3;

void setup()
{
  Serial.begin(9600);

  pinMode (soundSensor, INPUT);
  pinMode (LED, OUTPUT);
}

void loop()
{
  int statusSensor = digitalRead (soundSensor);

  if (statusSensor == 1)
  {
    digitalWrite(LED, HIGH);
    Serial.println("Sound");
  }

  else
  {
    digitalWrite(LED, LOW);
    Serial.println("low Sound");
  }
  delay(1);
}

Fade LED

int led = D2;           // the PWM pin the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by
void setup() {

  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 9:
  analogWrite(led, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}

Monday, 15 July 2019

MR GLA

https://drive.google.com/open?id=13_0WQmhKZCULN1AvJCMRiS19QvVHo1ua

Thursday, 4 July 2019

Testing

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Man {
    public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
        String baseUrl = "http://www.manishkumarjain.com";
        String expectedTitle = "Welcome: MKJ";
        String actualTitle = "";
        driver.get(baseUrl);
        actualTitle = driver.getTitle();
        if (actualTitle.contentEquals(expectedTitle)){
            System.out.println("Test Passed!");
        } else {
            System.out.println("Test Failed");
        }
               driver.close();
     
    }