Supplier eBooks

Microchip - Concept to Creation

Issue link: https://resources.mouser.com/i/1442841

Contents of this Issue

Navigation

Page 9 of 31

10 / Concept to Creation: Practical Applications for Smart, Connected and Secure IoT Solutions 2. TEMT6000 Ambient Light Sensor: This sensor acts like an NPN transistor with the base terminal controlled by the exposure to light. It is configured in a common collector (CC) amplifier circuit topology to allow for subtle changes at the input to drive a larger output signal to the collector emitter (CE) junction going to the microcontroller ADC pin. The brighter the light, the more current and thus a higher voltage on the microcontroller ADC input pin. SOFTWARE In this section, we will detail the software involved in this project. This will include the firmware and support files necessary for the Microchip Technology Xplained board as well as the setup of the Medium One Sandbox in your web browser. The source code provided for this project can be edited using Atmel Studio 7 or the Arduino IDE depending on your preference. To use the Arduino IDE, Microchip Technology provides the needed files on their GitHub site. The following URL will need to be added to the following location in the Arduino IDE: File Preferences Additional Boards Manager URLs. The URL is linked here. The software for this project is divided across three parts. 1. Microcontroller firmware is written in C. 2. Cloud application to send and receive commands to/from the end users smartphone and the microcontroller. This code will be written in Python. 3. Smartphone application provided by Medium One and will be configured specifically for this project. Microchip Xplained Board Firmware The firmware that runs on the microcontroller board is straightforward. The code does the following, in this order: Setup 1. Establish a serial debug connection to the host computer at 9600 baud. 2. Attempt to connect the desired wireless network. 3. Connect to the MQTT broker. 4. Subscribe to the MQTT broker submit a topic for any messages sent from Medium One to the microcontroller. 5. Set the various I/O pins as inputs or outputs. Main Repeating Loop 6. Poll the MQTT server with a heartbeat message to remain connected. 7. Take a reading from the TEMT6000 ambient light sensor. 8. Determine if the system is in manual or automatic mode. 9. If in automatic mode, adjust the LED brightness by mapping the 0 to 1023 digitized brightness signal to a 255 to 0 value that will control the duty cycle of the PWM signal sent on the DIM pin. 10. If in manual control mode, adjust the LED brightness by mapping the 0 percent to 100 percent setpoint set by the user on their smartphone to a 255 to 0 value that will control the duty cycle of the PWM signal sent on the DIM pin. Medium One offers easy-to-use resources to create a basic smartphone app to interact with IoT devices. " "

Articles in this issue

Links on this page

view archives of Supplier eBooks - Microchip - Concept to Creation