This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| en:iot-open:remotelab:itt:oledscreen [2018/11/15 06:22] – created 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 screen | + | ===== ITT OLED display |
| - | //Give an information, | + | This laboratory is located |
| ==== 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 |
| - | Write objectives for the laboratory i.e. "its purpose is to model ...." or " | + | |
| + | {{: | ||
| ==== 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/ | + | For this laboratory, the student should understand basic MQTT concepts like topics, broker, subscribing and publishing. Also, knowledge |
| ==== Technical details ==== | ==== Technical details ==== | ||
| - | //Provide technical details on the construction | + | This laboratory consists |
| - | === Sensors === | + | === Sensors ===Relay |
| - | //Describe sensors (if any). Provide details on measured values, connection details, accuracy, protocols, its relation to the physical/ | + | This laboratory |
| - | === Actuators | + | === Specifications |
| - | //Describe actuators, their impact on the physical/ | + | <table Ref.Tab.1.1> |
| + | < | ||
| + | ^ Specification ^ Value ^ | ||
| + | | Screen size | 64x48 pixels (0,66" | ||
| + | | Driver IC | SSD1306 | | ||
| + | | Interface | I2C| | ||
| + | | I2C address | 0x3C or 0x3D | | ||
| + | </ | ||
| + | |||
| + | === Electrical connection === | ||
| + | |||
| + | Connected | ||
| === 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 | + | * ITTIoT libary - used to program the controller module. |
| + | * Adafruit GFX library - general libary | ||
| + | * Adafruit SSD1306 Wemos Mini OLED - libary for controlling the OLED screen. | ||
| === Communication === | === Communication === | ||
| - | //Describe communication if it is implemented | + | The user can connect |
| === Limits === | === Limits === | ||
| - | //Provide information about limits on usage, i.e. need for maintenance/ | + | At the same time, only one user can program the controller. But all users connected to the Distancelab MQTT broker can subscribe and publish to topics specified. |
| ==== 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 |