• How to Send sensor data to cloud using NodMcu8266 | IoT Tutorial

    06/17/2020 at 15:23 0 comments

    We are planning to use the NodMcu8266 to automatically log temperature and humidity measurements within the cloud, and show these measurements inside an online dashboard for this we use the DHT11 sensor for Measure temperature and humidity  Data in our Environment.  We will complete this project by dividing it into several parts.

    Part-1:

    Required Component :

    1.NodeMcu8266

    2.Breadboard

    3. Connecting wire

    4.DHT11

    5.Breadboard Power Supply Module

    Software Required:

    The latest version of the Arduino IDE, which you can get from:
    http://www.arduino.cc/en/Main/Software

    Follow this link to How to  Complet  Software Setup Installing the Arduino IDE for the ESP8266 | IoT Tutorial

    This book will help you to gain more knowledge of the Internet of Things with ESP8266

    Part-2:

    After Complet your hardware  Collection and Software installation now we have to need waring with sensor and esp8266

    Circuit Diagram sensor Data cloud NodMcu8266:

    shows how to connect a DHT 11 sensor to NodMcu8266.

    DHT sensor with nosemcu8266

    Part-3

    Now we went to test sensor work properly or not so we have to need a test for sensor

    Testing the sensor:

    Now we will simply print the value of the temperature inside the Serial monitor of the Arduino IDE. If it has not been done yet

    ,install the DHT sensor library using the Arduino IDE library manager.

    install the DHT sensor library using the Arduino IDE library manager.

    This is the complete code for this part:

    // Libraries
    #include "DHT.h"
    
    // Pin
    #define DHTPIN D5
    
    // Use DHT11 sensor
    #define DHTTYPE DHT11
    
    // Initialize DHT sensor
    DHT dht(DHTPIN, DHTTYPE, 15);
    
    void setup() {
    
      // Start Serial  
      Serial.begin(115200); 
     
      // Init DHT 
      dht.begin();
    }
    
    void loop() {
    
      // Reading temperature and humidity
      float h = dht.readHumidity();
      // Read temperature as Celsius
      float t = dht.readTemperature();
    
      // Display data
      Serial.print("Humidity: "); 
      Serial.print(h);
      Serial.print(" %\t");
      Serial.print("Temperature: "); 
      Serial.print(t);
      Serial.println(" *C ");
      
       // Wait a few seconds between measurements.
      delay(2000);
    
    }

    if you see like this interface then test successfully done

    DHt test output

    Code Overview Part-3 Code:

    It starts by including the required libraries:

    #include "ESP8266WiFi.h"
    #include "DHT.h"

    To install those libraries, simply look for them inside the Arduino IDE library manager. Next, we need to set the pin that the DHT sensor is connected to:

    #define DHTPIN D5
    #define DHTTYPE DHT11

    After that, we declare an instance of the DHT sensor:

    DHT dht(DHTPIN, DHTTYPE, 15);

    We also define two variables that will hold the measurements of the sensor

    float temperature;
    float humidity;

    In the setup() function of the sketch, we initialize the sensor:

    dht.begin();

    in the loop() function, we make the measurements from the sensor:

    humidity = dht.readHumidity();
    temperature = dht.readTemperature();

    Finally  Display data on your serial monitor :

    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.println(" *C ");

    Part-4

    We are now going to see how to Send the temperature and humidity measurements in the cloud. We will use the Dweet.io cloud service here, which is very convenient for sending  data online:

    Sensor data send to Dweet.io:

    Code:

    // Libraries
    #include <ESP8266WiFi.h>
    #include "DHT.h"
    
    // WiFi parameters
    const char* ssid = "Mechatronics";
    const char* password = "Pa$$word";
    
    // Pin
    #define DHTPIN D5
    
    // Use DHT11 sensor
    #define DHTTYPE DHT11
    
    // Initialize DHT sensor
    DHT dht(DHTPIN, DHTTYPE, 15);
    
    // Host
    const char* host = "dweet.io";
    
    void setup() {
    
      // Start Serial
      Serial.begin(115200);
      delay(10);
    
      // Init DHT
      dht.begin();
    
      // We start by connecting to a WiFi network
      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.println("WiFi connected");
      Serial.println("IP address: ");
      Serial.println(WiFi.localIP());
    }
    
    void loop()...
    Read more »

  • Simple SD Card/Read Write– Arduino Workshop

    06/15/2020 at 13:54 1 comment

    In this project, we will connect up an SD Card to an Arduino and by using the SD.h library to access the card, we will create a new file on the card, write some text to that file, print out the contents of that file, then delete the file. This will teach you the basic concepts of accessing an SD card and reading and writing files to it. You will need an SD Card and some way of connecting it to an Arduino. The easiest way is to get an SD/MMC Card Breakout Board from various electronics hobbyist suppliers.

    Required Component  SD Card Arduino:

    1.Arduino 2. Resistors 3. SD Card & Breakout 4. connecting wire 5. Breadboard
    Never connect the Arduino’s output pins directly to the SD Card without first dropping the voltage from them from 5V down to 3.3V or you will damage the SD Card

    This book will help you to gain more knowledge about Arduino

    Beginning Arduino

    Circuit diagram SD Card Arduino

    Simple SD Card Read Write Digital pin 12 on the Arduino goes straight into pin 7 (DO) on the SD Card. Digital pins 13, 11, and 10 go via the resistors to drop the logic levels to 3.3V. The remaining connections to the SD card supply 3.3V to power the SD card via pin 4 and ground pins 3 and 6. Refer to the datasheet for your particular SD Card breakout board in case the pin outs differ from the circuit board above

    Code SD Card Arduino:

    #include <SD.h>
    File File1;
    void setup()
    {
    Serial.begin(9600);
    while (!Serial) { } // wait for serial port to connect.
    // Needed for Leonardo only
    Serial.println("Initializing the SD Card...");
    if (!SD.begin()) {
    Serial.println("Initialization Failed!");
    return;
    }
    Serial.println("Initialization Complete.\n");
    Serial.println("Looking for file 'testfile.txt'...\n");
    if (SD.exists("testfile.txt")) {
    Serial.println("testfile.txt already exists.\n");
    }
    else {
    Serial.println("testfile.txt doesn't exist.");
    Serial.println("Creating file testfile.txt...\n");
    }
    File1 = SD.open("testfile.txt", FILE_WRITE);
    File1.close();
    Serial.println("Writing text to file.....");
    String dataString;
    File1 = SD.open("testfile.txt", FILE_WRITE);
    if (File1) {
    for (int i=1; i<11; i++) {
    dataString = "Test Line ";
    dataString += i;
    File1.println(dataString);
    }
    Serial.println("Text written to file.....\n");
    }
    File1.close();
    Serial.println("Reading contents of textfile.txt...");
    File1 = SD.open("testfile.txt");
    if (File1) {
    while (File1.available()) {
    Serial.write(File1.read());
    }
    File1.close();
    }
    // if the file isn't open, pop up an error:
    else {
    Serial.println("error opening testfile.txt");
    }
    // delete the file:
    Serial.println("\nDeleting testfile.txt...\n");
    SD.remove("testfile.txt");
    if (SD.exists("testfile.txt")){
    Serial.println("testfile.txt still exists.");
    }
    else {
    Serial.println("testfile.txt has been deleted.");
    }
    }
    void loop()
    {
    //
    Nothing to see here
    }
    Make sure that your SD card has been freshly formatted in the FAT or FAT32 format. On a Mac, ensure the partition scheme is set to “Master Boot Record.” Run the program and open the serial monitor. The program will now attempt to write a file to the SD card, write some text to that file, read back the contents of the file and then finally delete the file. This will all be displayed on the serial monitor window. If everything goes well, you will get a readout like this: Initializing the SD Card... Initialization Complete. Looking for file 'testfile.txt'... testfile.txt doesn't exist. Creating file testfile.txt... Writing text to file..... Text written to file..... Reading contents of textfile.txt... Test Line 1 Test Line 2 Test Line 3 Test Line 4 Test Line 5 Test Line 6 Test Line 7 Test Line 8 Test Line 9 Test Line 10 Deleting testfile.txt... testfile.txt has been deleted. Make sure that the card is either SD or SDHC format and that it is formatted with “Master Boot Record” or MBR partitions.

    All Arduino tutorial available Click here

     ALL ARDUINO TUTORIAL 

  • Serial Temperature Sensor– Arduino Workshop

    06/15/2020 at 13:53 0 comments

    This project we know about Serial Temperature Sensor Arduino uses the LM35 analog temperature sensor. This sensor is part of the LM135 range of sensors from National Semiconductors. It has a range from −40°C to +100°C The circuit and code is designed for an LM35 sensor, but you can just as easily substitute an LM135 or LM235 if you wish. You will need to adjust your code accordingly to the relevant sensor. You can substitute a standard rotary potentiometer of a similar value for the 5K ohm trim pot (potentiometer). A trim pot, or trimmer potentiometer, is simply a small potentiometer designed to adjust, or trim, part of a circuit and then, once calibrated, be left alone. Any value trimmer or potentiometer with a value between 5K ohm and 10K ohm will do

    Required Component

    1.Arduino 2. Resistors 3. LM35 Temperature Sensor 4. 5K ohm Trim Pot 5. connecting wire 6. Breadboard 7. 6×2 LCD Display Module

    This book will help you to gain more knowledge about Arduino

    Beginning Arduino

    Circuit diagram Serial Temperature Sensor Arduino:

    Serial Temperature Sensor If you have the flat side of the LM35 temperature sensor facing you, the left-hand leg is the adjustment pin that goes to the center pin of the pot, the middle leg is the positive supply pin, and the right-hand leg is the ground pint. The center pin goes to analog pin 0 on the Arduino

    Code Serial Temperature Sensor Arduino:

    #define sensorPin 0
    float Celsius, Fahrenheit, Kelvin;
    int sensorValue;
    void setup() {
    Serial.begin(9600);
    Serial.println("Initialising.....");
    }
    void loop() {
    GetTemp();
    Serial.print("Celsius: ");
    Serial.println(Celsius);
    Serial.print("Fahrenheit: ");
    Serial.println(Fahrenheit);
    Serial.println();
    delay(2000);
    }
    void GetTemp()
    {
    sensorValue = analogRead(sensorPin); // read the
    sensor
    Kelvin = (((float(sensorValue) / 1023) * 5) * 100); // convert to
    Kelvin
    Celsius = Kelvin - 273.15; // convert to
    Celsius
    Fahrenheit = (Celsius * 1.8) +32; // convert to
    Fahrenheit
    }
    
    Enter the code and upload it to your Arduino. Once the code is running, open the serial monitor and make sure your baud rate is set to 9600. You will see the temperature displayed in both Fahrenheit and Celsius. The temperature may look incorrect to you. This is where the trimmer comes in; you must first calibrate your sensor. For proper calibration, you should be using a mixture of ice and water that has had time to stabilize at the temperature at which the ice melts. Place chopped or crushed ice in a Styrofoam cup (to limit outside influences) and either let it thaw until partially melted (in a fridge), or add some clean (ideally, distilled) water. The mixture should be at least 50 percent ice. Stir to mix well, and wait at least several minutes to make sure the water has had a chance to cool to the just freezing point. Then put the sensor (protected by a thin plastic bag with as little air as possible) in the water-ice slurry and wait until the reading stops changing. Then adjust the trimmer for a reading of 0°C. Now turn your trimmer or pot until the reading in the serial monitor shows the correct temperature. Your sensor is now calibrated. If you are using heat shrink tubing for the purpose of waterproofing the sensor, you should use a dual wall or filled-core heat type of heat-shrink tubing. You can remove the trimmer part of the circuit and it will run just fine. However, the temperature will be a close approximation, within 1°C. How the sensor works is not important (and is in fact pretty complicated) so I will simply look at how the code works for this project

    All Arduino tutorial available Click here

     ALL ARDUINO TUTORIAL