This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:remotelab:itt:remotelights [2018/11/14 18:13] – rim.puks | en:iot-open:remotelab:itt:remotelights [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== RGB LED module ===== | + | ===== ITT RGB LED module ===== |
| This laboratory is located in the office of ITT Group in Tallinn, Estonia. | This laboratory is located in the office of ITT Group in Tallinn, Estonia. | ||
| ==== Introduction | ==== Introduction | ||
| - | This laboratory consists of a RGB LED module connected to the ITT IoT controller module. The module contains one RGB LED. This node can be used to create very basic MQTT systems but can also be used as a signaling | + | This laboratory consists of an RGB LED module connected to the ITT IoT controller module. The module contains one RGB LED. This node can be used to create very basic MQTT systems but can also be used as a signalling |
| - | {{: | + | |
| + | {{: | ||
| ==== Prerequisites ==== | ==== Prerequisites ==== | ||
| - | //Describe prerequisite readings, software, hardware (if any) - note - only those that apply to ALL scenarios, knowledge necessary to understand. I case single scenario requires some extra knowledge/ | + | General knowledge of MQTT protocol: topics, brokers, subscribe, publish. |
| ==== Technical details ==== | ==== Technical details ==== | ||
| - | //Provide technical details on the construction | + | This laboratory conisists |
| - | + | ||
| - | === Sensors === | + | |
| - | //Describe sensors (if any). Provide details on measured values, connection details, accuracy, protocols, its relation to the physical/ | + | |
| === Actuators === | === Actuators === | ||
| - | //Describe actuators, their impact on the physical/ | + | This laboratory |
| + | |||
| + | === Specifications === | ||
| + | |||
| + | * LED size: 5050 | ||
| + | * Colors: 16777216 | ||
| + | |||
| + | === Electrical connection === | ||
| + | |||
| + | Connected to port GPIO4. | ||
| === Software, libraries and externals === | === Software, libraries and externals === | ||
| - | //Provide a list of software, software | + | To control WS2812B RGB LED the following |
| + | * ITTIoT libary - used to program the controller module. | ||
| + | * Adafruit NeoPixel libary | ||
| === Communication === | === Communication === | ||
| - | //Describe communication if it is implemented and sealed (not intended | + | The user can connect |
| === Limits === | === Limits === | ||
| - | //Provide information about limits on usage, i.e. need for maintenance/ | + | At the same time, one user can program the controller. But all users connected to the Distancelab MQTT broker can control the RGB LED, assuming they use the topic described in the controller program. |
| ==== Hands-on labs ==== | ==== Hands-on labs ==== | ||
| - | //List study scenarios (hands-on labs), linking | + | |
| - | | + | === Example code === |
| - | | + | <code c> |
| - | | + | #include < |
| - | | + | #include < |
| - | Note, assume that more professional group automatically contains less professional ones. Note - use language and as appropriate to the target group, i.e.:// | + | #include < |
| - | < | + | |
| - | | + | #define PIN D2 |
| - | | + | |
| - | | + | // When we setup the NeoPixel library, we tell it how many pixels, |
| + | // and which pin to use to send signals. | ||
| + | // Note that for older NeoPixel strips you might need to change | ||
| + | // the third parameter--see the strandtest | ||
| + | // example for more information | ||
| + | Adafruit_NeoPixel pixels = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800); | ||
| + | |||
| + | // https:// | ||
| + | String getValue(String data, char separator, int index) | ||
| + | { | ||
| + | int found = 0; | ||
| + | int strIndex[] = {0, -1}; | ||
| + | int maxIndex = data.length()-1; | ||
| + | |||
| + | | ||
| + | { | ||
| + | if(data.charAt(i)==separator || i==maxIndex) | ||
| + | { | ||
| + | found++; | ||
| + | strIndex[0] = strIndex[1]+1; | ||
| + | strIndex[1] = (i == maxIndex) ? i+1 : i; | ||
| + | } | ||
| + | | ||
| + | |||
| + | | ||
| + | } | ||
| + | |||
| + | // Change RGB LED color | ||
| + | // mosquitto_pub -u test -P test -t " | ||
| + | void iot_received(String topic, String msg) | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | Serial.println(msg); | ||
| + | |||
| + | String r = getValue(msg,';', | ||
| + | String g = getValue(msg,';', | ||
| + | String b = getValue(msg,';', | ||
| + | |||
| + | Serial.print(" | ||
| + | Serial.println(r); | ||
| + | |||
| + | Serial.print(" | ||
| + | Serial.println(g); | ||
| + | |||
| + | Serial.print(" | ||
| + | Serial.println(b); | ||
| + | | ||
| + | pixels.setPixelColor(0, | ||
| + | |||
| + | | ||
| + | } | ||
| + | |||
| + | void iot_connected() | ||
| + | { | ||
| + | | ||
| + | | ||
| + | iot.log(" | ||
| + | } | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | Serial.begin(115200); | ||
| + | Serial.println(" | ||
| + | |||
| + | iot.printConfig(); | ||
| + | iot.setup(); | ||
| + | |||
| + | pixels.begin(); | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | iot.handle(); | ||
| + | delay(200); | ||
| + | } | ||
| </ | </ | ||
| + | |||
| ==== Support ==== | ==== Support ==== | ||
| - | //Give some information on how to access help, how to get support in case of the trouble etc.// | + | info@ittgroup.ee |