Skip to main content

Latest Post

What is Industry 4.0?

  What is Industry 4.0 and what are some of the technologies that are driving it? Industry 4.0 is a term that refers to the fourth industrial revolution, which is characterized by the integration of digital technologies, such as artificial intelligence, cloud computing, big data, the internet of things, robotics, and 3D printing, into the manufacturing sector. Industry 4.0 aims to create smart factories that are more efficient, flexible, and responsive to customer needs and market changes. Some of the technologies that are enabling Industry 4.0 are: - Artificial intelligence (AI) : AI is the ability of machines to perform tasks that normally require human intelligence, such as reasoning, learning, decision-making, and problem-solving. AI can help optimize production processes, improve product quality, reduce costs, and enhance customer satisfaction. - Cloud computing: Cloud computing is delivering computing services, such as servers, storage, databases, software, and analytics, ov...

Log sensor data in the cloud

The Cloud 

"The cloud" refers to servers that are accessed over the Internet, and the software and databases that run on those servers. Cloud servers are located in data centers all over the world. By using cloud computing, users and companies do not have to manage physical servers themselves or run software applications on their own machines.

The cloud enables users to access the same files and applications from almost any device, because the computing and storage takes place on servers in a data center, instead of locally on the user device. This is why a user can log in to their Instagram account on a new phone after their old phone breaks and still find their old account in place, with all their photos, videos, and conversation history. It works the same way with cloud email providers like Gmail or Microsoft Office 365, and with cloud storage providers like Dropbox or Google Drive.

For businesses, switching to cloud computing removes some IT costs and overhead: for instance, they no longer need to update and maintain their own servers, as the cloud vendor they are using will do that. This especially makes an impact for small businesses that may not have been able to afford their own internal infrastructure but can outsource their infrastructure needs affordably via the cloud. The cloud can also make it easier for companies to operate internationally, because employees and customers can access the same files and applications from any location.

Video tutorial




Code for Arduino

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include<DHT.h>
#define DHTPIN D2
#define DHTTYPE DHT11
 
DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "";    // name of your wifi network!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
const char* password = "";     // wifi pasword !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
const char* host = "script.google.com";
const int httpsPort = 443;
// Use WiFiClientSecure class to create TLS connection
WiFiClientSecure client;
// SHA1 fingerprint of the certificate, don't care with your GAS service
const char* fingerprint = "46 B2 C3 44 9C 59 09 8B 01 B6 F8 BD 4C FB 00 74 91 2F EF F6";
String GAS_ID = "";     // Replace by your GAS service id           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
int it;
int ih;
void setup()
{
 
  dht.begin();  // sensor
  Serial.begin(115200); //Serial
  Serial.println();

  //connecting to internet
  Serial.print("connecting to ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  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()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  Serial.print("Temp = ");
  Serial.print(t);
  Serial.print(" HUM= ");
  Serial.println(h);
   it = (int) t;
   ih = (int) h;
  sendData(it, ih);
 
 delay(2000);
}

// Function for Send data into Google Spreadsheet
void sendData(int tem, int hum)
{
  Serial.print("connecting to ");
  Serial.println(host);
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }

  if (client.verify(fingerprint, host)) {
  Serial.println("certificate matches");
  } else {
  Serial.println("certificate doesn't match");
  }
  String string_temperature =  String(tem, DEC);
  String string_humidity =  String(hum, DEC);
  String url = "/macros/s/" + GAS_ID + "/exec?temperature=" + string_temperature + "&humidity=" + string_humidity;
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
         "Host: " + host + "\r\n" +
         "User-Agent: BuildFailureDetectorESP8266\r\n" +
         "Connection: close\r\n\r\n");

  Serial.println("request sent");
  while (client.connected()) {
  String line = client.readStringUntil('\n');
  if (line == "\r") {
    Serial.println("headers received");
    break;
  }
  }
  String line = client.readStringUntil('\n');
  if (line.startsWith("{\"state\":\"success\"")) {
  Serial.println("esp8266/Arduino CI successfull!");
  } else {
  Serial.println("esp8266/Arduino CI has failed");
  }
  Serial.println("reply was:");
  Serial.println("==========");
  Serial.println(line);
  Serial.println("==========");
  Serial.println("closing connection");
}

Code for Google drive

/*
//https://docs.google.com/spreadsheets/d/1sUFwKGAMzYWl6Y9RUM-dyWgsE1BfPqMzToBBm7JHK5g/edit#gid=0
//-----------------------------------------------
// Author: Trieu Le
// Email: lethanhtrieuk36@gmail.com
// Publish date: 07-Oct-2015
// Description: This code for demonstration send data from ESP8266 into Google Spreadsheet
// GET request syntax:
// https://script.google.com/macros/s/<gscript id>/exec?header_here=data_here
// Modified by Moz for YouTube chancel logMaker360 for this video: https://youtu.be/fS0GeaOkNRw 24-02-2018


//-----------------------------------------------
/**
* Function doGet: Parse received data from GET request,
  get and store data which is corresponding with header row in Google Spreadsheet
*/
function doGet(e) {
    Logger.log( JSON.stringify(e) );  // view parameters
    var result = 'Ok'; // assume success
    if (e.parameter == 'undefined') {
      result = 'No Parameters';
    }
    else {
      var sheet_id = '';        // Spreadsheet ID
      var sheet = SpreadsheetApp.openById(sheet_id).getActiveSheet();       // get Active sheet
      var newRow = sheet.getLastRow() + 1;                      
      var rowData = [];
      rowData[0] = new Date();                                          // Timestamp in column A
      for (var param in e.parameter) {
        Logger.log('In for loop, param=' + param);
        var value = stripQuotes(e.parameter[param]);
        Logger.log(param + ':' + e.parameter[param]);
        switch (param) {
          case 'temperature': //Parameter
            rowData[1] = value; //Value in column B
            result = 'Written on column B';
            break;
          case 'humidity': //Parameter
            rowData[2] = value; //Value in column C
            result += ' ,Written on column C';
            break;  
          default:
            result = "unsupported parameter";
        }
      }
      Logger.log(JSON.stringify(rowData));
      // Write new row below
      var newRange = sheet.getRange(newRow, 1, 1, rowData.length);
      newRange.setValues([rowData]);
    }
    // Return result of operation
    return ContentService.createTextOutput(result);
  }
  /**
  * Remove leading and trailing single or double quotes
  */
  function stripQuotes( value ) {
    return value.replace(/^["']|['"]$/g, "");
  }
  //-----------------------------------------------
  // End of file
  //-----------------------------------------------
 
  void setup() {
     
  }
 
  void loop() {
     
  }

Other references

Popular

Playing with Buttons

Button Pushbuttons or switches connect two points in a circuit when you press them. This example turns on the built-in LED on pin 13 when you press the button. Hardware Arduino Board Momentary button or Switch 10K ohm resistor hook-up wires breadboard Circuit diagram Code // constants won't change. They're used here to // set pin numbers: const int buttonPin = 2 ;     // the number of the pushbutton pin const int ledPin =   13 ;      // the number of the LED pin // variables will change: int buttonState = 0 ;         // variable for reading the pushbutton status void setup () {   Serial . begin ( 9600 );   // initialize the LED pin as an output:   pinMode (ledPin, OUTPUT);   // initialize the pushbutton pin as an input:   pinMode (buttonPin, INPUT); } void loop () {   // read the state of the pushbutton value:   buttonState = digitalRead (buttonPin);   // Show the state of pushbutton on s...

Home Automation

A smart system made by using Node MCU dev board. What is Node MCU? NodeMCU is an open-source firmware for which open-source prototyping board designs are available. The name "NodeMCU" combines "node" and "MCU" (micro-controller unit). The term "NodeMCU" strictly speaking refers to the firmware rather than the associated development kits.  Both the firmware and prototyping board designs are open source. Requirments Node MCU 4 channel relay toggle switch * 4 Hi-links (220v ac to 5v dc) Circuit Diagram Program #ifdef ENABLE_DEBUG         #define DEBUG_ESP_PORT Serial         #define NODEBUG_WEBSOCKETS         #define NDEBUG #endif #include <Arduino.h> #include <ESP8266WiFi.h> #include "SinricPro.h" #include "SinricProSwitch.h" #include <map> #define WIFI_SSID         "your wifi name"     #define WIFI_PASS         "your wifi pass" #define APP_KEY...

Turn LED On and Off Through LDR

  LDR An LDR ( Light Dependent Resistor ) is a component that has a (variable) resistance that changes with the light intensity that falls upon it. This allows them to be used in light sensing circuits. A photoresistor is made of a high resistance semiconductor. Hardware Required Arduino Board LED 220 ohm resistor LDR 10k ohms resistor Circuit Diagram Code int ldr=A0; //Set A0(Analog Input) for LDR. int value= 0 ; void setup () { Serial . begin ( 9600 ); pinMode ( 3 ,OUTPUT); } void loop () { value= analogRead (ldr); //Reads the Value of LDR(light). Serial . println ( "LDR value is :" ); //Prints the value of LDR to Serial Monitor. Serial . println (value); if (value< 300 )   {     digitalWrite ( 3 ,HIGH); //Makes the LED glow in Dark.   }   else   {     digitalWrite ( 3 ,LOW); //Turns the LED OFF in Light.   } }

Temperature sensor

About the LM35 The LM35 is an inexpensive, precision Centigrade temperature sensor made by  Texas Instruments . It provides an output voltage that is linearly proportional to the Centigrade temperature and is, therefore, very easy to use with the Arduino. The sensor does not require any external calibration or trimming to provide accuracies of ±0.5°C at room temperature and ±1°C over the −50°C to +155°C temperature range. One of the downsides of the sensor is that it requires a negative bias voltage to read negative temperatures. So if that is needed for your project, I recommend using the DS18B20 or TMP36 instead. The TMP36 by Analog Devices is very similar to the LM35 and can read temperatures from -40°C to 125°C without any external components Note that the sensor operates on a voltage range of 4 to 30 V and that the output voltage is independent of the supply voltage. The LM35 is part of a series of analog temperature sensors sold by Texas Instruments. Other members of the seri...

MQ2 Gas Sensor

 About Gas Sensor The MQ series of gas sensors use a small heater inside with an electrochemical sensor. They are sensitive to a range of gasses and are used indoors at room temperature. The output is an analog signal and can be read with an analog input of the Arduino. The MQ-2 Gas Sensor module is useful for gas leakage detection in homes and industries. It can detect LPG, i-butane, propane, methane, alcohol, hydrogen, and smoke. Some modules have a built-in variable resistor to adjust the sensitivity of the sensor. Note:  The sensor becomes very hot after a while, don't touch it! Required  Arduino UNO Breadboard MQ-2 Gas sensor module Red, Green led 5mm 220 Ohm Buzzer The connections are pretty easy: The MQ-5 sensor Pin-> Wiring to Arduino Uno A0-> Analog pins D0-> none GND-> GND VCC-> 5V other components Pin-> Wiring to Arduino Uno D13-> +ve of buzzer GND-> -ve of buzzer D12-> anode of red light D11-> anode of green light GND-> cathode...

Play a melody with a Piezo speaker

  Play a Melody using the tone() function This example shows how to use the  tone()  command to generate notes. It plays a little melody you may have heard before. Hardware Required Arduino board piezo buzzer or a speaker hook-up wires Making header file To make the pitches.h file, either click on the button just below the serial monitor icon and choose "New Tab", or use Ctrl+Shift+N. Then paste in the following code: /************************************************* * Public Constants *************************************************/ # define NOTE_B0 31 # define NOTE_C1 33 # define NOTE_CS1 35 # define NOTE_D1 37 # define NOTE_DS1 39 # define NOTE_E1 41 # define NOTE_F1 44 # define NOTE_FS1 46 # define NOTE_G1 49 # define NOTE_GS1 52 # define NOTE_A1 55 # define NOTE_AS1 58 # define NOTE_B1 62 # define NOTE_C2 65 # define NOTE_CS2 69 # define NOTE_D2 73 # define NOTE_DS2 78 # define NOTE_E2 82 # define NOTE_F2 87 ...

Seven Segment Display Interfacing with Arduino

Seven-Segment Introduction  Let’s start the main part of this tutorial by answering a question: what is a seven-segment display? As its name suggests, a 7-segment device consists of 7  light-emitting diodes . These light-emitting diodes are arranged and packed inside a single display with a specific pattern in mind. If this pattern is controlled in a specific way by turning on and turning off LEDs, a seven-segment device will display a unique number. There is also an extra eighth LED on a seven-segment display which is used to display dots. This dot is sometimes used as a decimal point when we want to display a fractional value.  The picture below shows a seven-segment display and its pinout. The string of eight LEDs on the left side shows the internal connection and a picture on the right side shows how these LEDs are arranged to make a seven-segment display. Pin3 and 8 are common pins. These pins are used to provide either 5 volts or ground in common-anode and common ca...

Mini Oscilloscope via Arduino Nano

What is an oscilloscope?   An  oscilloscope , formerly known as an oscillograph, is an instrument that graphically displays electrical signals and shows how those signals change over time. It measures these signals by connecting with a sensor, which is a device that creates an electrical signal in response to physical stimuli like sound, light, and heat. For instance, a microphone is a sensor that converts sound into an electrical signal. Oscilloscopes are often used when designing, manufacturing, or repairing electronic equipment. Engineers use an oscilloscope to measure electrical phenomena and solve measurement challenges quickly and accurately to verify their designs or confirm that a sensor is working properly. Scientists, engineers, physicists, repair technicians, and educators use oscilloscopes to see signals change over time. An automotive engineer might use an oscilloscope to correlate analog data from sensors with serial data from the engine control unit. Meanwh...

Fade an LED

  Fade This example demonstrates the use of the  analogWrite()  function in fading an LED off and on. AnalogWrite uses  pulse width modulation (PWM) , turning a digital pin on and off very quickly with different ratio between on and off, to create a fading effect. Hardware Required Arduino board LED 220 ohm resistor hook-up wires Circuit Diagram Code int led = 9 ;           // 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 // the setup routine runs once when you press reset: void setup () {   // declare pin 9 to be an output:   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; ...

Fire Alarm with arduino

Flame Sensor A  flame detector  is a sensor designed to detect and respond to the presence of a flame or fire. Responses to a detected flame depend on the installation but can include sounding an alarm, deactivating a fuel line (such as a propane or a natural gas line), and activating a fire suppression system. The IR Flame sensor used in this project is shown below, these sensors are also called  Fire sensor modules  or  flame detector sensors  sometimes. There are different types of flame detection methods. Some of them are Ultraviolet detector, near IR array detector, infrared (IR) detector, Infrared thermal cameras, UV/IR detector, etc. When fire burns it emits a small amount of Infra-red light, this light will be received by the Photodiode (IR receiver) on the sensor module. Then we use an Op-Amp to check for a change in voltage across the IR Receiver, so that if a fire is detected the output pin (DO) will give 0V(LOW), and if the is no fire the o...