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 

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...
Running flasher @ 460800...
Flasher is running
Flash size: 4194304, params: 0x0240 (dio,32m,40m)
2656 @ 0x0 -> 0
262144 @ 0x8000 -> 94208
128 @ 0x3fc000 -> 0
4096 @ 0x7000
94208 @ 0x8000
774144 @ 0x100000
4096 @ 0x3fb000
Wrote 874416 bytes in 19.38 seconds (352.48 KBit/sec)
2656 @ 0x0
4096 @ 0x7000
262144 @ 0x8000
772016 @ 0x100000
4096 @ 0x3fb000
128 @ 0x3fc000
Booting firmware...
All done!

Then started up 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(which is D3) 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.  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.


Hall effect sensor in the ESP32 with Arduino ide

Learning about the esp32 again. When looking at the adc documentation at this interested me

It is also possible to read the internal hall effect sensor via ADC1.

Digging in the code for the arduino-esp32 we find that we can read it using hallRead() from arduino-esp32/cores/esp32/esp32-hal-adc.h

Might be useful to someone.

//Simple sketch to access the internal hall effect detector on the esp32.
//values can be quite low. 
//Brian Degger 

int val = 0;

void setup() {

void loop() {
  // put your main code here, to run repeatedly:
  val = hallRead();
  // print the results to the serial monitor:
  //Serial.print("sensor = ");
  Serial.println(val);//to graph

Strong magnets are needed to get a good response.