Fun and Games with i2c, esp8266 and MongooseOS

I have been using mongoose-os with the esp32, and wanted to try similar with the esp8266.
One of the examples I wanted to try was the adafruit-ssd1306 app, which is a js programm that calls the c-libraries through an api. Find it here https://github.com/mongoose-os-apps/arduino-adafruit-ssd1306 

Flashing it was ok

Loaded arduino-adafruit-ssd1306/esp8266 version 1.0 (20170712-183120/???)
Using port /dev/ttyUSB0
Opening /dev/ttyUSB0...
Connecting to ESP8266 ROM, attempt 1 of 10...
Connected
Running flasher @ 460800...
Flasher is running
Flash size: 4194304, params: 0x0240 (dio,32m,40m)
Deduping...
2656 @ 0x0 -> 0
262144 @ 0x8000 -> 94208
128 @ 0x3fc000 -> 0
Writing...
4096 @ 0x7000
94208 @ 0x8000
774144 @ 0x100000
4096 @ 0x3fb000
Wrote 874416 bytes in 19.38 seconds (352.48 KBit/sec)
Verifying...
2656 @ 0x0
4096 @ 0x7000
262144 @ 0x8000
772016 @ 0x100000
4096 @ 0x3fb000
128 @ 0x3fc000
Booting firmware...
All done!

Then started up mos

~/.mos/bin/mos

All ok….the i2c display isn’t working yet, because the pins in the configuration is wrong. The Wemos d1 mini only has a few pins broken out and not the 14,15 in the demo.
So….from the Wemos, d1 and d2 are the pins for i2c. I changed the configuration to 1,2 and saved.
Instability ensues.
I need to flash it again to get the connection back. I try again, this time changing the connections to use the d5 and d6 on the Wemos. Again, instability, and multiple resets. I read a bit about the resets and thought it might be power instability, something to do with the filesystem(SPIFFs).
With fresh eyes I returned, I tried to just change the configuration to turn on debug for the I2C.
And look! When it was on, I saw in its reset, that the I2C debug issued warnings like GPIO6 is part of SPIFFs and shouldn’t be used.
One of the experiments, with pins 6, 7 scrambled the Wemos so  much that I couldn’t reflash it without getting serious.

Serious being a 5.8k resistor between GPIO0 and Ground. Well it did in the end. First I had to learn a valuable lesson.

D pins on the Wemos are not the same number as the GPIO pins on the ESP8266. https://wiki.wemos.cc/products:d1:d1_mini  maps it out.

d1 and d2 on the Wemos, are NOT GPIO1 and GPIO2, neither is d6 GPIO6. D1 and D2 are GPIO4 and GPIO5.

Display now works. No strange resets. Hope this will be of use to someone else.

 

Leave a Reply

Your email address will not be published. Required fields are marked *