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

Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32

Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32 Hello Everyone! I have come up with new tutorial Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32 For Code & Circuit Diragram: In this video what you will learn about? 1. How to configure the new Blynk IoT Platform. 2. How to setup web dashboard 3. How to create template in blynk iot 4. How to interface ultrasonic sensor with node mcu esp8266. 5. How to read ultrasonic sensor with esp8266 1.You can Watch Playlist on New Blynk IoT Platfom New Blynk IoT platform with esp32 | how to setup automation in Blynk IoT app https://youtu.be/O2HZuu4KtIc 2.How to create events in blynk IoT platform | events in new Blynk IoT platform 🔥🔥 https://youtu.be/X5zVaGk8QV0 3.IoT Based smart garden monitoring system | Smart plant monitoring using Blynk IoT https://youtu.be/GTdxD5vQwy0 4.Water level monitoring system using IoT | IoT based...

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 }

DS18B20 Temperature sensor with new Blynk IOT Platform | DS18B20 with Esp32 & Blynk IoT Cloud

DS18B20 Temperature sensor with new Blynk IOT Platform | DS18B20 with Esp32 & Blynk IoT Cloud   Hello Everyone! I have come up with new tutorial based on the all new Blynk IoT platform. which is DS18B20 Temperature sensor with new Blynk IOT Platform | DS18B20 with Esp32 & Blynk IoT Cloud #iot #blynk In this video what you will learn about? 1. How to configure the new Blynk IoT Platform. 2. How to interface DS18B20 sensor with esp32 4. How to configure mobile blynk IoT platform 5. How to setup Automation in Blynk IoT 1.You can Watch Playlist on New Blynk IoT Platfom New Blynk IoT platform with esp32 | how to setup automation in Blynk IoT app | #iot #blynk #esp32 https://youtu.be/O2HZuu4KtIc 2.How to create events in blynk IoT platform | events in new Blynk IoT platform 🔥🔥 #blynk #esp32 #iot https://youtu.be/X5zVaGk8QV0 3.IoT Based smart garden monitoring system | Smart plant monitoring using Blynk IoT #iot #blynk #esp32 https://youtu.be/GTdxD5vQwy0 4.Wa...