Skip to content

Thingsquare Lighting

Thingsquare Lighting

Thingsquare Lighting is a collection of modules that allow a Thingsquare system to quickly and efficiently implement scheduled and reactive lighting applications. Thingsquare Lighting provides prioritized lighting events, local control, multi-hop zoning, schedules, and offline operation.

Thingsquare Lighting supports prioritized simultaneous input from smart phone control, battery-driven PIR sensors and light switches, and schedules. A PIR sensor that detects movement may hence turn on the lights even when they are scheduled to be turned off. Similarly, a smart phone user may choose to dim those lights again.

Each network device may be assigned to a logical lighting zone. Zoning allows for simultaneous control of entire rooms or areas. The number of devices per zone is unlimited, and the zone devices does not necessarily need to be within reach of each other but may be spread out in the wireless network. Zone commands may be sent remotely via the backend server, or locally from a user in the same local area network. Local control ensures operation even if the Internet connection is down.

Battery-driven PIR sensors and light switches are implemented using regular Thingsquare network devices configured to run in lifetime mode. Whenever they detect movement, or when a user presses the light switch, the device broadcasts a zone message to all nearby devices. The zone message is then propagated to all zone devices within a few seconds. Such a message may for instance cause a given zone to dim up the lights for a few minutes.

Thingsquare Lighting supports scheduled operation. A schedule may for example instruct the lights to be turned on during normal working hours, and be dimmed during nights and weekends. Scheduled operation works even if the network is temporarily disconnected from the Internet and the backend server.

Thingsquare Lighting is enabled by calling the function thsq_lighting_init. By also initializing and attaching the GPIO module, Thingsquare Lighting is configured to control pins with PWM.

  /* Initialize the lighting module */
  thsq_lighting_init();

  /* Initialize the configurable GPIO module */
  thsq_gpio_init();

  /* Make the GPIO module listen to events from the lighting module. */
  thsq_gpio_attach_lighting();

  /* Restore lighting settings from before last reboot. */
  thsq_lighting_apply_last();