Skip to content

IOT and Interaction

1. Dfinition of IOT

The Internet of Things (IoT) refers to a network of physical devices, vehicles, appliances, and other objects embedded with sensors, software, and connectivity, allowing them to collect and share data. This interconnectedness enables devices to communicate with each other and with cloud services, facilitating automation and data analysis. The term was first coined by Kevin Ashton in 1999, and it encompasses a wide range of applications, from smart home devices to industrial automation.

1

Platforms:ALiyun, AWS, AzureLOT etc

2. Arduino IOT Design

Click the here and add the devices.

3

Then select the device type.

4

Remember your device ID and Password.

5

Then, add the things.

6

After adding things, you need to add variables.

7

To add variable, fill the name and type.

8

FIll the float type.

9

Add the other three varables.

10

Associate the esp32 XIAO c3.

11

Then, set your newwork.

13

12

After adding them, the networking code was genrated.

14

Then, open the local Arduino IDE, pull the code to offline.

15

Set the hardware.

16

Vertify and upload the code.

17

The distance can be preview in the Arduino IDE.

2

The code is shown as follows:

bash
#include "DHT.h"
#define DHTPIN A1     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11   // DHT 11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println(F("DHTxx test!"));
  dht.begin();
}

void loop() {
  delay(2000);
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("°C "));
  Serial.print(f);
  Serial.println(F("°F"));
}