Update*
I already figure out how to use the sprintf() function and I found out that it only work well with positive integers.
So based from How to sprintf a float with Arduino - Yet Another Arduino Blog
I'll use dtostrf function instead as it support negative integers too.
I already manage to transmit the temperature over RF433 Mhz via this coding
Transmitter
#include <VirtualWire.h>
#include <SPI.h>
#include <max6675.h>
#include <SoftwareSerial.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
int SO = 8;
int CS = 9;
int CLK = 10;
MAX6675 temp(CLK,CS,SO);
char msg1[6];
void setup() {
Serial.begin(9600);
vw_set_tx_pin(12);
vw_setup(2000);
}
void loop() {
Serial.print("Cel.:");
Serial.println(temp.readCelsius()-10);
float c = temp.readCelsius()-10;
Serial.print("Original value1: ");
Serial.println(c);
char str[50];
strcpy(str, "String value using dtostrf1: ");
dtostrf(c, 2, 2, &str[strlen(str)]);
Serial.println(str);
Serial.println();
dtostrf(temp.readCelsius()-10, 6,2,msg1);
delay(2000);
vw_send((uint8_t *)msg1,strlen(msg1));
vw_wait_tx();
}
And Receiver
#include <VirtualWire.h>
#include <LiquidCrystal.h>
#include <SPI.h>
LiquidCrystal lcd (2,3,4,5,6,7);
byte msg1[VW_MAX_MESSAGE_LEN];
byte msgLength1 = VW_MAX_MESSAGE_LEN;
void setup() {
Serial.begin(9600);
Serial.println("Ready");
lcd.begin(16, 2);
vw_set_rx_pin(11);
vw_setup(2000);
vw_rx_start();
}
void loop() {
lcd.clear();
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(msg1, &msgLength1))
{
lcd.setCursor(0,0);
lcd.print("Cel:.");
for (int i = 0; i < msgLength1; i++)
{
lcd.write(msg1[i]);
}
delay(2000);
}
}
I manage to send 1 Data to the LCD which is Celsius attach picture
But I cant seem to figure out how to send 2 Data over which are Celsius & Fahrenheit
temp.readCelsius()-10
(temp.readCelsius()*9/5)+32
Anyone know the coding how to send both reading to LCD16x2?
I need Celsius on (0,1) and Fahrenheit on (0,2) LCD screen position.
