Won't transmit a message after after servo rotates from water detected

Hello Good day. I am doing a project that would send a message to a receiver when the soil moisture sensor detects water. When the soil moisture sensor detects the water the servo rotates and will send "water detected " to the serial monitor of the receiver. The problem is the receiver cant receive the message when there is a servo. I am using 433mhz transmitter and receiver.

Here is my code. Please help me.

#include<Servo.h>
#include <DallasTemperature.h>
#include<OneWire.h>
#include <RH_ASK.h>
#include <SPI.h>

#define ONE_WIRE_BUS 11
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

RH_ASK rf_driver;
''
Servo myservo;
const int analogpin = A1;
int limitS =300;
int pos=180;
int smokeA0=A0;
int limitG= 230;
int limitT= 50;

void setup() {
Serial.begin(9600);
pinMode(smokeA0,INPUT);
pinMode(analogpin,INPUT);
myservo.attach(4);
rf_driver.init();

}

void loop() {
float sensorValue=analogRead(smokeA0);
float sensor=analogRead(analogpin);
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);

if(sensor>limitS){
Serial.println(" | water detected!: ");
Serial.println (sensor);
myservo.write(pos);
delay(500);
const char *msg = "1";
rf_driver.send((uint8_t *)msg, strlen(msg));
rf_driver.waitPacketSent();
exit(0);}

if (sensorValue>limitG && tempC>limitT) {
Serial.print("SUNOG\n");
Serial.println(" | Smoke detected:");
Serial.println (sensorValue);
delay(100);
myservo.write(pos);
delay(500);
const char *msg = "1";
rf_driver.send((uint8_t *)msg, strlen(msg));
rf_driver.waitPacketSent();
exit(0);
}
else{
myservo.write(0);
}
}
''

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Please post your code as per the instructions given above.

What model Arduino are you using?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

1 Like

We change the motor servo to solenoid lock and it is now working fine, We dont know how to calibrate servo with transmitter

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.