• Announcements

    • bluehash

      Forum Upgrade   03/11/2017

      Hello Everyone, Thanks for being patient while the forums were being fixed and upgraded. Please see details and report issues in this thread. Thanks!
chicken

[Energia Library] Bosch BMP085 Template Library

58 posts in this topic

I finished up my first Energia project, a template library for the Bosch BMP085 temperature and pressure sensor. It uses I2C and supports temperature in Celsius and pressure in Pascal.
 
https://github.com/astuder/BMP085-template-library-Energia
 
I connected the GY-80 breakout commonly found on eBay, but it should also work with most other BMP085 breakouts, like the ones from Adafruit or Sparkfun.
 
Note that I had to patch Energia to make 1-byte read work on MSP430G2553 with Rev1.5 LaunchPad. I also had to remove the LED2 jumper, probably due to too weak I2C pull-up.
 
Update:
 
Tested on LaunchPad 1.5 with MSP430G2553, StellarPad Rev A and Arduino R3.
 
Energia requires patches 226 and 235 in twi.c for I2C to work properly on MSP430G2553
https://github.com/energia/Energia/pull/226/files
https://github.com/energia/Energia/pull/235/files
 
Updates:
- Tested with Energia 0101E0010 with MSP430G2553 and F5529, no more I2C patches needed.
- Tested with BMP180 and Software I2C http://forum.43oh.com/topic/3777-energia-library-bosch-bmp085-template-library/?p=44410

- Fixed I2C for Energia 0101E0016 by removing ugly hacks from the past from the library code. Tested only with MSP430G2553

Serginho and energia like this

Share this post


Link to post
Share on other sites

I'm new at all this, but will this work with the MSP430F5529 LaunchPad? If not, any guidelines for patching it? 

Share this post


Link to post
Share on other sites

If this is a joke, it's lost on me. 

if you use the '@' and a user's nickname it sends them an alert. bluehash was alerting chicken to look at your question.

Share this post


Link to post
Share on other sites

here as summoned :)

 

I got the new LaunchPad this week and installed Energia 0010 a while ago, but hadn't time yet to test this library.

 

As my I2C fixes to Energia 0009 were accepted into the main branch, in theory the library and example should work as provided without any patching.

 

Please let me know if you run into issues - or even better, if it worked.

Share this post


Link to post
Share on other sites

I've ordered the sensor so when it arrives I will test and report. Also ordered the AM2302 temp/humidity sensor so we'll see how that goes, too. 

Share this post


Link to post
Share on other sites

Tested with Energia 0101E0010 and the new F5529 LaunchPad. It works as expected if SDA/SCL are connected to pins P3.0 / P3.1, i.e. the same pins as with the G2553.

 

The source of confusion is likely the F5529 quick start guide which shows I2C on pins P4.1 / P4.2, while Energia sticks to the backward compatible pin layout.

Share this post


Link to post
Share on other sites

Got the sensor, and with chicken's help got his demo example running. 

 

The only gotcha I encountered was that, according to the quick start guide, the F5529 LaunchPad defaults the I2C Clock and Data lines to pins 4.2 and 4.1, respectively. Who knows why? When I moved them to 3.1 and 3.0, it worked. (On this version of the LaunchPad, these latter pins are by default the SPI signals MISO and MOSI.) 

 

I also wired up an input pin to the optional EOC (end of conversion) signal from the sensor, and presumably that's working too to speed things up a bit. 

Share this post


Link to post
Share on other sites

@@abecedarian From a quick glance at the source, Energia does only check whether USCI is present and then uses UCB0, which is wired to the same pins for G2553 and F5529. 4.2/4.1 would be UCB1.

 

IMO, this makes sense as it maintains backward compatibility with the MSP430 LaunchPad. Too bad the quick start guide does not reflect this.

 

Unlike for Stellaris/Tiva, the MSP430 implementation of Wire does not yet allow to set an alternative I2C module.

 

PS: On the Tiva LaunchPad, the pins in question are actually connected with 0-ohm resistors (R9/R10), which caused its own set of confusion :)

abecedarian likes this

Share this post


Link to post
Share on other sites

Would be nice to be able to access other peripherals with similar functionality though. ;-)

As in, it would be nice to be able to mix I2C and SPI devices together, easily.

Share this post


Link to post
Share on other sites
 
  • Launchpad 1.5 msp430G2
  • 2553
  • Bosch BMP085 from sparkfun
  • (no links provided since this is Energia lib problem I think
  • using latest Energia 0101E0011 
  • Windows 7
  • code provided by OP
  • I tried searching for this error and nothing came up.  Did I miss something?  I downloaded the files, uploaded them to the Energia folder "libraries" folder I created, copied the libraries from the Arduino software, and uploaded the example file.  This is the error code I get:

 

c:/users/pat/desktop/rocket stuff/energia-0101e0011-windows/energia-0101e0011/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld.exe: cannot open linker script file memory.x: No such file or directory
collect2: ld returned 1 exit status

 

Share this post


Link to post
Share on other sites

Hmm, I haven't tried my library with the latest Energia yet. The error message doesn't ring a bell either.

 

Can you post some code to show how you use the library?

Share this post


Link to post
Share on other sites

Hmm, I haven't tried my library with the latest Energia yet. The error message doesn't ring a bell either.

 

Can you post some code to show how you use the library?

 

I used the ReadSensor.ino file included in the github zip file for this library. 

/*
 ReadSensor - Basic example of using I2C-based template library for Bosch BMP085 digital pressure sensor.
   Created by Adrian Studer, April 2013.
   Distributed under MIT License, see license.txt for details.   
*/

#include <Wire.h>          // required by BMP085 library
#include <C:/Users/Pat\Desktop/rocket stuff/energia-0101E0011-windows/energia-0101E0011/libraries/BMP085_t.h>      // import BMP085 template library

BMP085<0> PSensor;         // instantiate sensor, 0 = low precision pressure reading

void setup()
{
  Serial.begin(9600);      // initialize serial, used to display readings in Serial Monitor
  Wire.begin();            // initialize I2C that connects to sensor
  PSensor.begin();         // initalize pressure sensor
}

void loop()
{
  PSensor.refresh();                    // read current sensor data
  PSensor.calculate();                  // run calculations for temperature and pressure
  Serial.print("Temperature: ");         
  Serial.print(PSensor.temperature/10);  // display temperature in Celsius
  Serial.print(".");
  Serial.print(PSensor.temperature%10);  // display temperature in Celsius
  Serial.println("C");
  Serial.print("Pressure:    ");
  Serial.print((PSensor.pressure+50)/100);   // display pressure in hPa
  Serial.println("hPa");

  delay(5000);                          // wait a while before next loop
}

Share this post


Link to post
Share on other sites

I will have to update my Energia to reproduce.

 

Do you need the full path for the BMP085_t.h include?

 

 

#include <BMP085_t.h>

 

Should do the trick if you copied the library into the right folder.

Share this post


Link to post
Share on other sites

Well, I'm not sure that I copied it into the correct folder then. The bmp085_t.h file I copied into the "libraries" folder and tried to call it but it didn't like that. I'll go over adding files correctly to energia again.

 

Sent from my SGH-T889 using Tapatalk

 

 

Share this post


Link to post
Share on other sites

Ok, I get the same error with Energia E0011.

 

For what it's worth, even the Blink sketch throws a similar error. E0010 works just fine.

 

here the last line of the detailed compile output and the error:

 

C:\Other Programs\energia-0101E0011\hardware\tools\msp430\bin\msp430-gcc -Os
-Wl,-gc-sections,-u,main -mmcu=msp430f5529 -o
C:\Users\Adrian2\AppData\Local\Temp\build9069550804598847055.tmp\Blink.cpp.elf
C:\Users\Adrian2\AppData\Local\Temp\build9069550804598847055.tmp\Blink.cpp.o
C:\Users\Adrian2\AppData\Local\Temp\build9069550804598847055.tmp\core.a
-LC:\Users\Adrian2\AppData\Local\Temp\build9069550804598847055.tmp -lm 

c:/other programs/energia-0101e0011/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld.exe:
cannot open linker script file memory.x: No such file or directory
collect2: ld returned 1 exit status
And for what it's worth, here the same command that works in E0010:

C:\Other Programs\energia-0101E0010\hardware\tools\msp430\bin\msp430-gcc -Os
-Wl,-gc-sections,-u,main -mmcu=msp430f5529 -o
C:\Users\Adrian2\AppData\Local\Temp\build1899634374725368843.tmp\Blink.cpp.elf
C:\Users\Adrian2\AppData\Local\Temp\build1899634374725368843.tmp\Blink.cpp.o
C:\Users\Adrian2\AppData\Local\Temp\build1899634374725368843.tmp\core.a
-LC:\Users\Adrian2\AppData\Local\Temp\build1899634374725368843.tmp -lm
Maybe someone familiar with the Energia build system can spot the issue.
supamas likes this

Share this post


Link to post
Share on other sites

You know what? The "no space in path" finally got me. Interestingly it works fine for Energia 0009 and 0010.

 

Move Energia 0011 into a parent folder that has no spaces, and Blink as well as my example will compile.

supamas likes this

Share this post


Link to post
Share on other sites

I finished up my first Energia project, a template library for the Bosch BMP085 temperature and pressure sensor. It uses I2C and supports temperature in Celsius and pressure in Pascal.

 

https://github.com/astuder/BMP085-template-library-Energia

 

Hi @@chicken

 

Thank you very much for your BMP085 library. It works nicely also with the Software I2C Master Library for MSP430G2553 written by Rei Vilo. I tested with MSP430G2 Launchpad and a BMP180 breakout module (bought from Ebay). In the attached screenshot the final value of the pressure was corrected for altitude (that's why the dumped value of p and the pressure are different).

 

Istvan Cserny

 

post-699-0-88936700-1391194560_thumb.png

chicken likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now