Posts

Connecting Arduino & NodeMCU with WiFi

#include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> const char* ssid = "WiFiSSID"; const char* password = "password"; void setup () {   Serial.begin(9600);   WiFi.begin(ssid, password);   while (WiFi.status() != WL_CONNECTED) {     delay(1000);     Serial.print("Connecting..");   } } void loop() {   if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status     HTTPClient http;  //Declare an object of class HTTPClient     http.begin("http://192.168.0.1/Work/api/Device/AddEmpWork/12121212/1"); //Specify request destination     int httpCode = http.GET(); //Send the request     if (httpCode > 0) { //Check the returning code       String payload = http.getString(); //Get the request response payload       Serial.println(payload); //Print the response payload     }     http.end(); //Close connection   }   delay(3000); //Send a request every 30 seconds }

Temperature and Humidity in Arduino & NodeMCU

#include "DHT.h" DHT dht; void setup() {   Serial.begin(9600);   Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)");   dht.setup(4); } void loop() {   delay(dht.getMinimumSamplingPeriod());   float humidity = dht.getHumidity();   float temperature = dht.getTemperature();   Serial.print(dht.getStatusString());   Serial.print("\t");   Serial.print(humidity, 1);   Serial.print("\t\t");   Serial.print(temperature, 1);   Serial.print("\t\t");   Serial.println(dht.toFahrenheit(temperature), 1); }

Creating Toast Message in Android

 Toast.makeText(getBaseContext(), "Your Message", Toast.LENGTH_SHORT).show();

Creating Dialog Box in Android

AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this); dialog.setCancelable(false); dialog.setTitle("Dialog on Android"); dialog.setMessage("Are you sure you want to delete this entry?"); dialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() {     @Override     public void onClick(DialogInterface dialog, int id) {         //Action for "Delete".     } }) .setNegativeButton("Cancel ", new DialogInterface.OnClickListener() {     @Override     public void onClick(DialogInterface dialog, int which) {         //Action for "Cancel".     } }); final AlertDialog alert = dialog.create(); alert.show();