Post a new topicPost a reply Page 1 of 2   [ 12 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: I2C connection to Waspmote and AgriBoard
PostPosted: Mon Feb 20, 2012 10:43 pm 

Joined: Fri Nov 27, 2009 12:07 am
Posts: 99
Location: UK
Hi,

I have successfully got an I2C sensor working directly off the Waspmote sensor pin set - when I add an Agriboard the news is less good. The Agriboard doesn't use any I2C devices so hoping this is possible... but look forward to thoughts.


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Tue Feb 21, 2012 9:15 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7475
Hi point5,

do you have an Agriculture Board or an Agriculture PRO Board? There are no I2C devices in the first one, but in the second one you have two analog to digital converters and a digital potentiometer attached to this bus.

Regards.


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Tue Feb 21, 2012 9:43 am 

Joined: Fri Nov 27, 2009 12:07 am
Posts: 99
Location: UK
Hi, Thanks for the info.

It is the pro board I am using - can you tell me the addresses used by the onboard I2C devices please? Hopefully my device doesn't clash :-) Presumably the clock and data lines are both pulled high via 4K7 resistors so no need to use additional pullups? Does it matter which connector I use to connect to extenal I2C devices.... the 1x12 or the 2x11 ? Thanks.


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Tue Feb 21, 2012 10:13 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7475
Hi point5,

the addresses of the devices on the board are:

0010100
0010110
0101000

The resistors are internal to the microcontroller, enabled when the bus is initiated, so you don't need to add them externally, and yes, it doesn't matter which of both connectors you use, just be careful to turn on all the devices connected to the bus or you may have some problems in the communication.

Regards.


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Tue Feb 21, 2012 8:48 pm 

Joined: Fri Nov 27, 2009 12:07 am
Posts: 99
Location: UK
Thanks - I'm getting good output with just the Waspmote but wrong output when I add the AgriBoard pro. I have posted the simple code below in case I am doing something obviously wrong. The are no address clashes and the sensor is wired with no pull-up resistors. I am hoping that I am missing a vital line of code - fingers crossed :-)

Code:
#include <Wire.h>
#include <BMP085.h>
float mbar;
BMP085 bmp;
 
void setup() {
  digitalWrite(SENS_PW_3V3,HIGH);
  USB.begin();
  Wire.begin();
  bmp.begin(); 
}
 
void loop() {
    USB.print("Temperature = ,");
    USB.print(bmp.readTemperature());
    USB.print(", *C     ");
   
    USB.print("Pressure = ,");
    mbar=(bmp.readPressure());
    USB.print((mbar/100)+8.6);
    USB.println(", mBar");
   
    delay(5000);
}


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Wed Feb 22, 2012 10:09 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7475
Hi point5,

it seems your crossed fingers worked, but it isn't so obvious. You must turn on the devices that work with the I2C in the board to avoid collisions in the bus. After this line

Code:
digitalWrite(SENS_PW_3V3,HIGH);


Add this one:

Code:
SensorAgr.setSensorMode(SENS_ON, SENS_AGR_RADIATION);


If you don't want to use the Agriculture library, this sentence is equivalent:

Code:
digitalWrite(DIGITAL5, HIGH);


Please try and let us know how it worked.

Regards.


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Wed Feb 22, 2012 10:15 am 

Joined: Fri Nov 27, 2009 12:07 am
Posts: 99
Location: UK
Wonderful, I understand now :-) Thank you.

For anyone in the same boat here is the working sample code:

Code:
#include <WaspUtils.h>
#include <BMP085.h>
float mbar;
BMP085 bmp;
 
void setup() {
  SensorAgr.setSensorMode(SENS_ON, SENS_AGR_RADIATION);
  USB.begin();
  bmp.begin(); 
}
 
void loop() {
    USB.print("Temperature = ,");
    USB.print(bmp.readTemperature());
    USB.print(", *C     ");
   
    USB.print("Pressure = ,");
    mbar=(bmp.readPressure());
    USB.print((mbar/100)+8.6);
    USB.println(", mBar");
   
    delay(5000);
}


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Wed Feb 22, 2012 2:06 pm 

Joined: Fri Nov 27, 2009 12:07 am
Posts: 99
Location: UK
Testing seems good so far which is great news. One aspect which is not quite right yet though is the resolution - the BMP085 has a few different modes which control resolution depending on how much power saving is required. By default the Library requests ultra high res which works fine in standard arduino but it looks like this isn't happening on the Waspmote.

So my question is: what are the changes I need to look at making to a standard Arduino Library to make it work with fully Waspmote? In this case the BMP085 library can be viewed here: https://github.com/adafruit/BMP085-Library

Thanks for any advice.


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Wed Feb 22, 2012 4:24 pm 

Joined: Fri Nov 27, 2009 12:07 am
Posts: 99
Location: UK
Okay, I think I found the problem:

I had been doing the maths directly on bmp.readPressure(); - changing it back to how I wrote it in the code above USB.print((mbar/100)+8.6);
, with the maths being done on the float, has fixed the issue. I don't know why but it would be great to learn :-)


Top
 Profile  
 
 Post subject: Re: I2C connection to Waspmote and AgriBoard
PostPosted: Thu Feb 23, 2012 10:08 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7475
Hi point5,

that you say is pretty weird. Could you post how did you add the maths to the bmp.readPressure function?

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 12 posts ]
Go to page 1, 2  Next


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use