BjarneBitscrambler/OrientationSensorFusion-ESP

ESP-8266 Compatibility unconfirmed

Closed this issue · 4 comments

ESP-8266 compatibility isn't confirmed by actual testing on hardware.

I've ordered a d1_mini for this purpose.

Hello Bjarne,
I've got a d1 mini, so I could help (if I've got the time).
I'm a bit struggling with the code if it is not integrated into SensESP, which I sort of understand. I'm running on a Mac, so the NXP software to test is not much of a help for me.

I received a couple d1_minis, and will start testing.

After making a few changes to the example main.cc (found in the /examples/ project subfolder), now have orientation output on the d1_mini (ESP8266). It turns out that the ESP8266 treats the loop() function differently than the ESP32 does. On the ESP32 it is acceptable to continuously execute a while() loop inside loop(), whereas on the ESP8266 this causes a watchdog timeout.

The solution was to pull the sensor read & fusion & print code out of the while(true) and just have it standing alone in loop(). This also required moving the variables that were declared at the top of loop() outside the function (i.e. making them globals).

I'll do some more in-depth testing, but for now it looks like the code works on the ESP8266.

An interesting difference between the two platforms popped up: the compiler for ESP8266 catches an error that is missed by the ESP32 compiler. In the sample main.cc. there was an unterminated while( true ) { ... in the loop() function. That is, there was no ending } brace for the while. The compiler saw the ending brace for the loop() function and was happy enough with that, when compiling for ESP32. As soon as the platform was switched to ESP8266, there was a compile error about the missing brace.

This is possibly related to the observation of the previous comment, in which the loop() function is treated differently on the two platforms.