Lab 12 - more IoTempower and Integration
For all following tasks, use IoTempower's built in drivers (check Commands in documentation and setup.cpp ) to create your devices. You often find hints and wiring instructions already inside the Commands documentation.
1. (old lab 11-5) New Sensors
Attention: When attaching new actors or sensors to a microcontroller, disconnect the microcontroller from power first. If you destroy something due to violation of this rule, we will discuss some fair compensation (nothing is that expensive, but please use some diligence and discipline here). Most things use 3.3V, only wire things to 5V if explicitly stated by us (like below for the motor) - most sensors and devices in your kit will be destroyed if you wire them to 5V.
- Ultrasonic Distance Sensors. Connect the ultrasonic distance sensor to a Wemos D1 Mini, adjust its
setup.cpp
, and re-deploy or flash. Display its values on the Node-RED dashboard as a chart, slider, or gauge. Implement a filter in Node-RED to only show changes bigger than 2cm and add it into the flow before the chosen dashboard element. - RFID reader. Connect the RFID-RC522 RFID tag reader via SPI to a Wemos D1 Mini, adjust its
setup.cpp
and re-deploy or flash. Evaluate the UID of the tag in Node-RED (check at least two rfid tags). Based on the detected UID, turn a new button on the dashboard either red and displaying "Access Denied" or green and displaying "Access Granted". If you press the button, reset its color and make it display "Scan Tag". - Touch Sensor. This is a new task and can be based on this video demonstration.
- Build a touch sensor based on the analog port and an attached cable that uses a Node-RED flow to generate pressed and released messages on MQTT.
- Use the filter
filter_binarize
to achieve the same.
- Optional: Build the presented voltage divider and connect the capacitive moisture sensor. Use a text field in the dashboard to either show wet or dry based on the values from the moisture sensor (use a filter to do the cut off on the microcontroller as before).
- Also the Gas and Alcohol sensors should work this way - please be mindful about voltages (try 3V first, else go to 5V and use voltage divider if values too high) - please talk to us when unsure.
2. (old lab 11-6) New Actors
- Read up on PWM (for example here: https://learn.sparkfun.com/tutorials/pulse-width-modulation/all). Hook up a simple LED with resistor to a GPIO port of a Wemos D1 Mini. Adjust
setup.cpp
to use PWM on this GPIO port (re-deploy or flash). Use a slider in Node-RED to control the brightness (duty cycle) of the LED. - Replace the LED (and register) with a Buzzer. Annoy your neighbors moving the slider playing different tones (but not too long).
- Use the
rgb_single
IoTempower command to control the RGB led (use 3 resistors - one on each color phase). (rgb_single
uses 3 pwm drivers internally - if you are very curious, you can also define 3 pwm devices to achieve the same.) Use a color-picker in Node-RED to send a color value to the LED and consider using the dashboard on your phone for enjoying the effect to change color easily from the phone. - Use the
servo
command to control your motors. Send an angle value with a slider from Node-RED. One is a true motor and should pick the angle that you send, the other one should be a hacked servo where you select its speed with the angle value. The motors need 5V on their power input (please Google wiring of the SG90 servo first).
3. (old lab 11-7) Integration Task
Build an access control system using the RFID reader, the RGB-LED, the buzzer, and the true servo extending your task 5 re-using its dashboard. Show the access status on the RGB LED (red for access denied and green for access granted). When access is granted, turn the motor to another angle that signals open (make sure it turns back to its closed position after a short while). When access is denied play a short nasty sound on the buzzer.
Homework
Prepare your Project idea as a story.
- Recall the story-based modelling from lecture 9
- Write up the 1st draft of it in your GitLab repo sub-folder for the project (or link to teammate's repo subfolder).
Next lab we will discuss the stories. Note: you can make adjustments and refinements to it as you work on the project.