Hello Michael,

Michael Picco <mpi...@placerville.me> writes:

> Hello!
>
> I finally have figured out how to efficiently interact with Amforth on my
> mega2560 and have installed much of the I2C stuff on it.
Good!

>
> Question:
>
> Has anyone worked out how to talk to the BME280 sensor using Amforth?  Wading
> through the spec sheet tells me it's going to be a challenge.  It would be
> nice not to reinvent the 'wheel', if someone has already done the
> heavy-lifting!

I have, much to my dismay, spent more than 20 hours on this. Not
once in my life have I seen such an awkward interface.
Unbelievable.

The C code on
https://github.com/BoschSensortec/BME280_driver/blob/master/bme280.c
is working. It is just not meaningfully documented. Code using
this can be found here
https://github.com/adafruit/Adafruit_BME280_Library

You have to very carefully study the datasheet and obey the
"signed" vs. "unsigned" song and dance. I have written C code to
see, whether my intermediate calculations were correct. I have
managed to calculate temperature and humidity. The humidity
values were significantly too low (I do have more sensors). And
on pressure values I gave up after wading through about halfway.

That being said: I was pointed to a working implementation for
noForth on MSP430, published in "Vierte Dimension" 2020-01
https://forth-ev.de/wiki/vd-archiv


As I said, working the sensor with C is ok, since the adafruit
library is written and working. Working the sensor in Forth is
kind of horrible, because you need to reverse engineer the
calculation. WHY not spending the silicon to do the calculation
"on board" and produce linear, compensated readings is beyond my
imagination.

I pulled the one BME280 sensor out, I will happily give it away.
And I ordered a handful of expensive Sensirion SHT85 sensors for
temperature, humidity and a mpx6115 sensor for pressure (needs
an ADC). The sensirion sensors worked for me after a couple
hours. I did not figure out, how to check the crc that comes
with the data --- but that is left for another time.

I can send my code re. BME289 your way, if you are interested.
But do not spend countless hours on a misdesigned interface ...


Cheers,
Erich

-- 
May the Forth be with you ...


_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to