HI All,
Please help, I am really struggling… :x
I am new to Arduino and am working on a project using two Arduino Uno’s, a 433Mhz Transmitter and reciever and an Ultrasonic Sensor HC-SRO4. I want to send the distance data from the untrasonic sensor from one Arduino to another. The project is to monitor the Kerosene levels in a home heating oil tank using the sensor and wirelessly transmit the data to an arduino board inside the house with an LCD display on it.
Using code that I found Online I can get the Ultrasonic sensor to measure distance on one arduino. I also found code online that transmits a text message(“Hello”) from one arduino to another. I am struggling to get the code to transmit the distance data from one UNO to the other. This is the code I am working with. I think I need to packet the dat to transmit…Anyone know the code for this?
//code for testing Ultrasonic Sensor
#include <VirtualWire.h>
#define ECHOPIN 3 // pin to recieve echo pulse
#define TRIGPIN 2 // Pin to recieve Trigger Pulse
void setup ()
{
Serial.begin(9600);
pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
}
void loop ()
{
// Start Ranging - Generating a trigger of 10us burst
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGPIN,LOW);
//Distance Calculation
float distance = pulseIn(ECHOPIN, HIGH);
distance= distance/58;
Serial.print(distance);
Serial.println(" cm");
{
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
}
send (distance);
}
void send (char *distance)
{
vw_send((uint8_t *)distance, strlen(distance));
vw_wait_tx(); // Wait until the whole message is gone
delay(200);
}