This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:remotelab:itt:oledscreen [2018/12/06 06:43] – rim.puks | en:iot-open:remotelab:itt:oledscreen [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== OLED display module ===== | + | ===== ITT OLED display 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. | ||
| Line 8: | Line 8: | ||
| ==== Prerequisites ==== | ==== Prerequisites ==== | ||
| - | For this laboratory, the student should understand basic MQTT concepts like topics, broker, subscribing and publishing. Also knowledge about I2C interface is recommended but not mandatory. | + | For this laboratory, the student should understand basic MQTT concepts like topics, broker, subscribing and publishing. Also, knowledge about I2C interface is recommended but not mandatory. |
| ==== Technical details ==== | ==== Technical details ==== | ||
| - | This laboratory consists of a OLED display module attached to the ITT IoT controller module. Oled module contains an organic light-emitting diode, that is a light-emitting diode in which the emissive electroluminescent layer is a film of organic compound that emits light in response to an electric current. | + | This laboratory consists of an OLED display module attached to the ITT IoT controller module. Oled module contains an organic light-emitting diode, that is a light-emitting diode in which the emissive electroluminescent layer is a film of organic compound that emits light in response to an electric current. |
| - | === Sensors === | + | === Sensors ===Relay |
| This laboratory does not have any sensors. | This laboratory does not have any sensors. | ||
| Line 42: | Line 42: | ||
| ==== Hands-on labs ==== | ==== Hands-on labs ==== | ||
| - | //List study scenarios | + | |
| - | | + | === Example code === |
| - | | + | |
| - | | + | <code c> |
| - | | + | |
| - | Note, assume that more professional group automatically contains less professional ones. Note - use language and as appropriate | + | #include < |
| - | < | + | #include < |
| - | | + | #include < |
| - | | + | #include < |
| - | | + | #include < |
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | #define OLED_RESET 0 | ||
| + | |||
| + | Ticker timeTicker; | ||
| + | Adafruit_SSD1306 display(OLED_RESET); | ||
| + | |||
| + | // ITT splashs screen bitmap. Generator: http:// | ||
| + | static const unsigned char PROGMEM logo16_glcd_bmp[] = | ||
| + | { | ||
| + | 0x00, 0x00, 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) | ||
| + | # | ||
| + | #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 | ||
| + | void iot_connected() | ||
| + | { | ||
| + | Serial.println(" | ||
| + | iot.log(" | ||
| + | isBootModeNormal = true; | ||
| + | } | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | Serial.begin(115200); | ||
| + | Serial.println(" | ||
| + | |||
| + | // initialize | ||
| + | display.begin(SSD1306_SWITCHCAPVCC, | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | | ||
| + | | ||
| + | // Show image buffer on the display | ||
| + | display.display(); | ||
| + | |||
| + | // Display splashscreen two second | ||
| + | delay(2000); | ||
| + | |||
| + | // print IoT json config | ||
| + | iot.printConfig(); | ||
| + | |||
| + | // Initialize IoT library | ||
| + | iot.setup(); | ||
| + | |||
| + | | ||
| + | | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | | ||
| + | iot.handle(); | ||
| + | |||
| + | | ||
| + | i++; | ||
| + | |||
| + | // Display counter value and boot mode on the OLED screen | ||
| + | display.clearDisplay(); | ||
| + | | ||
| + | display.setTextColor(WHITE); | ||
| + | display.setCursor(0, | ||
| + | display.println(" | ||
| + | display.println(i); | ||
| + | |||
| + | display.setCursor(0, | ||
| + | |||
| + | if(isBootModeNormal) | ||
| + | { | ||
| + | display.println(" | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | display.println(" | ||
| + | } | ||
| + | |||
| + | display.display(); | ||
| + | |||
| + | // Send counter value to the server | ||
| + | if(WiFi.isConnected() && isBootModeNormal) | ||
| + | { | ||
| + | if(sendDataFlag) | ||
| + | { | ||
| + | sendDataFlag = false; | ||
| + | String msg = String(i); | ||
| + | iot.publishMsg(" | ||
| + | Serial.println(msg); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| </ | </ | ||
| + | |||
| ==== Support ==== | ==== Support ==== | ||
| - | //Give some information on how to access help, how to get support in case of the trouble etc.// | + | info@ittgroup.ee |