{"id":29228,"date":"2022-06-30T12:59:55","date_gmt":"2022-06-30T19:59:55","guid":{"rendered":"https:\/\/digilent.com\/blog\/?p=29228"},"modified":"2022-06-30T12:59:55","modified_gmt":"2022-06-30T19:59:55","slug":"build-a-smart-lamp-using-an-analog-discovery-pro-adp3450-part-1","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/build-a-smart-lamp-using-an-analog-discovery-pro-adp3450-part-1\/","title":{"rendered":"Build a Smart Lamp Using an Analog Discovery Pro ADP3450 &#8211; Part 1"},"content":{"rendered":"<p>This is the first part of a series of four blog posts where we will design a smart RGB-lamp which is powered by a battery and controlled through an app running on a smartphone. Lamp and smartphone communicate through Bluetooth Low Energy (BLE). Besides setting the luminosity and the color of the LED, the system also measures the ambient lighting, so users can switch off the light once it is no longer needed. Or do that even automatically, if needed.<\/p>\n<p>Digilent\u2019s Analog Discovery Pro <a href=\"https:\/\/digilent.com\/reference\/test-and-measurement\/analog-discovery-pro-3x50\/start\">ADP3450<\/a> running in Linux Mode is at the heart of the system: it collects the data from a <a href=\"https:\/\/digilent.com\/reference\/pmod\/pmodals\/start\">Pmod ALS<\/a>\u00a0ambient light sensor and receives the settings from the smartphone\u2019s app through a <a href=\"https:\/\/digilent.com\/reference\/pmod\/pmodble\/start\">Pmod BLE<\/a>. It also applies the brightness and color of the LED based on these data sets or switches the on\/off state.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/06\/smartlamp1-600x331.jpg\" alt=\"\" width=\"600\" height=\"331\" class=\"aligncenter size-medium wp-image-29229\" data-wp-pid=\"29229\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/06\/smartlamp1-600x331.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/06\/smartlamp1-1024x565.jpg 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/06\/smartlamp1-1536x847.jpg 1536w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/06\/smartlamp1.jpg 1920w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<h2>Getting a HAL for the Analog Discovery Pro<\/h2>\n<p>In our project, we control the Analog Discovery Pro (ADP) through the <a href=\"https:\/\/digilent.com\/reference\/software\/waveforms\/waveforms-sdk\/start\">WaveForms SDK<\/a> with a Python script. For this, we need several functions for each of the instruments, like read, write, and initialization and control functions. Communication over SPI (Serial Peripheral Interface) and UART (Universal Asynchronous Receiver-Transmitter) is also necessary. This means that we require some sort of abstraction to simplify the interaction with the hardware: a Hardware Abstraction Layer (HAL).<\/p>\n<p>There are two ways to get the HAL functions for our project: One way is that you follow the directions given in the Getting Started with WaveForms SDK guide. The other way is that you download them from <a href=\"https:\/\/github.com\/Digilent\/WaveForms-SDK-Getting-Started-PY\/tree\/master\/WF_SDK\">Digilent\u2019s GitHub repository<\/a>. There, you will also find a list of the functionality each module provides and a couple of test routines.<\/p>\n<p>Once you created or downloaded the HAL functions for the SDK, create a new folder and copy the files into it. Also, duplicate the file dwfconstants.py from the Python examples folder of your WaveForms installation into the new directory. The default installation path is <em>C:\\Program Files (x86)\\Digilent\\WaveFormsSDK\\samples\\py\\dwfconstants.py<\/em>. This file contains all the constants used by the SDK.<\/p>\n<p>Now that you have created or copied the HAL functions, you are done with this part of the blog post series. In the next installment, we\u2019ll talk about the library for the Pmods, testing their functionality, and generating the Android app.<a href=\"#_ftnref1\" name=\"_ftn1\"><span><\/span><\/a><span><a href=\"https:\/\/digilent.com\/reference\/pmod\/pmodble\/start#-1\"><\/a><\/span><\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-29228 jlk' data-task='like' data-post_id='29228' data-nonce='d8c4d58d14' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-29228 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-29228 jlk' data-task='unlike' data-post_id='29228' data-nonce='d8c4d58d14' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-29228 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-29228 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>This is the first part of a series of four blog posts where we will design a smart RGB-lamp which is powered by a battery and controlled through an app &hellip; <\/p>\n","protected":false},"author":61,"featured_media":29229,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4327,4312,4267,1563],"tags":[4352,4353,3899],"ppma_author":[4506],"class_list":["post-29228","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","category-usb-scopes-analyzers-generators","category-featured","category-guide","tag-adp3450","tag-linux","tag-test-and-measurement"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/06\/smartlamp1.jpg","jetpack_sharing_enabled":true,"authors":[{"term_id":4506,"user_id":61,"is_guest":0,"slug":"richardoed","display_name":"Richard Oed","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/12de1ad12c6f52d1668873102baa76018ec3d4f2078318739209f4b75051c424?s=96&d=mm&r=g","1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":"","9":"","10":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/29228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/61"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=29228"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/29228\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/29229"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=29228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=29228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=29228"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=29228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}