0

dtostrf on Feather M0
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

dtostrf on Feather M0

by travisma on Thu Aug 15, 2019 2:12 pm

I've recently started working with a Feather M0 with a LoRa module (Adafruit part 3178). I have some floating point sensor data that I want to format for the radio. I did some sketch development on my Uno and tested dtostrf to format the data. It worked fine. However, trying to move the code to the M0 resulted in an error:

exit status 1
'dtostrf' was not declared in this scope

Just for fun, I checked the sketch on a Nano and Feather 32u4. It also worked fine there. Am I missing something with my setup for the Feather M0.
I'm using the Arduino IDE 1.8.9 and have the Adafruit SAMD boards 1.5.3 installed.

I have been able to get the formatting working with the PString library from Mikal Hart (of TinyGPS++ fame). Just curious why the dtostrf isn't on the M0.

Thanks.
--MARK

travisma
 
Posts: 2
Joined: Thu Aug 15, 2019 1:56 pm

Re: dtostrf on Feather M0

by adafruit_support_mike on Sat Aug 17, 2019 12:36 am

The SAMD board support package contains dtorstrf.h and dtostrf.c files:

https://github.com/adafruit/ArduinoCore ... rduino/avr

so the IDE must not be able to find them. That could be a sign of inconsistencies in the BSP, or a bug in the compiler.

Try deleting your Arduino15 folder and reinstalling the board support packages from scratch.. that's less intrusive than downgrading to a previous version of the IDE. If the code still doesn't compile, try dropping back to about 1.8.6

adafruit_support_mike
 
Posts: 58856
Joined: Thu Feb 11, 2010 2:51 pm

Re: dtostrf on Feather M0

by travisma on Wed Aug 21, 2019 8:47 am

Don't you hate it when the answer is right in front of you!!! My bad, I should have paid a lot more attention when I read the tutorial.

https://learn.adafruit.com/adafruit-fea ... ches-to-m0

There is a topic on this page of the tutorial that discusses Floating Point Conversion. It clearly states here that the dtostrf function is not included in the M0 run-time library. This explains the error I was seeing as soon as I tried to move my sketches from the Feature 32u4 to the Feather M0. It's too bad that it's not supported. If you have any floating point sensor data that you want to transmit via the LoRa radio, the dtostrf function is ideal for formatting it.

One Solution: as mentioned in my original post, I've been using the PString library from Mikal Hart and it seems to be working just fine.

--MARK

travisma
 
Posts: 2
Joined: Thu Aug 15, 2019 1:56 pm

Re: dtostrf on Feather M0

by adafruit_support_mike on Thu Aug 22, 2019 12:26 am

Glad to hear you found something that works. Happy hacking!

adafruit_support_mike
 
Posts: 58856
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.