Skip to main content

Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad

  Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad Circuit diagram: Arduino Sketch: // C++ code // int moisture_data = 0; void setup() {   pinMode(A0, INPUT);   Serial.begin(9600);   pinMode(12, OUTPUT);   pinMode(6, OUTPUT); } void loop() {   moisture_data = analogRead(A0);   Serial.println(moisture_data);   if (moisture_data < 21) {     digitalWrite(12, HIGH);     digitalWrite(6, HIGH);   } else {     digitalWrite(12, LOW);     digitalWrite(6, LOW);   }   delay(10); // Delay a little bit to improve simulation performance }

IoT based Liquid level Monitoring using ESP32 board and Qubitro IoT Portal

 IoT based Liquid level Monitoring using ESP32 board and Qubitro IoT Portal


Hello Everyone! IoT based Liquid level Monitoring using ESP32 board and Qubitro IoT Portal In this video what you will learn about? 1. How to configure the new Qubitro Iot Platform. 2. How to Create new project on Qubitro IoT Platform. 4. How to Create Dashboard for Monitoring data. 5. How to Interface the Ultrasonic sensor with ESP32. 6. How to do the programming for the ESP32. #Qubitro #IoT




Circuit Diagram:













Code:

[Note :you need to install the QubitroMqttClient.h  library]

you can download the library click here Download

#include <QubitroMqttClient.h>

#include <WiFi.h>

#define trig 5   // Trig pin

#define echo 18

 int duration;

 int distance;

// WiFi Client

WiFiClient wifiClient;


// Qubitro Client

QubitroMqttClient mqttClient(wifiClient);


// Device Parameters

char deviceID[] = "5060befb-5aec-4777-b247-4c11ce884a54";

char deviceToken[] = "IeqcXR0zhmhHpbmf-mt8t1w$9FAg3-gutaMd-0$J";


// WiFi Parameters

const char* ssid = "impulsetech";

const char* password = "impulse567";


void setup() {

  // Initialize the serial port

  serial_init();

  

  // Initialize wireless connectivity

  wifi_init();


  // Initialize Qubitro

  qubitro_init();

  pinMode(trig, OUTPUT);

  pinMode(echo, INPUT);

}


void loop() {


  digitalWrite(trig, LOW); 

  delayMicroseconds(2);

  digitalWrite(trig, HIGH); 

  delayMicroseconds(10);

  digitalWrite(trig, LOW);

  duration = pulseIn(echo, HIGH);

  distance= duration*0.034/2;

  //Serial.println(distance);

  delay(100);

  // Generate random values

  int sensor_value_1 = distance;

  int sensor_value_2 = random(0, 100);


  // Print the random values

  Serial.print("Sensor value 1: ");

  Serial.println(sensor_value_1);

  Serial.print("Sensor value 2: ");

  Serial.println(sensor_value_2);


  // Send telemetry

  String payload = "{\"Sensor 1\":" + String(sensor_value_1)

    + ",\"Sensor 2\":" + String(sensor_value_2) + "}";

  mqttClient.poll();

  mqttClient.beginMessage(deviceID);

  mqttClient.print(payload);

  mqttClient.endMessage();


  // Delay

  delay(2000);

}


// Initialization code


void serial_init() {

  // Initiate serial port connection

  Serial.begin(115200);


  // Delay for stabilization

  delay(200);

}


void wifi_init() {

  // Set WiFi mode

  WiFi.mode(WIFI_STA);


  // Disconnect WiFi

  WiFi.disconnect();

  delay(100);


  // Initiate WiFi connection

  WiFi.begin(ssid, password);


  // Print connectivity status to the terminal

  Serial.print("Connecting to WiFi...");

  while(true)

  {

    delay(1000);

    Serial.print(".");

    if (WiFi.status() == WL_CONNECTED)

    {

      Serial.println("");

      Serial.println("WiFi Connected.");

      Serial.print("Local IP: ");

      Serial.println(WiFi.localIP());

      Serial.print("RSSI: ");

      Serial.println(WiFi.RSSI());

      break;

    }

  }

}


void qubitro_init() {

  char host[] = "broker.qubitro.com";

  int port = 1883;

  mqttClient.setId(deviceID);

  mqttClient.setDeviceIdToken(deviceID, deviceToken);

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

  if (!mqttClient.connect(host, port))

  {

    Serial.print("Connection failed. Error code: ");

    Serial.println(mqttClient.connectError());

    Serial.println("Visit docs.qubitro.com or create a new issue on github.com/qubitro");

  }

  Serial.println("Connected to Qubitro.");

  mqttClient.subscribe(deviceID);

}


Comments

Popular posts from this blog

Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad

  Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad Circuit diagram: Arduino Sketch: // C++ code // int moisture_data = 0; void setup() {   pinMode(A0, INPUT);   Serial.begin(9600);   pinMode(12, OUTPUT);   pinMode(6, OUTPUT); } void loop() {   moisture_data = analogRead(A0);   Serial.println(moisture_data);   if (moisture_data < 21) {     digitalWrite(12, HIGH);     digitalWrite(6, HIGH);   } else {     digitalWrite(12, LOW);     digitalWrite(6, LOW);   }   delay(10); // Delay a little bit to improve simulation performance }

Getting Started with the Arduino IoT Cloud using Esp32 & DHT-11

  Getting Started with the Arduino IoT Cloud using Esp32 Introduction: The Internet of Things has given rise to plenty of exciting new projects for makers. It's both interesting and practical to be able to develop remote sensors and gadgets. Allowing IoT devices from multiple manufacturers to interact with your innovations will open up a lot of possibilities, including some you might not have considered before. In this getting started guide of Arduino IOT cloud we will learn about how to use Arduino IOT cloud with Esp32 board. Arduino IOT cloud What is Arduino IOT cloud? Arduino IoT Cloud is a web-based service that allows users to create connected devices quickly, easily, and securely. Multiple devices can be linked together and data can be exchanged in real-time. Users can also able to monitor the data using a simple user interface from anywhere. one can also use the android application for monitoring and controlling the devices. Because Arduin...

Interfacing of TMP36 Temperature Sensor with an Arduino in Tinkerad.

  Interfacing of TMP36 Temperature Sensor with an Arduino in Tinkerad. This project will turn the Arduino into a thermometer! By using the tmp36 temperature sensor. We can able to measure our body temperature and turn on the 3 LEDs. Green LED indicates the low-temperature range, Yellow LED indicates the medium temperature range and Red LED indicates the high-temperature range. One can test the circuit starting the simulation, clicking on the sensor, then adjusting its temperature value using the slider, and can test the desired resulting LED patterns. For making the actual circuit, you need to use the Arduino, breadboard, USB cable, male-female jumper wires, three LEDs, three resistors (any value from 100-1K, 220 ohms), a TMP36 sensor,   Circuit Diagram:   Components Required: §   Arduino UNO §   TMP36 (Temperature sensor) §   Resistor-03 §   LED – Green §   LED – Yellow § ...