Hi I am having problem with connecting OLED display via I2C.
My setup
ESP8266 (Wemos D1)
OLED 128x64 SSD1306
wiring:
i2c.sda
- GPIO 4 (D2)
i2c.scl
- GPIO 5 (D1)
- ["i2c.enable", true]
- ["i2c.sda_gpio", 4]
- ["i2c.scl_gpio", 5]
mos call I2C.Scan
detects the display-> [ 60 ]
.
The code sample I am trying to run is:
/*
* Copyright (c) 2014-2017 Cesanta Software Limited
* All rights reserved
*
* This example demonstrates how to use mJS Arduino Adafruit_SSD1306
* library API.
*/
// Load Mongoose OS API
load('api_timer.js');
load('api_arduino_ssd1306.js');
// Initialize Adafruit_SSD1306 library (I2C)
let d = Adafruit_SSD1306.create_i2c(4 /* RST GPIO */, Adafruit_SSD1306.RES_128_64);
// Initialize the display.
d.begin(Adafruit_SSD1306.SWITCHCAPVCC, 0x3D, true /* reset */);
d.display();
let i = 0;
let showStr = function(d, str) {
This file has been truncated. show original
with the difference where I updated I2C address to 0x3c
(60)
I was looking for an answer here, but I didn’t find the solution yet - https://forum.mongoose-os.com/discussion/1106/i2c-oled-not-working .
What else can I do? How else can I debug the problem?
I know the I2C display is working fine, because I got it working using different firmware (espruino).
Ok, I found it. I am new to mongoose, so I made this rookie mistake
Except import libs in JS code init.js
file I also should import libs by adding them to mos.yml
.
In my particular case those are:
# libs necessary for the current app
- origin: https://github.com/mongoose-os-libs/arduino-adafruit-ssd1306
- origin: https://github.com/mongoose-os-libs/mj