Please help me correct this code. It is the offspring of an analog pressure transducer code (MPa converted to PSI) and a 433 Mhz transmission code. When uploaded, the pressure transducer prints to the serial monitor and the transmitter transmits, however, the message transmitted is not what is printed on the serial monitor. Instead the message is letter for letter what is written after const char *msg. How can I get the transmitted message to be the converted PSI value printing on the monitor?
transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
}
void measurePressure(){
int raw = analogRead(A0);
float voltage = (float) raw * 5.0 / 1024.0; // voltage at the pin of the Arduino
float pressure_kPa = (voltage - 0.5) / 4.0 * 1200.0; // voltage to pressure
float pressure_psi = (pressure_kPa * 0.14503773773020923)+1.15; // kPa to psi
Serial.print(“pressure_psi:”);
Serial.println(pressure_psi);
vw_set_tx_pin(12); // Sets pin D12 as the TX pin
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(4000); // Bits per sec
}
void loop()
{
measurePressure();
delay(1000);
const char *msg = “pressure_psi:”; // Message to be sent
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg)); //Sending the message
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false); // Turn the LED off.
delay(50); // A short gap.
}
Moderator edit: language. Do not repeat.