ESP8266 Witty Cloud LDR + ArduinoIDE + Thingspeak = IoT Light Sensor

Values representing darkness. Daylight would be in the range 300-1000.

Here is a quick example on basic usage of ESP8266 Witty Cloud development board. The Witty Cloud board comes with ESP8266 accompanied by an RGB led, a button and a Light Dependant Resistor. There is also usb chips and connector for easy connectivity. This makes it a great IoT device to start with. Some inputs, some outputs and nice small form factor.

  1. Get ArduinoIDE with ESP8266 extensions, check ESP8266 on NodeMCU board + DS18B20 + ArduinoIDE + ThingSpeak
  2. Connect USB cable, set port and board details
  3. Get API-key
  4. Upload code
  5. Enjoy the graph online

More on Witty Cloud:

Example code in GitHub:

/*  ESP8266 LDR ArduinoIDE Thingspeak IoT Example code
 *  This sketch sends data via HTTP GET requests to of the value on
 *  LDR sensor on ESP8266 development board - Wittyboard. You need an api_key from Thingspeak.
 *  Based on:
 *  ESP8266 Witty:


const char* ssid = "VaasaHacklab";
const char* pass = "wifikey";

// RGB or button pins are not used in LDR example
#define RED_PIN      7   // RGB Light pin at Arduino pin 3
#define GREEN_PIN    8   // RGB Light pin at Arduino pin 5
#define BLUE_PIN     9   // RGB Light pin at Arduino pin 6
#define BUTTON_PIN   4   // button
#define LDR_PIN      A0

char host[] = "";
String path = "/update?key=" + ApiKey + "&field1=";

int ldr_value = 0;

void setup() {

  Serial.print("Connecting to ");

  WiFi.begin(ssid, pass);
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {

  Serial.print("Connected to ");
  Serial.print("IP address: ");

  pinMode(LDR_PIN, INPUT);


void loop() {
  ldr_value = analogRead(LDR_PIN); // read input value and store it
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
  client.print(String("GET ") + path + ldr_value + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: keep-alive\r\n\r\n");

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.