Hi
Analog pressure cannot accept data from the sender. I use Arduino Uno and I will use 2 analog pressure sensors, I use modul nRF24L01 .
Whether the code below is correct or wrong.
Please help for the correct code
Transmiter 1 :
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define pot_pin A0
RF24 radio(9,10);
const uint64_t pipes[3] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0E3LL };
void setup() {
Serial.begin(9600);
pinMode(pot_pin,INPUT);
radio.begin ();
radio.setDataRate(RF24_1MBPS);
radio.setChannel(35);
radio.setPALevel(RF24_PA_MIN);
radio.openReadingPipe(1, pipes[1]);
}
void loop() {
radio.stopListening ();
int value = analogRead(pot_pin);
float voltage = (value5.0)/1024.0;
float pressure_pascal = (3.0((float)voltage-0.47))1000000.0;
float pressure_bar = pressure_pascal/10e5;
float pressure_psi=pressure_bar14.5038;
radio.write(&pressure_bar, sizeof(pressure_bar));
Serial.print("Transmitting Data : ");
Serial.println(pressure_bar);
delay(50);
}
=================================================================
Receiver :
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define buzzerPin 2
#define threshold 6
#define led_pin 3
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27);
RF24 radio(9,10);
const uint64_t pipes[3] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0E3LL };
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
radio.begin();
radio.setDataRate(RF24_1MBPS);
radio.setChannel(35);
radio.setPALevel(RF24_PA_MIN);
radio.openReadingPipe(1, pipes[1]);
radio.openReadingPipe(2, pipes[2]);
// radio.startListening();
}
void loop() {
// put your main code here, to run repeatedly:
radio.startListening();
if (radio.available())
{
while (radio.available())
{
int value = 0 ;
float voltage = (value5.0)/1024.0;
float pressure_pascal = (3.0((float)voltage-0.47))1000000.0;
float pressure_bar = pressure_pascal/10e5;
float pressure_psi=pressure_bar14.5038;
radio.read(&pressure_bar, sizeof(pressure_bar));
Serial.print("Received Data : ");
Serial.println(pressure_bar);
lcd.begin(16,2);
lcd.setBacklight(255);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Pressure:”);
lcd.print(pressure_bar);
lcd.print("Bar ");
delay(1000);
if(pressure_bar < threshold){
delay(50);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Pressure low”);
lcd.setCursor(0,1);
lcd.print(“Check Tank”);
delay(500);
tone(buzzerPin, 440);
digitalWrite(led_pin, HIGH);
delay(400);
noTone(buzzerPin);
digitalWrite(led_pin, LOW);
delay(50);
}
else {
noTone(buzzerPin);
digitalWrite(led_pin, LOW);
lcd.setCursor(0,1);
lcd.print(“Pressure Normal”);
delay(1000);
}
}
}
}
Thank You
Regards