Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
27 views1 page

P1

This code summarizes an Arduino sketch that reads light intensity values from an LDR sensor connected to an analog pin and sends the readings to a ThingSpeak channel. The sketch connects to a WiFi network, initializes the ThingSpeak client, defines the channel number and write API key, then enters a loop to read the LDR sensor, print the values to serial, and update the ThingSpeak channel with the readings every second.

Uploaded by

Shivkumar Gorge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views1 page

P1

This code summarizes an Arduino sketch that reads light intensity values from an LDR sensor connected to an analog pin and sends the readings to a ThingSpeak channel. The sketch connects to a WiFi network, initializes the ThingSpeak client, defines the channel number and write API key, then enters a loop to read the LDR sensor, print the values to serial, and update the ThingSpeak channel with the readings every second.

Uploaded by

Shivkumar Gorge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <ESP8266WiFi.

h>;
#include <WiFiClient.h>;
#include <ThingSpeak.h>;

const char* ssid = "Asdf"; //Your Network SSID

const char* password = "asdf1234"; //Your Network Password

int val;

int LDRpin = A0; //LDR Pin Connected at A0 Pin

WiFiClient client;

unsigned long myChannelNumber = 912031; //Your Channel Number (Without Brackets)

const char * myWriteAPIKey = "9CNEIQUW0U3GGKO7"; //Your Write API Key

void setup()

Serial.begin(9600);

delay(10);

// Connect to WiFi network

WiFi.begin(ssid, password);

ThingSpeak.begin(client);

}
void loop()

val = analogRead(LDRpin); //Read Analog values and Store in val variable


Serial.println("/n");
Serial.print(val); //Print on Serial Monitor

delay(1000);

ThingSpeak.writeField(myChannelNumber, 1,val, myWriteAPIKey); //Update in


ThingSpeak
delay(100);

You might also like