Circuit and Arduino code

The FLORA, FLORA BLE module, and FLORA light sensor are wired up as pictured:

Required Arduino libraries:

Download and unzip the following file, then open up light-logging-hat.ino in your Arduino IDE:

The main loop of the code reads the light sensor and sends the value out over the bluetooth connection:

Download: file
void loop(void)
{
   /* Get a new sensor event */ 
  sensors_event_t event;
  tsl.getEvent(&event);
 
  /* Display the results (light is measured in lux) */
  if (event.light)
  {
    ble.println(event.light);
  }
  else
  {
    /* If event.light = 0 lux the sensor is probably saturated
       and no reliable data could be generated! */
    Serial.println("Sensor overload");
  }
  
  delay(1000);

}
This guide was first published on Sep 30, 2015. It was last updated on Sep 30, 2015. This page (Circuit and Arduino code) was last updated on Jul 16, 2019.