Differences

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

Link to this comparison view

Next revision
Previous revision
en:iot-open:remotelab:itt:oledscreen [2018/11/15 06:22] – created rim.puksen:iot-open:remotelab:itt:oledscreen [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-===== OLED screen module ===== +===== ITT OLED display module ===== 
-//Give an information, where laboratory is located (partner name) and very short description (like one sentence).//+This laboratory is located in the office of ITT Group in Tallinn, Estonia.
  
 ==== Introduction  ==== ==== Introduction  ====
-//Here provide some general idea of the laboratory. Do not use very complicated phrases. It is to be understood by people with limited understanding of the technology. Photos, schematic and drawings may be attached as well+This laboratory can be used to practice displaying messages on the OLED screen
-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:oled3.png?300|}}
  
 ==== Prerequisites ==== ==== Prerequisites ====
-//Describe prerequisite readingssoftwarehardware (if any) - note - only those that apply to ALL scenariosknowledge necessary to understandI case single scenario requires some extra knowledge/prerequisites, provide it with scenario document, not here.//+For this laboratorythe student should understand basic MQTT concepts like topicsbrokersubscribing and publishingAlso, knowledge about I2C interface is recommended but not mandatory.
  
 ==== Technical details ==== ==== Technical details ====
-//Provide technical details on the construction of the laboratoryboth 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 consists of an OLED display module attached to the ITT IoT controller module. Oled module contains an organic light-emitting diodethat is a light-emitting diode in which the emissive electroluminescent layer is film of organic compound that emits light in response to an electric current.
  
-=== Sensors === +=== Sensors ===Relay 
-//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.//+This laboratory does not have any sensors.
  
-=== Actuators === +=== Specifications === 
-//Describe actuators, their impact on the physical/mechanical part of the laboratory device, limits, connections, etcAdd photos and schematics, where the actuator is locatedIn case actuator is virtualdo 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.//+<table Ref.Tab.1.1> 
 +<caption>OLED screen specifications</caption> 
 +^ Specification ^ Value ^ 
 +| Screen size | 64x48 pixels (0,66")| 
 +| Driver IC | SSD1306 | 
 +| Interface | I2C| 
 +| I2C address | 0x3C or 0x3D | 
 +</table> 
 + 
 +=== Electrical connection === 
 + 
 +Connected to ports GPIO4 (SDA) and GPIO5 (SCL).
  
 === 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.//+  * ITTIoT libary - used to program the controller module. 
 +  * Adafruit GFX library - general libary for Adafruit displays 
 +  * Adafruit SSD1306 Wemos Mini OLED libary for controlling the OLED screen.
  
 === 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 and program this controller using the Distancelab environment.
  
 === Limits === === Limits ===
-//Provide information about limits on usagei.eneed for maintenance/service break, access mode (parallel, booking, etc.), manual mechanical reset, etc.//+At the same timeonly one user can program the controllerBut all users connected to the Distancelab MQTT broker can subscribe and publish to topics specified.
  
 ==== 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 + 
-  * Masters +<code c> 
-  * Professionals + 
-Noteassume that more professional group automatically contains less professional onesNote - use language and as appropriate to the target group, i.e.:// +#include <Arduino.h> 
-<code> +#include <ittiot.h> 
-  * Beginners: Elementary operations on the Arduino 2x16 LCD screen+#include <Ticker.h> 
-  * Undergraduates: Visualizing temperature and humidity on the remote screen. +#include <ESP8266WiFi.h> 
-  * MastersUsing power saving states to limit power consumption.+#include <SPI.h> 
 +#include <Wire.h> 
 +#include <Adafruit_GFX.h> 
 +#include <Adafruit_SSD1306.h> 
 + 
 +#define OLED_RESET 0  // GPIO0 
 + 
 +Ticker timeTicker; 
 +Adafruit_SSD1306 display(OLED_RESET)
 + 
 +// ITT splashs screen bitmap. Generator: http://javl.github.io/image2cpp/ 
 +static const unsigned char PROGMEM logo16_glcd_bmp[] = 
 +
 +  0x000x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf0,  
 +  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x10, 0x00, 0x00, 0x00,  
 +  0x00, 0x00, 0x00, 0x07, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  
 +  0x07, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x10, 0x00,  
 +  0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x1f, 0xff, 0xff, 0xc0, 0x00,  
 +  0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x07,  
 +  0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,  
 +  0xc0, 0x00, 0x00, 0x00, 0x07, 0x1f, 0xe3, 0xff, 0xc0, 0x00, 0x00,  
 +  0x00, 0x07, 0x1f, 0xe3, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x07, 0x10,  
 +  0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x10, 0xe2, 0x00, 0x00,  
 +  0x00, 0x00, 0x00, 0x07, 0x10, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00,  
 +  0x07, 0x10, 0xe3, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x07, 0x10, 0xe0,  
 +  0x00, 0x00, 0x18, 0x00, 0x00, 0x07, 0x10, 0xe0, 0x00, 0x00, 0x18,  
 +  0x00, 0x00, 0x07, 0x10, 0xe0, 0x00, 0x00, 0x18, 0x00, 0x00, 0x07,  
 +  0x10, 0xe3, 0xfc, 0xff, 0xf8, 0x00, 0x00, 0x07, 0x10, 0xe3, 0xfc,  
 +  0xff, 0xf8, 0x00, 0x00, 0x07, 0x10, 0xe2, 0x1c, 0x80, 0x00, 0x00,  
 +  0x00, 0x07, 0x10, 0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x07, 0x10,  
 +  0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x07, 0x10, 0xe2, 0x1c, 0x80,  
 +  0x00, 0x00, 0x00, 0x07, 0x10, 0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00,  
 +  0x07, 0x10, 0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x07, 0x10, 0xe2,  
 +  0x1c, 0x80, 0x00, 0x00, 0x00, 0x07, 0xf0, 0xe2, 0x1c, 0x80, 0x00,  
 +  0x00, 0x00, 0x00, 0x00, 0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00,  
 +  0x00, 0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x1c,  
 +  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x1c, 0x80, 0x00, 0x00,  
 +  0x00, 0x00, 0x00, 0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,  
 +  0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x1c, 0x80,  
 +  0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x1c, 0x80, 0x00, 0x00, 0x00,  
 +  0x00, 0x00, 0xfe, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  
 +  0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x80, 0x00,  
 +  0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00,  
 +  0x00, 0x00, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,  
 +  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x80, 0x00, 0x00,  
 +  0x00, 0x00, 0x00, 0x00, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,  
 +  0x00, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80,  
 +  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 
 +}; 
 + 
 +#if (SSD1306_LCDHEIGHT != 48) 
 +#error("Height incorrect, please fix Adafruit_SSD1306.h!"); 
 +#endif 
 + 
 +bool isBootModeNormal; 
 +bool sendDataFlag; 
 + 
 +int i = 0; 
 + 
 +// Ticker library callback, which will occur 0.5 second interval. 
 +void sendData() 
 +
 +  sendDataFlag=true; 
 +
 + 
 +// Function started after the connection to the server is established. 
 +void iot_connected() 
 +
 +  Serial.println("MQTT connected callback"); 
 +  iot.log("IoT OLED screen example!"); 
 +  isBootModeNormal = true; 
 +
 + 
 +void setup() 
 +
 +  Serial.begin(115200); 
 +  Serial.println("Booting"); 
 + 
 +  // initialize with the I2C addr 0x3C (for the 64x48) 
 +  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); 
 + 
 +  // Since the buffer is intialized with an Adafruit splashscreen 
 +  // internally, we should clear it 
 +  display.clearDisplay(); 
 + 
 +  // Load ITT splash screen into buffer 
 +  display.drawBitmap(00,  logo16_glcd_bmp, 64, 48, 1); 
 +  // Show image buffer on the display 
 +  display.display(); 
 + 
 +  // Display splashscreen two second 
 +  delay(2000); 
 + 
 +  // print IoT json config to serial 
 +  iot.printConfig(); 
 + 
 +  // Initialize IoT library 
 +  iot.setup(); 
 + 
 +  // Initialize Ticker interval and callback 
 +  timeTicker.attach(0.5, sendData); 
 +
 + 
 +void loop() 
 +{ 
 +  // IoT behind the plan work, it should be periodically called 
 +  iot.handle(); 
 + 
 +  // Increase counter value 
 +  i++; 
 + 
 +  // Display counter value and boot mode on the OLED screen 
 +  display.clearDisplay(); 
 +  display.setTextSize(1); 
 +  display.setTextColor(WHITE); 
 +  display.setCursor(0,0); 
 +  display.println("Counter"); 
 +  display.println(i); 
 + 
 +  display.setCursor(0,30); 
 + 
 +  if(isBootModeNormal) 
 +  { 
 +    display.println("Mode: NORM"); 
 +  } 
 +  else 
 +  { 
 +    display.println("Mode: BOOT"); 
 +  } 
 + 
 +  display.display(); 
 + 
 +  // Send counter value to the server 
 +  if(WiFi.isConnected() && isBootModeNormal) 
 +  { 
 +    if(sendDataFlag) 
 +    { 
 +      sendDataFlag = false; 
 +      String msg = String(i); 
 +      iot.publishMsg("count", msg.c_str()); 
 +      Serial.println(msg); 
 +    } 
 +  } 
 +
 + 
 </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/oledscreen.1542262965.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