Okay, so first of all, i am a noob at this. I have only been playing around with arduino for a few weeks, so i am really bad at coding.
Enough excuses.
I just bought some 433MHz transmitter and receiver modules.
I can send a message that i write myself, like now i'm sending "Stupid arduino" cause i'm mad, well whatever.
But if i write celsius(float from my TMP102 sensor) instead of "Some message" it gives me the error "cannot convert 'float' to 'const char*' in initialization"
I have tried googling, but i haven't found a workaround.
I really hope someone can help me
Transmitter code:
// 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>
#include <Wire.h>
int tmp102Address = 0x48;
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup"); // Prints "Setup to the serial monitor"
Wire.begin();
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()
{
float celsius = getTemperature();
const char *msg= "Stupid arduino"; // Message to be sent
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg)); //Sending the message
//vm_send((uint8_t *)celsius, 5)
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false); // Turn the LED off.
delay(1000); // A short gap.
}
float getTemperature(){
Wire.requestFrom(tmp102Address,2);
byte MSB = Wire.read();
byte LSB = Wire.read();
int TemperatureSum = ((MSB << 8) | LSB) >> 4;
float celsius = TemperatureSum*0.0625;
return celsius;
}
Receiver code:
/*
** Example Arduino sketch for SainSmart I2C LCD Screen 16x2
** based on https://bitbucket.org/celem/sainsmart-i2c-lcd/src/3adf8e0d2443/sainlcdtest.ino
** by
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:
** https://bitbucket.org/fmalpartida/new-liquidcrystal
** Modified - Ian Brennan ianbren at hotmail.com 23-10-2012 to support Tutorial posted to Arduino.cc
** Written for and tested with Arduino 1.0
**
** NOTE: Tested on Arduino Uno whose I2C pins are A4==SDA, A5==SCL
*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <VirtualWire.h>
#define I2C_ADDR 0x27 // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int n = 1;
int count;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup"); //Prints "Setup" to the serial monitor
vw_set_rx_pin(12); //Sets pin D12 as the RX Pin
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(4000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
lcd.begin (16,2); // <<----- My LCD was 16x2
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
lcd.clear();
int i;
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
lcd.print("Got: ");
lcd.setCursor (0 ,1 );
for (i = 0; i < buflen; i++)
{
char c = (buf[i]);
lcd.print(c);
}
count++;
// Serial.print(count);
lcd.println("");
digitalWrite(13, false);
}
}