# SN087 Wireless Lighting Controller¶

The SN087 is a California Title 24 compliant lighting controller that provides for the remote, wireless control of lighting for both indoor and outdoor commercial applications. Powered by compatible LED drivers, its compact design and flexible deployment options make it ideal for placement in a wide array of fixtures.

In This Section

At the core of the SN087 is an SM220UF1 module. SNAPpy scripts and firmware can be uploaded to the module using SNAPtoolbelt or Portal.

## Pin Mappings¶

The SN087 has a dimming output that can control lighting dimmers using PWM or 0-10V analog voltage. The pins used to control this output as well as the onboard LEDs are:

Name SM220 Series Pad SNAPpy IO Description
LVLA D1 5 Controls the analog voltage of the output signal
PWMA D3 7 Controls the PWM waveform of the output signal
BOOST_EN C5 23 Enables the 3v3-to-12v output signal boost converter
LED_GREEN F1 0 Controls the on-board green LED
LED_RED F2 9 Controls the on-board red LED

The SN087 is also able to verify certain voltages at different points on the board using the SM220UF1’s ADC pins. A self-test function is provided in the example script to verify correct voltages. The ADC channels and voltage divider ratios can be used to read these voltages manually as well:

+3v3 2 243/575 0.0036972737
+12v (from boost) 0 211/1871 0.0138551540
DIM Output (0-10v) 1 211/1871 0.0138551540

These voltage measurements can be used to verify hardware and software functionality. See the example script below for a sample “self-test” function.

## Example Script¶

In order to make getting started with the SN087 as easy as possible, we’ve provided an example script on GitHub that enables a number of useful lighting functions:

• Getting and setting the dim level
• Setting and checking a virtual “Group ID” to control multiple lights at once
• Controlling the on-board LEDs
• Designating a “no communication” timeout to reset the dim level to a default level
• Running a hardware “self-test” that verifies voltages at certain points in the device

Unmodified, the script will set the dim level to 80% on startup, and will return to this default dim level if the keep-alive timer expires. Calling the set_dim_level(), group_dim_level(), or reset_keep_alive() functions will reset the timer. While the keep-alive timer is still active, the on-board LED will remain green, but once it expires, the LED will turn red. The keep-alive timer defaults to 15 minutes, but can be changed by modifying the NO_COMMUNICATION_TIMEOUT value (measured in seconds). The default dim level can be changed by modifying the DEFAULT_DIM_LEVEL value.

The script also contains the concept of a “group” ID, that allows you to put multiple lights in a group that can be controlled simultaneously using multicast RPCs. Each light can only belong to one user-defined group as set by the set_group() function, but all lights also belong to the wildcard group (0xFFFF).

When the dim level for a light is set, the light will smoothly fade to the set level. The speed at which the light fades up or down is set by the DIM_RAMP_SPEED value. Increasing this value will cause the light to dim more slowly, while decreasing it will cause the light to dim more slowly.

The available callable functions are described below.

### set_dim_level(level)¶

Sets the dim level from 0%-100% by providing a level value between 0 and 100. Without modification, the script will dim from 0-10V using the LVLA analog voltage control instead of the PWMA pulse-width control.

Calling this function will reset the keep-alive timer.

### get_dim_level()¶

Get the dim level from 0%-100% as an integer.

### group_dim_level(group, level)¶

Set the dim level for this light if the group parameter matches the light’s group. This is handy for controlling many lights at a time with multicast messages.

If the group parameter is set to 0xFFFF (the “wildcard” group), this function will change the dim level of this light, regardless of the light’s group.

Calling this function will reset the keep-alive timer if the group parameters matches this light’s group or is the wildcard group (0xFFFF).

### set_group(group)¶

Set the group that this light belongs to, where group can be 0x0000-0xFFFF.

### is_my_group(group)¶

Helper function to determine if this light belongs to the group parameter provided. It is used by the group_dim_level() function.

Returns True if this light’s group matches the group parameter, or if the group parameter is set to the wildcard group (0xFFFF). Returns False otherwise.

### led_green()¶

Helper function that turns the red on-board LED off and turns on the green on-board LED. This indicates that the keep-alive timer is still active.

### led_red()¶

Helper function that turns the green on-board LED off and turns on the red on-board LED. This indicates that the keep-alive timer has expired and the light has returned to the default dim level.

### reset_keep_alive()¶

Resets the keep-alive timer. Setting the dim level via set_dim_level() or group_dim_level() automatically resets the keep-alive timer using this function, but can be manually reset if needed.

### sts_get_dim_level()¶

A callable function that takes no arguments and returns a string. This function is very similar to get_dim_level() except that it returns a string so that it can be used for data collection.

### run_self_test()¶

This function runs a hardware self-test that measures the voltages on the +3v3, +12v, and dim level output. It verifies that each voltage is within 10% of the expected value, and loops through a set number of dim level settings.

Returns True if the self-test passes, and False otherwise. It will also print the particular error to STDOUT on failure.

Resources for the SN087:

Resource Description MD5
SN087 3D model STEP file 52be524d3515d373539bab588fb846bb
SN087 Data Sheet Mechanical Data Sheet c5377100168e4ee85ce850d29eaff651