BMP180 using 433MHz modules

Hello, I'm using BMP180 sensor and I want to send data (only pressure) via simple 433Mhz module and get it. I can read sensor, but I can't send this data. I'm trying to combine RadioHead library for transmitter with SFE_BMP180 libary. Maybe someone could help me? In the code below in the end I just left original RadioHead code example for word ''hello''.

#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#include <SFE_BMP180.h>
#include <Wire.h>
SFE_BMP180 pressure;
#endif
RH_ASK driver;
void setup()
{
  if (pressure.begin())
Serial.println("BMP180 init success");
else
{
Serial.println("BMP180 init fail\n\n");
Serial.println("Check connection");
while (1);
}
#ifdef RH_HAVE_SERIAL
    Serial.begin(9600);	  // Debugging only
#endif
    if (!driver.init())
#ifdef RH_HAVE_SERIAL
         Serial.println("init failed");
#else
	;
#endif
}
void loop()
{
  char status;
double  P, T;
status = pressure.startPressure(3);
if (status != 0)
{
delay(status);
status = pressure.getPressure(P, T);
if (status != 0)
{
Serial.print(" pa = ");
Serial.print(P * 0.000986923, 2);
}
 
}
    const char *msg = "hello";

    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
    delay(200);
}

Read the forum guidelines to see how to properly post code and some hints on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Edit your original post by selecting the code and clicking the </> in the menu bar.

code tags new

It is best to send integer data, rather than "double", as the configuration of a double variable depends on which Arduino you are using.

To do so using RadioHead, you can use something like the following:

    int data = get_pressure();  //scale to mBar or hPa?
    driver.send((uint8_t *) &data, sizeof(data));

The receiving program has to be modified accordingly.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.