Skip to content
→
Skip to footer
→
Skip to search
→
Connect with
Confidence
English
Deutsch
Español
Français
中文
Blog
Sign In
How to Buy
Contact Us
Search
Popular Searches:
XCTU
XBee
AnywhereUSB
Industrial Routers
Drivers & Firmware
Solutions
Solutions Home
By Industry
Education
Energy
Industrial
Medical
Retail
Smart Cities
Transportation
All Industries
By Application
Asset and Inventory Management
Digital Signage
Environmental Monitoring
Green Technology
Public Safety and Emergency Services
Public Transit
Traffic Management
All Applications
Packaged Solutions
Digi 360
Digi LifeCycle Assurance
Managed Services
Opengear OOB Solutions
SmartSense Monitoring Solutions
Ventus Managed Network Solutions
Technologies
Technologies Home
DAL OS
Digi Accelerated Linux operating system delivers sophisticated device functionality.
Digi SureLink
Persistent network connections ensuring rapid, always-on communications.
Digi TrustFence
Integrated IoT device security framework, device identity and data privacy.
Featured Technologies
4G LTE Cellular
5G Connectivity
Bluetooth
Cellular Failover
Edge Computing
FIPS 140-2
FirstNet
Fixed Wireless Access
Gigabit-Class LTE
LoRaWAN
Out-of-Band Management
Private Networks
SD-WAN
USB Over IP
Voice Control
Zigbee Wireless Mesh
All Technologies >
Products
Products Home
Embedded Systems
Digi XBee
Digi XBee Home
Cellular Modems
LoRaWAN
RF Modules
Gateways
Development Kits
Software and Tools
XBee Studio
XCTU
Cellular Data Plans
Digi ConnectCore
Digi ConnectCore Home
System-on-Modules
Single Board Computers
Development Kits
Software and Tools
Cloud Services
Security Services
Cellular and Networking
Cellular Routers and Endpoints
Cellular Routers and Endpoints Home
Enterprise Routers
Industrial Routers
Transportation Routers
Software and Tools
Digi Remote Manager
Digi Containers
Digi Mobile VPN
Digi WAN Bonding
Digi 360
Infrastructure Management
Infrastructure Management Home
Industrial Automation
USB Connectivity
Serial Connectivity
Console Servers
Software and Tools
Digi Navigator
Digi Remote Manager
Digi Axess
Digi LifeCycle Assurance
Professional Services
Managed Connectivity Services
Implementation Services
Application Development
Wireless Design Services
Resources
Resources Home
Resource Library
Datasheets
Ebooks
Solution Briefs
Technical Briefs
Videos
White Papers
All Library Resources
Customer Stories
Events
Examples and Guides
IoT Terminology
Digi Logos and Photos
Product Certifications
Project Gallery
Security Center
Webinars
More Videos
Support
Support Home
Technical Support
Select your product for firmware, drivers, software, knowledge base articles and manuals.
Select Your Product
Customer Portal
Product Certifications
Professional Services
Security Center
Support Forum
Support Services
Company
Company Home
About Digi
Awards and Recognition
Careers
Investor Relations
Leadership
Locations
Media Coverage
Press Releases
Partners
Partner Portal Login
Network Operators
Technology Alliances
Value-Added Resellers
Opengear, A Digi Company
Smart Out-of-Band Management
Visit Opengear
SmartSense by Digi
Sensing-as-a-Service Solutions
Visit SmartSense
Ventus, A Digi Company
Managed Network-as-a-Service (MNaaS)
Visit Ventus
Blog
Sign In
How to Buy
Home
/
Resources
/
Examples & Guides
/
Light Sensor Example: XBee Zigbee Cloud Kit
Resources
Customer Stories
Events
IoT Terminology
Certifications
Project Gallery
Resource Library
Security Center
Videos
Webinars
Light Sensor Example: XBee Zigbee Cloud Kit
Share
Share
Tweet
Table of Contents
Introduction
Assemble the Parts
Configure the Radio
Wire up the Circuit
View it!
Use it!
1) Introduction
In this example you will learn to use a photocell light sensor with the XBee Zigbee Gateway to sense and take action based on the amount of available light. You use light to tell if it’s day or night of course, but you can also determine if a cabinet is open or closed, or if someone is currently occupying a hotel room. Because light changes at the speed...well of light, it's a great sensor to use when want to prototype using changes that happen instantaneously rather than only over a longer period of time. Best of all, these sensors are cheap—at about a dollar a piece, they’re a great component to use when deploying sensors in large multiples. The resistance across the two leads of the cell varies according to the amount of light hitting the cell. With our circuit, the brighter it is, the lower the voltage that is passed to the XBee's analog-to-digital converter (ADC). This reading is then sent via
Device Cloud
to the XBee Zigbee Cloud Kit's online dashboard application. Now you can monitor the brightness from anywhere right in your web browser.
2) Assemble the Parts
To hook up a light sensor you'll need:
XBee Zigbee Cloud Kit*
1 -
photocell
- for sensing light (
data sheet
)
3 -
10K ohm resistors
Jumper wires
*...or a
powered
XBee Zigbee with
breadboard
and
jumper wires
.
3) Configure the Radio
You'll configure the radio using your free Device Cloud account. (Note that radios can also be configured using
XCTU
.)
NOTE: If your radio was recently configured by the XBee Zigbee Cloud Kit then the sampling rate and pin settings are already set. You can safely skip these steps.
Log in to
Device Cloud
.
Select Devices under the Device Management tab.
Select the XBee Zigbee that you are configuring, then select Properties or double-click to open the Properties window for that device.
Select Configurations, then Input and Output Settings, then confirm that DIO1/AD1/SPI_ATTN is set to Analog Input.
On the same page, confirm that Sample Rate is set to 5000 ms which will take a sample every five seconds.
Save your changes!
4) Wire up the Circuit
You will build this sensor circuit using the XBee Development Board.
Plug in the three 10K ohm resistors to separate rows of the
breadboard
as shown. They will form a chain with the each resistor connecting to one end of each resistor on either side. These scale the input down from 3.3 volt input to near the 2.5 volt maximum of the XBee Zigbee's ADC.
Connect a red jumper wire from the open end of the first resistor to 3.3 volts power.
Connect one end of a yellow (or any other color) jumper wire to the open end of the third resistor. Connect the other end of this wire to to the XBee's AD1 pin.
Plug in the photocell so that one leg connects to the same junction row as the yellow wire and third resistor. The other leg can go into an unused row. (A photoresistor doesn't have any polarity, its orientation doesn't matter.)
Connect a black jumper wire from the open leg of the photocell to ground (GND) as shown.
Set the DIP switch for AD1 on the PCB to OFF to disconnect the soldered-on component.
Here's what everything should look like:
5) View It!
You will use the XBee Zigbee Cloud Kit's web application to configure a widget for viewing the light readings from your sensor:
https://xbeegateway.herokuapp.com/#/login
Log in to the XBee Zigbee Cloud Kit web application.
Use the Add Widget button to create a new display widget.
Choose Gauge Widget for the widget type.
Add a label such as "
Light
."
Choose your XBee Zigbee device by its ID.
Select ADC1 as the input stream and check the device configuration to make sure it is configured properly.
Enter "
100-(value/1000*100)
" to transform the input from millivolts to a simple percentage from 0 to 100. The calculation takes the input value, scales to a decimal, then multiplies by 100 to get a percentage value. Since is technically the percentage of darkness we subtract it from 100 to flip it to the percentage of brightness.
Add a name for Units such as "
percent
."
Set a low value of 0 and a high of 100 to see the percentage light range displayed.
Save the changes to see your new Widget.
6) Use it!
The light level is now being transmitted from your XBee Gateway! Place it in some sunshine and see if you get the widget to show 100% as the sensor saturates with brightness. Cover it with a box to see it go towards 0%. You can also add a graph widget to examine the brightness data over time. See if you can sense cloudy periods, or watch the sunset data in real time. You can also run your setup from a battery pack and place it in your refrigerator. When the door is closed, does the light really go out? You might want to try setting up an Alarm in Device Cloud to alert you to late-night snackers. There are many different light sensors available, all with different ranges and response characteristics. Most light sensors will generate data that changes very quickly.
Tags:
XBee