Internet of Things
TinkerforgeCode in ActionAbout Me
  • Course Outline
  • 1 - Getting Started
    • Overview
    • Connect to the LED
    • Getting Started
      • Glitch
      • The Application Template
    • Concepts in Programming
      • What is Programming?
      • Variables
      • Functions and Commands
      • Control Structures
      • Loops
      • Objects and Libraries
    • Programming Simple Web Apps
    • Exercises
      • 1.1 Buttons and Inputs
  • 2 - Internet of Things
    • Overview
    • IoT in our Apps
      • Getting Started
        • Hardware Kit
        • Brick Viewer and Daemon
      • Connect to the Devices
        • The Tinkerforge Device Manager
      • Program the Devices
        • RGB LED
        • RGB LED Button
        • OLED Display
        • Sensors
          • Humidity Sensor
          • Ambient Light Sensor
    • Components and Use Cases
    • Exercises
      • 2.1 Lights and Buttons
      • 2.2 Sensors
      • 2.3 Display
  • 3 - Artificial Intelligence
    • Overview
    • AI in our Apps
      • Google's Teachable Machine
      • Face Recognition
      • Training a Custom Model
    • Rules vs. Learning
    • Learning from Data
    • Use Cases
      • Computer Vision
        • Image Classification
        • Handwriting Recognition
    • Machine Learning Algorithms
      • Artificial Neural Networks
      • Decision Trees
      • Logistic Regression
    • Exercises
      • 3.1 Rules vs. Learning
      • 3.2 Fruits and Vegetables
      • 3.3 Face Recognition
      • 3.4 A Classifier for Iris
  • 4 - Cloud & APIs
    • Overview
    • APIs in our Apps
    • Cloud and APIs
      • Weather API
      • NASA Open APIs
      • EDAMAM Nutrition and Recipes API
    • Push Notifications
    • Exercises
  • 5 - App Project
    • Overview
    • Summer 2021
    • Summer 2022
  • Appendix
    • Other Devices
      • Motorized Linear Poti
      • Sound Pressure Sensor
      • NFC Reader
      • Motion Detector
    • UI Features
      • Realtime Charts
      • Countdown Timer
    • Digital Computers
      • Overview
      • The Binary System
      • Code Systems
      • Logic Gates
      • Binary Addition
      • From Analog to Digital
    • Cheat Sheets
    • Projects
      • IoT @ Pickup-Boxes
Powered by GitBook
On this page
  • a) Display a welcome message
  • b) Display and update sensor values
  • c) Control the heat with the hardware button
  • d) Temperature visualized

Was this helpful?

  1. 2 - Internet of Things
  2. Exercises

2.3 Display

This exercise extends our app's capabilities with a 128x64 display.

Previous2.2 SensorsNextOverview

Last updated 4 years ago

Was this helpful?

a) Display a welcome message

Welcome any new users to your application and show a welcome message on the OLED display on startup of your app.

Possible solution:

b) Display and update sensor values

After 5 seconds, remove the welcome message from a) and reserve the first two rows to display the temperature and humidity. Update the values in an appropriate interval. Make sure you format the values so that they are readable and include units of measurements.

You can use the toFixed() function to truncate a decimal value to any number of decimal digits.

Possible solution:

c) Control the heat with the hardware button

Imagine a user of your app should be able to perform 3 different actions using the hardware devices. The actions are:

  • Turn down heat

  • Turn up heat

Improve your app's version from b) and reserve the lines 4 and 5 to display each action in a separate row. Indicate by a small arrow ">" that the first option is initially active. The user should now be able to navigate through the different options by pressing and releasing the hardware button. With every button press, the ">" should move to the next action, and when the last one is active, start over at the beginning.

To perform an action, the user should press and hold the hardware button for at least half a second. To simulate the status of the heat and its current level, reserve line 7 to display a number of symbols (for example a pipe: |) to indicate the current heat level in 10 discrete steps.

To measure how much time elapsed between the button being pressed and released, you can assign a variable with the current date when the button is pressed, and another when the button is released. The difference between both values will be the elapsed time in milliseconds:

var startTime = new Date();
...
var endTime = new Date();
var elapsed = startTime - endTime // time in ms

Possible solution:

d) Temperature visualized

Visualize the temperature on the display. Create a character-based visualization every 5 seconds and use for displaying the temperature. Move the visualization from left to right with every new value, so the user can see a snapshot of the temperature's history.

See if you can find a suitable character for the visualization. Maybe a pipe will do?: |

Possible solution:

Exercise 2.3 - Display | a) Display a welcome message
Exercise 2.3 - Display | b) Display and update sensor values
Exercise 2.3 - Display | c) Control the heat with the hardware button
Exercise 2.3 - Display | d) Temperature visualized
A simple data visualization with pipe symbols.