Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on ESP8266 chip #21

Closed
octimot opened this issue Oct 23, 2020 · 3 comments
Closed

Not working on ESP8266 chip #21

octimot opened this issue Oct 23, 2020 · 3 comments

Comments

@octimot
Copy link

octimot commented Oct 23, 2020

I tried to run the code on a Wemos D1 Mini board.

First, the compiler threw an error, which I fixed like this:

Line 30 in print.h:
fdevopen( &serial_putc, 0 );

Needs to be changed to:
Serial.setDebugOutput(true);

This seems to be the proper way to redirect stdout on ESP8266 chips - a conditional based on the chip type might be useful in the code in the future.

But even after uploading the revised code to the board, I can't get it to communicate with the TFMini Plus (which works well on an Arduino Uno).

Did somebody have any luck with this?

@octimot
Copy link
Author

octimot commented Oct 23, 2020

I dug a bit deeper and it could be that SoftwareSerial triggers a crash on ESP8266 chips.

On opensensinglab/tfmini#6 they recommend using the ESPSoftwareSerial for the TFMini.

Not sure how I could implement that info for testing. Help? 🤓

@octimot
Copy link
Author

octimot commented Oct 24, 2020

I managed to make it work, by using the main Serial class for communicating with the TFMini Plus.

Basically:

  • I disabled any sort of Serial output (entire TFMPlus::printFrame() and TFMPlus::printReply() ),
  • commented out all printf functions,
  • and removed the inclusion of SoftwareSerial since it's not needed anymore.

I want to output tfDist to an OLED shield, so, for my purpose, I can still see the measured results even without the serial connection to the computer.

But if someone wants to tackle this, it would be nice to have it fixed. If you need the altered code, just let me know.

@budryerson
Copy link
Owner

I was not aware of the Wemos D1 Mini board. Now I am. Thank you.

I like printf() because it enables compact, easy to read code; but I didn't create it and, as you noted, problems can arise.
printf() may be already included in the Arduino IDE for ESP8266 chips, in which case you would not need to call printf.h. ESP8266 printf() may behave differently in that a \n needs to be sent before any output occurs. I agree that it's sometimes more reliable to replace every printf() with Serial.print().

I also agree that SoftwareSerial brings it's own set of problems and that's why I do not understand why you want to communicate with the TFMini-Plus in the UART mode. Why not use I2C mode?

I would love to see your code. Thanks,

Bud Ryerson
San Francisco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants