Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:remotelab:itt:remotelights [2018/11/14 18:08] rim.puksen: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  ====
-//Here provide some general idea of the laboratoryDo not use very complicated phrasesIt is to be understood by people with limited understanding of the technology. Photos, schematic and drawings may be attached as well+This laboratory consists of an RGB LED module connected to the ITT IoT controller moduleThe module contains one RGB LEDThis node can be used to create very basic MQTT systems but can also be used as a signalling part of other more complicated systems
-Write objectives for the laboratory i.e. "its purpose is to model ...." or "simulate", or simply to "practice". Write some objectives. Provide a link to the live video stream (if any).//+ 
 +{{:en:iot_homelab_kit:hardware:led2.png?200 |}}
  
 ==== Prerequisites ==== ==== Prerequisites ====
-//Describe prerequisite readingssoftware, hardware (if any) - note - only those that apply to ALL scenarios, knowledge necessary to understand. I case single scenario requires some extra knowledge/prerequisitesprovide it with scenario documentnot here.//+General knowledge of MQTT protocol: topicsbrokerssubscribepublish.
  
 ==== Technical details ==== ==== Technical details ====
-//Provide technical details on the construction of the laboratory, both hardware, and software. Use technical words and sentences. It is to be understood by technology-related people. Consider it as kind of laboratory hardware and eventually software implementation. Sections below (remove section if not present) present details. Provide circuit, essential mechanical schema, if necessary to use the laboratory and understand its physics/mechanics, etc.// +This laboratory conisists of a ITT IoT controller module connected to a RGB LED module.
- +
-=== Sensors === +
-//Describe sensors (if any). Provide details on measured values, connection details, accuracy, protocols, its relation to the physical/mechanical part of the laboratory (if any). Add photos and schematics, where the sensor is located. In case the sensor is virtual, do not expose it - present as physical until it is essential to know it regarding study (i.e. code implementation, timings, etc.). Provide links to external resources regarding i.e. necessary libraries, protocol definition, etc.//+
  
 === Actuators === === Actuators ===
-//Describe actuators, their impact on the physical/mechanical part of the laboratory device, limits, connections, etcAdd photos and schematics, where the actuator is located. In case actuator is virtual, do not expose it - present as physical until it is essential to know it regarding study (i.e. code implementationtimingsetc.). Provide links to external resources regarding i.e. necessary libraries, protocol definition, etc.//+This laboratory involves a WS2812B RGB LEDRGB LEDs are basically three LEDs (redgreenbluethat are built inside one shellThey include a WS2812 driver that makes it possible to use only one pin to control them. 
 + 
 +=== 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 libraries and external resources (i.e. files) necessary during code development. Please note, write here only common for all hands-on-labs scenarios (there is a relevant section in scenario template. Remove this section if empty.//+To control WS2812B RGB LED the following libraries are used: 
 +  * ITTIoT libary - used to program the controller module. 
 +  * Adafruit NeoPixel libary used to control the RGB LED.
  
 === Communication === === Communication ===
-//Describe communication if it is implemented and sealed (not intended to be implemented by students, or provided i.e. as default code). Present data flow. Describe protocols and details i.e. key-value pairs, etc. Provide how exceptions are handled.//+The user can connect to this controller using the Distancelab environment
  
 === Limits === === Limits ===
-//Provide information about limits on usagei.e. need for maintenance/service break, access mode (parallel, booking, etc.), manual mechanical resetetc.//+At the same timeone user can program the controllerBut all users connected to the Distancelab MQTT broker can control the RGB LEDassuming they use the topic described in the controller program.
  
 ==== Hands-on labs ==== ==== Hands-on labs ====
-//List study scenarios (hands-on labs)linking to the Dokuwiki pages with hands-on labs descriptions (there should be a separate page for each scenario). Classify each scenario and refer to the target group using starting keywords+ 
-  * Beginners +=== Example code === 
-  * Undergraduates +<code c> 
-  * Masters +#include <Arduino.h> 
-  * Professionals +#include <ittiot.h> 
-Note, assume that more professional group automatically contains less professional onesNote - use language and as appropriate to the target groupi.e.:// +#include <Adafruit_NeoPixel.h> 
-<code> + 
-  * Beginners: Elementary operations on the Arduino 2x16 LCD screen+#define PIN            D2 
-  * Undergraduates: Visualizing temperature and humidity on the remote screen+ 
-  * Masters: Using power saving states to limit power consumption.+// When we setup the NeoPixel librarywe 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 on possible values. 
 +Adafruit_NeoPixel pixels = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800); 
 + 
 +// https://stackoverflow.com/questions/9072320/split-string-into-string-array 
 +String getValue(String data, char separator, int index) 
 +
 +  int found = 0; 
 +  int strIndex[] = {0, -1}; 
 +  int maxIndex = data.length()-1; 
 + 
 +  for(int i=0; i<=maxIndex && found<=index; i++) 
 +  { 
 +    if(data.charAt(i)==separator || i==maxIndex) 
 +    { 
 +        found++; 
 +        strIndex[0] = strIndex[1]+1; 
 +        strIndex[1] = (i == maxIndex) ? i+1 i; 
 +    } 
 +  
 + 
 +  return found>index ? data.substring(strIndex[0], strIndex[1]) : ""; 
 +
 + 
 +// Change RGB LED color 
 +// mosquitto_pub -u test -P test -t "ITT/IOT/3/rgb" -m "51;255;153" 
 +void iot_received(String topic, String msg) 
 +{ 
 +  Serial.print("MSG FROM USER callback, topic: "); 
 +  Serial.print(topic); 
 +  Serial.print(" payload: "); 
 +  Serial.println(msg); 
 + 
 +  String r = getValue(msg,';',0); 
 +  String g = getValue(msg,';',1); 
 +  String b = getValue(msg,';',2); 
 + 
 +  Serial.print("R: "); 
 +  Serial.println(r); 
 + 
 +  Serial.print("G"); 
 +  Serial.println(g); 
 + 
 +  Serial.print("B: "); 
 +  Serial.println(b); 
 +  // Moderately bright green color. 
 +  pixels.setPixelColor(0, r.toInt(), g.toInt(), b.toInt());  
 + 
 +  pixels.show(); // This sends the updated pixel color to the hardware. 
 +
 + 
 +void iot_connected() 
 +{ 
 +  Serial.println("MQTT connected callback"); 
 +  iot.subscribe("rgb"); 
 +  iot.log("IoT NeoPixel example!"); 
 +
 + 
 +void setup() 
 +
 +  Serial.begin(115200); 
 +  Serial.println("Booting"); 
 + 
 +  iot.printConfig(); // print json config to serial  
 +  iot.setup(); 
 + 
 +  pixels.begin(); // This initializes the NeoPixel library. 
 +
 + 
 +void loop() 
 +
 +  iot.handle(); 
 +  delay(200); 
 +}
 </code> </code>
 +
 ==== Support ==== ==== Support ====
-//Give some information on how to access help, how to get support in case of the trouble etc.//+info@ittgroup.ee
  
en/iot-open/remotelab/itt/remotelights.1542218887.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0