Week 4

From the webiste the uni brought the componets they had tutuarials on how to link the BMP180 to a online server called Cayenne. this allows us to see the results on the internet from any were so you dont need to set up the srduino to the computurer to get the results.

To do this you need 3 components the ardiuno board, the arduino ethernet shield and the BMP180 sensor.
ethernet-and-bmp180_bb

Once it has been set up the next thing to do is use a code that runs the bmp180 and also sends the information to the website.

The code i have got is from the website I am sending the information to but changed it slightly.

#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include
#include
#include
#include

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = “alirostam”;
char password[] = “Rostam101”;
char clientID[] = “rostam101@hotmail.co.uk”;

#define TEMPERATURE_VIRTUAL_CHANNEL 1
#define BAROMETER_VIRTUAL_CHANNEL 2

Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10180);
bool bmpSensorDetected = true;

void setup()
{
Serial.begin(9600);
Cayenne.begin(username, password, clientID);
if (!bmp.begin())
{
CAYENNE_LOG(“No BMP sensor detected”);
bmpSensorDetected = false;
}
}

void loop()
{
Cayenne.loop();
}

// This function is called at intervals to send temperature sensor data to Cayenne.
CAYENNE_OUT(TEMPERATURE_VIRTUAL_CHANNEL)
{
if (bmpSensorDetected)
{
float temperature;
bmp.getTemperature(&temperature);
// Send the value to Cayenne in Celsius.
Cayenne.celsiusWrite(TEMPERATURE_VIRTUAL_CHANNEL, temperature);
}
else
{
CAYENNE_LOG(“No BMP sensor detected”);
}
}

// This function is called at intervals to send barometer sensor data to Cayenne.
CAYENNE_OUT(BAROMETER_VIRTUAL_CHANNEL)
{
if (bmpSensorDetected)
{
// Send the command to get data.
sensors_event_t event;
bmp.getEvent(&event);

if (event.pressure)
{
// Send the value to Cayenne in hectopascals.
Cayenne.hectoPascalWrite(BAROMETER_VIRTUAL_CHANNEL, event.pressure);
}
}
else
{
CAYENNE_LOG(“No BMP sensor detected”);
}
}

This code should send the information directly to the cayenne website and i can obtain my results from there.

My parts have not arrived in time to check to see if this would work in time for the presentation. But by watching the step by step tutorial on there website Im pretty sure that it is going to work correctly.

After I have done the test on these parts and i am confident that it is going to work correctly I will go to the next step of my project and start by designing the product i am going to get to react to the readings of the BMP180 sensor.

code2flow_a3cec

 

Advertisements

Week 3 Testing

After looking more into my component from last time I realised some of the libraries that I downloaded for the coeds last time have test on them to check if the board is working correctly.

The first test was the BMP085 TEST. It gave me a sketch to run on my board to check to see if it was functioning correctly.

Adafruit_BMP085 bmp;

void setup() {
Serial.begin(9600);
if (!bmp.begin()) {
Serial.println(“Could not find a valid BMP085 sensor, check wiring!”);
while (1) {}
}
}

void loop() {
Serial.print(“Temperature = “);
Serial.print(bmp.readTemperature());
Serial.println(” *C”);

Serial.print(“Pressure = “);
Serial.print(bmp.readPressure());
Serial.println(” Pa”);

// Calculate altitude assuming ‘standard’ barometric
// pressure of 1013.25 millibar = 101325 Pascal
Serial.print(“Altitude = “);
Serial.print(bmp.readAltitude());
Serial.println(” meters”);

Serial.print(“Pressure at sealevel (calculated) = “);
Serial.print(bmp.readSealevelPressure());
Serial.println(” Pa”);

// you can get a more precise measurement of altitude
// if you know the current sea level pressure which will
// vary with weather and such. If it is 1015 millibars
// that is equal to 101500 Pascals.
Serial.print(“Real altitude = “);
Serial.print(bmp.readAltitude(101500));
Serial.println(” meters”);

Serial.println();
delay(500);

After i uploaded this sketch i checked the serial monitor and the message “could not find valid BMP085 senor” so just to make sure again it wasn’t me i checked the component with another test.

The second test I did was the sensorapi test.

#include
#include
#include

/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
which provides a common ‘type’ for sensor data and some helper functions.

To use this driver you will also need to download the Adafruit_Sensor
library and include it in your libraries folder.

You should also assign a unique ID to this sensor for use with
the Adafruit Sensor API so that you can identify this particular
sensor in any data logs, etc. To assign a unique ID, simply
provide an appropriate value in the constructor below (12345
is used by default in this example).

Connections
===========
Connect SCL to analog 5
Connect SDA to analog 4
Connect VDD to 3.3V DC
Connect GROUND to common ground

History
=======
2013/JUN/17 – Updated altitude calculations (KTOWN)
2013/FEB/13 – First version (KTOWN)
*/

Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);

/**************************************************************************/
/*
Displays some basic information on this sensor from the unified
sensor API sensor_t type (see Adafruit_Sensor for more information)
*/
/**************************************************************************/
void displaySensorDetails(void)
{
sensor_t sensor;
bmp.getSensor(&sensor);
Serial.println(“————————————“);
Serial.print (“Sensor: “); Serial.println(sensor.name);
Serial.print (“Driver Ver: “); Serial.println(sensor.version);
Serial.print (“Unique ID: “); Serial.println(sensor.sensor_id);
Serial.print (“Max Value: “); Serial.print(sensor.max_value); Serial.println(” hPa”);
Serial.print (“Min Value: “); Serial.print(sensor.min_value); Serial.println(” hPa”);
Serial.print (“Resolution: “); Serial.print(sensor.resolution); Serial.println(” hPa”);
Serial.println(“————————————“);
Serial.println(“”);
delay(500);
}

/**************************************************************************/
/*
Arduino setup function (automatically called at startup)
*/
/**************************************************************************/
void setup(void)
{
Serial.begin(9600);
Serial.println(“Pressure Sensor Test”); Serial.println(“”);

/* Initialise the sensor */
if(!bmp.begin())
{
/* There was a problem detecting the BMP085 … check your connections */
Serial.print(“Ooops, no BMP085 detected … Check your wiring or I2C ADDR!”);
while(1);
}

/* Display some basic information on this sensor */
displaySensorDetails();
}

/**************************************************************************/
/*
Arduino loop function, called once ‘setup’ is complete (your own code
should go here)
*/
/**************************************************************************/
void loop(void)
{
/* Get a new sensor event */
sensors_event_t event;
bmp.getEvent(&event);

/* Display the results (barometric pressure is measure in hPa) */
if (event.pressure)
{
/* Display atmospheric pressue in hPa */
Serial.print(“Pressure: “);
Serial.print(event.pressure);
Serial.println(” hPa”);

/* Calculating altitude with reasonable accuracy requires pressure *
* sea level pressure for your position at the moment the data is *
* converted, as well as the ambient temperature in degress *
* celcius. If you don’t have these values, a ‘generic’ value of *
* 1013.25 hPa can be used (defined as SENSORS_PRESSURE_SEALEVELHPA *
* in sensors.h), but this isn’t ideal and will give variable *
* results from one day to the next. *
* *
* You can usually find the current SLP value by looking at weather *
* websites or from environmental information centers near any major *
* airport. *
* *
* For example, for Paris, France you can check the current mean *
* pressure and sea level at: http://bit.ly/16Au8ol */

/* First we get the current temperature from the BMP085 */
float temperature;
bmp.getTemperature(&temperature);
Serial.print(“Temperature: “);
Serial.print(temperature);
Serial.println(” C”);

/* Then convert the atmospheric pressure, and SLP to altitude */
/* Update this next line with the current SLP for better results */
float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA;
Serial.print(“Altitude: “);
Serial.print(bmp.pressureToAltitude(seaLevelPressure,
event.pressure));
Serial.println(” m”);
Serial.println(“”);
}
else
{
Serial.println(“Sensor error”);
}
delay(1000);
}

Again after uploading the sketch i checked the serial monitor. Ooops, no BMP085 detected. So Im pretty sure that my sensor is not functioning correctly and i have orderd an new one to come.

While I wait for a new component to come I started to think what I could do with this and I thought about a product that would react to the temperature and weather out side. So I was thinking of a stuffed animal that makes certain faces or movement depending on the weather. I also wanted to be able to check the results easily. And instead of me having to set it up every time on my laptop. So I found some tutorials online on how to connect the sensor to a Ethernet shield and get your results instantly streamed to a website that you can connect with your phone. So I have ordered a Ethernet shield to pair with my ardiuno board.

Week 2 Individual Research

Image result for bmp180 labeled

I decide to start and to assemble my part. the diagram above shows a four pin bmp180 sensor but mine has 5 pins. But I only need to set up four of them.

On BMP180  On Arduino Board
VCC 3V3
GND GND
SCL A5
SDA A4

After setting up the circuit I needed to find some example codes online:

The first code i found and tries was a code by Smart Microcontroller Channel

void setup() {
Serial.begin(9600);
bmp.begin();
}

void loop() {
Serial.print(“Temperature = “);
Serial.print(bmp.readTemperature());
Serial.println(” C”);

Serial.print(“Pressure = “);
Serial.print(bmp.readPressure());
Serial.println(” Pa”);

Serial.print(“Altitude = “);
Serial.print(bmp.readAltitude());
Serial.println(” meters”);

Serial.println();
delay(2000);

But using this code I found that I was getting false readings and that i would only be given the pressure and the altitude and not the temperature. and the readings it give me for the pressure and the altitude were wrong as well.

Temperature  0.0C 
Pressure  234 Pa 
Altitude  30367.0 Meters 

To check that it wasn’t the code that was wrong and not me or the BMP180 I tried a different code.

This code was by Paul McWhorter

#include “Wire.h” // imports the wire library for talking over I2C
#include “Adafruit_BMP085.h” // import the Pressure Sensor Library
Adafruit_BMP085 mySensor; // create sensor object called mySensor

float tempC; // Variable for holding temp in C
float tempF; // Variable for holding temp in F
float pressure; //Variable for holding pressure reading

void setup(){
Serial.begin(9600); //turn on serial monitor
mySensor.begin(); //initialize mySensor
}

void loop() {
tempC = mySensor.readTemperature(); // Read Temperature
tempF = tempC*1.8 + 32.; // Convert degrees C to F
pressure=mySensor.readPressure(); //Read Pressure

Serial.print(“The Temp is: “); //Print Your results
Serial.print(tempF);
Serial.println(” degrees F”);
Serial.print(“The Pressure is: “);
Serial.print(pressure);
Serial.println(” Pa.”);
Serial.println(“”);
delay(250); //Pause between readings.
}

 

I had to change this code slightly those as this guy has set it up to tell the temperature in Fahrenheit.

But again in this coding the results were coming out wrong. The pressure was again 234 Pa and there was no temperature.

Next thing i need to do is try and find some test i can do to see if my part is working correctly.

Week 1 Individual Research

The BMP180 Barometric sensor module can give accurate measurement of the temperature, pressure in the air and altitude. Barometric sensors can be used to work out the weather. As from the pressure from the air and the temperature we can work out weather. because the sensor can also work out the altitude it can also be used as a altimeter.

 

The BMP180 has a consists of a piezo-resistive sensor, an analog to digital converter and a control unit with EEPROM and a serial I2C interface. The BMP180 delivers the uncompensated value of pressure and temperature. The EEPROM has stored 176 bit of individual calibration data. This is used to compensate offset. Temperature dependence and other parameters of the sensor.