BMP180 no pressure display


#1

Hi,

I’ve just got the BMP180 running with Cayenne on my Arduino YUN. I can see the temperature and pressure readouts on my PCs console. My dashboard, which is runing on my PCs Firefox, shows only temperatue values. The pressure widget shows nothing.

So on my PC everything runs properly, only the pressure widget on the web dashboard seems to have problem… any ideas?

Please see attached my code.

cheers,

Artur

/*
  Cayenne BMP180 Example

  This sketch shows how to send luminosity data to a BMP180 Sensor in the Cayenne Dashboard.

  The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

  Steps:
  1. Install the Adafruit Unified Sensor library (https://github.com/adafruit/Adafruit_Sensor) from the Arduino Library Manager.
  2. Install the Adafruit BMP085 Unified library (https://github.com/adafruit/Adafruit_BMP085_Unified) from the Arduino Library Manager.
  3. In the Cayenne Dashboard add a new BMP180 widget.
  4. Set the widget to Value Display.
  5. Select Virtual Pins and select virtual pins for the barometer and temperature.
  6. Set BAROMETER_PIN to the pin number you selected for the barometer.
  7. Set TEMPERATURE_PIN to the pin number you selected for the temperature.
  8. Attach a BMP180 to your Arduino.
   Schematic:
   BMP180    Arduino
   [VDD] --- [3V3]
   [GND] --- [GND]
   [SDA] --- [Analog Pin 4] (The SDA may be different on some devices, e.g. for Arduino Mega the SDA pin is Digital Pin 20)
   [SCL] --- [Analog Pin 5] (The SCL may be different on some devices, e.g. for Arduino Mega the SCL pin is Digital Pin 21)
  9. Set the token variable to match the Arduino token from the Dashboard.
  10. Compile and upload this sketch.
  11. Once the Arduino connects to the Dashboard it should automatically update the BMP180 widget with data.
*/

#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <Console.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>


// If you're not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples.
#include <CayenneYun.h>

// Virtual Pins of the BMP180 widget.
#define BAROMETER_PIN V3
#define TEMPERATURE_PIN V2

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

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "2flp3fjaer";

void setup()
{

  // Initialize Console and wait for port to open:
  Bridge.begin();
  Console.begin();

  // Wait for Console port to connect
  while (!Console);

  Console.println("Console initialized");

  //Serial.begin(9600);
  Cayenne.begin(token);
  if (!bmp.begin())
  {
    CAYENNE_LOG("No BMP sensor detected");
    Console.println("BMP180 nie hula");

    bmpSensorDetected = false;
  }
}

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

// This function is called when the Cayenne widget requests data for the barometer's Virtual Pin.
CAYENNE_OUT(BAROMETER_PIN)
{
  Console.println ("Cayenne call pressure");
  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_PIN, event.pressure);
      Console.println("event.pressure");
      Console.println(event.pressure);
    }
  }
  else
  {
    CAYENNE_LOG("No BMP sensor detected");
  }
}

// This function is called when the Cayenne widget requests data for the temperature's Virtual Pin.
CAYENNE_OUT(TEMPERATURE_PIN)
{
   Console.println ("Cayenne call temperature");

  if (bmpSensorDetected)
  {
    float temperature;
    bmp.getTemperature(&temperature);
    // Send the value to Cayenne in Celsius.
    Cayenne.celsiusWrite(TEMPERATURE_PIN, temperature);
    Console.println("temperature");
    Console.println(temperature);
  }
  else
  {
    CAYENNE_LOG("No BMP sensor detected");
  }
}