You are on page 1of 4

Rahulganth E N 21BEE0092

Date: 09.06.2023

Lab Assessment Name:Rahulganth E N

Experiment no: 2 Roll no: 21BEE0092

Internet of Things

Random Number Generation

Aim:

To generate random numbers using google colab and insert in thinkspeak IOT channel fields.

Requirements:

Google colab

Thinkspeak IOT

Code:

mport http.client as httplib


import urllib
import time
import random as rand
import thingspeak
channelID1=2134416
key1="9WXHVNOT1UF55XNX"

def MFM384(channel1):
vin=rand.randint(0,50)
i=rand.randint(0,50)
response1=channel1.update({'field1': vin, 'field2':i}) print(response1)
channel1 thingspeak.Channel(id=channelID1, api_key=key1)

while True:
MFM384(channel1)
Rahulganth E N 21BEE0092

Field:

RESULT:

The random Numbers are generated using google colab python code and inserted n the fields in
thinkspeak IOT.
Rahulganth E N 21BEE0092

MOISTURE DETECTER

AIM:

To find the moisture of the environment using moisture sensor with Arduino ide and Arduino esp8266.

Apparatus Required:

Bread board, Moisture sensor, USB, Arduino ide, esp8266

Code:

const int sensor_pin = A0;

void setup() {
Serial.begin(9600);
}

void loop() {
float moisture_percentage;
moisture_percentage=(100.00-((analogRead(sensor_pin)/1023.00)*100.00) );
Serial.print("Soil Moisture (in percentage) = ");
Serial.print(moisture_percentage);
Serial.print("\n");
delay(1000);
}
Rahulganth E N 21BEE0092

OUTPUT:

RESULT:

By using esp8266 module and moisture sensor the moisture of the room has been calculated.

You might also like