-
• #2
Hi, I started to convert the C to JS, feel free to use it as a starting point. It is not tested or verified in any way other than some JSLinting.
https://gist.github.com/AlexanderBrevig/e04fbeb19402d5f5d8f7
-
• #3
Can someone with more I2C experience on the Espruino answer if
Wire.beginTransmission(addrBME280); Wire.write(reg); Wire.write(data); Wire.endTransmission();
equals
I2C1.writeTo(addrBME280, [reg, data]);
If not then could a sample for the equivalent be provided? I'll fix the gist as needed (or feel free to fix yourself:) )
-
• #4
Yes - I think that's fine...
-
• #5
Looks good @alexanderbrevig :)
I'll hopefully receive the breakout board early next week so I can try the module live. I'll report back then once I have it hooked up. (Second Espruino also on the way to become my dev board)
-
• #6
We will offer a bounty of bonus awesome electronics to the first GitHub share of a working code set.
You guys are doing an awesome job building a great platform and we want to support it any way we can.
Kind regards
Ian.
Embedded Adventures -
• #7
Hi Ian,
Didn't know you were on here :)
Cheers
Ian
-
• #8
@ianharris thanks! I really appreciate it - I wish more hardware makers did that sort of thing!
-
• #9
My question is a little bit off topic :-),
how would I connect the BME280/680 to Espruino ? Is there a special adapter or a socket ? Having all fingers as thumbs, soldering would not be my preferred solution.
BTW, using an BME680 could be a solution to create longtime observation of rooms. Right now friends have the problem to follow some putrid smell in their appartment. This sensor could give some information about time and strength, which can be helpful to locate the source. -
• #10
The best bet right now is embeddedadventures and @ianharris' BME280 adaptor
Hopefully when the 680 comes out there might be an adaptor for that as well? :)
-
• #11
I'm confident we (if not me, then some other more knowledgeable) will get it working with the Espruino as soon as one of us gets their hands on one. Did I understand you correctly @IanWatkins, that you have one on the way?
-
• #12
@alexanderbrevig That's right, but Ian didn't have in UK stock so waiting for delivery from the USA so should be here in the next few days.
As soon as it arrives I'll hook it up to my second, new shiny Espruino (my first is embedded now) and try your code and see where we are. I'll of course report back then and hopefully we can get to the point of a working module.
-
• #13
@alexanderbrevig Board arrived this evening so hooked up to Espruino and got code loaded. Think it was right on flash code limit as was reporting out of memory while loading it. But minifying the module solved that.
Comms over I2C confirmed and can dump out the bme280 object structure and am getting compensation values back from the chip.
Got a few errors:
Line 290
var data[8];
throws an error and I think should be:
var data = [];
Line 380:
this.writeRegister(C.regCtrlMeas, C.ctrlMeas);
I think should be:
this.writeRegister(C.regCtrlMeas, ctrlMeas);
Line 10
regMeasurementsStart: 0xf,
should that be:
regMeasurementsStart: 0xf7,
Will crack on running tests in the morning but for now I'm off to bed.
Cheers
Ian
-
• #14
@IanWatkins Cool! Sorry about those mistakes, I translated to JS with regex and very little manual work so things like
int data[8];
->var data = [];
got missed.
If (when) you get the other quirks out of the way, you should do a PR to this http://www.espruino.com/Writing+Modules with the Module and claim the prize [then tell us what you got]! :) -
• #15
Great news!
There are definitely a few things we can do to reduce the amount of data taken up, but if/when the module goes into the set of normal Espruino modules it'll get minified by default anyway.
-
• #16
I just received my module from Embedded Adventures, unfortunately I won't have time to get started on it until May. Want to borrow mine, @alexanderbrevig?
-
• #17
@alexanderbrevig Hey, don't apologise, just happy you made a stab at it to get me started.
I've actually come up against a bit of a showstopper here. I think I'm getting sensible values back from the sensor with a raw read of values. However, I cannot use any of the compensated functions as some values required are simply not set.
Looking at the Arduino code (which I confirmed works just fine on my Arduino Uno this morning) here and look at line 50 for example there is a variable from the compStruct called
compParams.compStruct.dig_T1
and various others of the form dig_Tx and dig_Px (defined in the header file here starting at line 129).
I cannot see anywhere in the Arduino code where these values get set, hence Alexander's code also won't have set them. dig_Hx (Humidity) are set and I am getting a sensible looking humidity value (although not temperature compensated yet)
So can someone who is Arduino fluent take a look at the EA code from @ianharris and tell me where the dig_Tx and dig_Px values get set.
I've been looking at this all day and I'm sure I'm missing something but I just cannot see it.
Cheers
Ian
-
• #18
Scratch that, its a C Union statement in the header file that blasts 20 odd values in of various sizes.
Guess I will need to sit down and push them in by hand. Boo. :)
But on the plus side, combine that with what looks like sensible raw values being read, should be workable.
-
• #19
OK, it's all working, sort of...
Couple of the values coming back are suspect but I need to go through each function and check each one to ensure it's doing the right thing. I suspect it is just some rounding issues or other gotchas going from C to JS.
Some output from my test rig:
_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v76 Copyright 2015 G.Williams >echo(0); ChipID : 96 CtrlMeas : 36 Measuring... . . . . Done !!! ---------------------------------------------------------- { "i2c": { "_options": { "scl": B6, "sda": B7, "bitrate": 100000 } }, "compParams": { "dig_T1": 28415, "dig_T2": 26397, "dig_T3": 50, "dig_P1": 37393, "dig_P2": -10875, "dig_P3": 3024, "dig_P4": 6654, "dig_P5": 13, "dig_P6": -7, "dig_P7": 9900, "dig_P8": -10230, "dig_P9": 4285, "dig_H1": 75, "dig_H2": 356, "dig_H3": 0, "dig_H4": 335, "dig_H5": 0, "dig_H6": 30 }, "t_fine": 0, "adc_t": 525584, "adc_p": 335232, "adc_h": 30412 } ---------------------------------------------------------- Temperature : 22.33 Humidity : 49.2021484375 Pressure (Suspect) : -124.63193742510 Pressure More Accurate (Suspect) : -116.96609374999 Temperature Most Accurate : 22.32728913521 Humidity Most Accurate (Suspect) : NaN Pressure Most Accurate : 1009.19167457070 ----------------------------------------------------------
Current test prog is here
Current module code is hereMore when I've had time to work the functions and improve the code a bit. But still happy for anyone to chip in with improvement ideas.
Cheers
Ian
-
• #20
Great work Ian!
And yes, as soon as we can get our hands on the BME680, we will be the first out with a breakout module.
Ian.
-
• #21
As soon as we can get our hands on the BME680, we will be the first out with a breakout module.
That's great news!
I got the 280 a week or so back so I'll have to take a look at this and see what's up with it... Or have you had any progress @IanWatkins? It's so close!
-
• #22
Not had any time past week or so @Gordon, been away working. Hope to be home again next week and get back on it.
The program and module code I posted as Gists above is my latest (links below). So if you want to take that and spend some time on it, you are more than welcome. My aim was to eventually replicate what Ian did with his Arduino example.
I just recently got the "Humidity Most Accurate" working as well, so only "Pressure" and "Pressure More Accurate" needs fixing although they look OK comparing my code with Ian's, the data sheet from Bosch and Bosch's code, so suspect a rounding issue or similar.
Current test prog is here
Current module code is hereOutput currently looks like this:
_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v77 Copyright 2015 G.Williams >echo(0); ChipID : 96 CtrlMeas : 36 Measuring... . . . . Done !!! ---------------------------------------------------------- Temperature : 21.9 Humidity : 45.8583984375 Pressure (Suspect) : -126.86268593172 ---------------------------------------------------------- Pressure More Accurate (Suspect) : 85.15359374999 ---------------------------------------------------------- Temperature Most Accurate : 21.90582997486 Humidity Most Accurate : 45.85865386029 Pressure Most Accurate : 1006.10934649366 ---------------------------------------------------------- { "i2c": { "_options": { "scl": B6, "sda": B7, "bitrate": 100000 } }, "compParams": { "dig_T1": 28415, "dig_T2": 26397, "dig_T3": 50, "dig_P1": 37393, "dig_P2": -10875, "dig_P3": 3024, "dig_P4": 6654, "dig_P5": 13, "dig_P6": -7, "dig_P7": 9900, "dig_P8": -10230, "dig_P9": 4285, "dig_H1": 75, "dig_H2": 356, "dig_H3": 0, "dig_H4": 335, "dig_H5": 0, "dig_H6": 30 }, "t_fine": 112157.84947130654, "adc_t": 524245, "adc_p": 336661, "adc_h": 29806 } ----------------------------------------------------------
Cheers
Ian
Hi All,
As some of you know, I'm interested in flying sensors on multicopters using the Espruino as the controller board (my project here).
The Bosch BME280 is a three sensor chip (pressure, temperature and humidity) and Embedded Adventures (EA) have made a breakout board for it called the MOD-1022.
EA have also produced an Arduino library for interfacing to the board here on GitHub.
Would those with that kind of knowledge take a look at their library and tell me if its feasible to port to a module for Espruino please? I've had a scan through it and not seen anything I didn't recognise although I'll admit I didn't understand all of it.
These three sensors chips are used more and more in mobile applications and I would expect that they will eventually replace for example the Bosch BMP180 so might be worth investing the time to create a module.
Cheers
Ian