just for my documentation
please refer to real web :
https://hackaday.io/project/7008-fly-wars-a-hackers-solution-to-world-hunger/log/24646-three-dollar-ec-ppm-meter-arduino
Parts:
-MCU of your choice with ADC
-DS18B20 waterproof temperature sensor
-500 ohm [or 1kohm resistor]
-Type A Two Prong american plug to Figure 8
-Female Socket for Figure 8 connector
So why are we using a plug:
-Cheap
-Available worldwide
-Standard size [makes calibration easy]
Use the solid prong one like below and not the one with holes:
Wiring it up:
Note: You want the Solid Prong type plug
Do not Plug the pronged plug into the mains
Operating Principal
PPM is calculated from the EC of a fluid, EC is the inverse of the electrical resistance of the fluid. We are estimating the EC or PPM of a fluid by measuring the resistance between two probes [The plug pins] when the plug is submerged in the liquid of interest.
Ec measurement needs to be done using AC or the liquid of interest is polarised and will give bad readings. This has got to be a great example of asking why instead of just accepting a statement as fact, it turns out we can take a very fast DC reading without suffering polarisation. meaning we can make a really cheap EC sensor.
Want to use it and dont care how it works? Skip to the main EC code and using the wiring diagram it will work.
Temperature Compensation
Temperature has an effect on the conductivity of fluids so it is essential that we compensate for this.
It is common to use a liner approximation for small temperature changes[1] to convert them to their equivelant EC at 25*C:
EC25 = EC /( 1 + a (T - 25) )
EC25- Equivelant EC at 25'C
EC - Measured EC
T- Temperature [Decgrees C] of Measurment
a = 0.019 °C [Commonly used for nutrient solutions]
Deciding on Value of R1
//##################################################################################
//----------- Do not Replace R1 with a resistor lower than 300 ohms ------------
//##################################################################################
We can change the Value of R1 in the voltage divider to change the range of EC we want to measure. Below is the Equivalent Voltage divider circuit.
//************************** Libraries Needed To Compile The Script [See Read me In Download] ***************//
// Both below Library are custom ones [ SEE READ ME In Downloaded Zip If You Dont Know how To install] Use them or add a pull up resistor to the temp probe
#include <OneWire.h>
#include <DallasTemperature.h>
//************************* User Defined Variables ********************************************************//
//##################################################################################
//----------- Do not Replace R1 with a resistor lower than 300 ohms ------------
//##################################################################################
int R1= 1000;
int Ra=25; //Resistance of powering Pins
int ECPin= A0;
int ECGround=A1;
int ECPower =A4;
//*********** Converting to ppm [Learn to use EC it is much better**************//
// Hana [USA] PPMconverion: 0.5
// Eutech [EU] PPMconversion: 0.64
//Tranchen [Australia] PPMconversion: 0.7
// Why didnt anyone standardise this?
float PPMconversion=0.5;
//*************Compensating for temperature ************************************//
//The value below will change depending on what chemical solution we are measuring
//0.019 is generaly considered the standard for plant nutrients [google "Temperature compensation EC" for more info
float TemperatureCoef = 0.019; //this changes depending on what chemical we are measuring
//********************** Cell Constant For Ec Measurements *********************//
//Mine was around 2.9 with plugs being a standard size they should all be around the same
//But If you get bad readings you can use the calibration script and fluid to get a better estimate for K
//float K=2.88;
float K=4.25;
//************ Temp Probe Related *********************************************//
#define ONE_WIRE_BUS 10 // Data wire For Temp Probe is plugged into pin 10 on the Arduino
const int TempProbePossitive =8; //Temp Probe power connected to pin 9
const int TempProbeNegative=9; //Temp Probe Negative connected to pin 8
//***************************** END Of Recomended User Inputs *****************************************************************//
OneWire oneWire(ONE_WIRE_BUS);// Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire);// Pass our oneWire reference to Dallas Temperature.
float Temperature=10;
float EC=0;
float EC25 =0;
int ppm =0;
float raw= 0;
float Vin= 5;
float Vdrop= 0;
float Rc= 0;
float buffer=0;
//*********************************Setup - runs Once and sets pins etc ******************************************************//
void setup()
{
Serial.begin(9600);
pinMode(TempProbeNegative , OUTPUT ); //seting ground pin as output for tmp probe
digitalWrite(TempProbeNegative , LOW );//Seting it to ground so it can sink current
pinMode(TempProbePossitive , OUTPUT );//ditto but for positive
digitalWrite(TempProbePossitive , HIGH );
pinMode(ECPin,INPUT);
pinMode(ECPower,OUTPUT);//Setting pin for sourcing current
pinMode(ECGround,OUTPUT);//setting pin for sinking current
digitalWrite(ECGround,LOW);//We can leave the ground connected permanantly
delay(100);// gives sensor time to settle
sensors.begin();
delay(100);
//** Adding Digital Pin Resistance to [25 ohm] to the static Resistor *********//
// Consule Read-Me for Why, or just accept it as true
R1=(R1+Ra);// Taking into acount Powering Pin Resitance
Serial.println("ElCheapo Arduino EC-PPM measurments");
Serial.println("By: Michael Ratcliffe Mike@MichaelRatcliffe.com");
Serial.println("Free software: you can redistribute it and/or modify it under GNU ");
Serial.println("");
Serial.println("Make sure Probe and Temp Sensor are in Solution and solution is well mixed");
Serial.println("");
Serial.println("Measurments at 5's Second intervals [Dont read Ec morre than once every 5 seconds]:");
};
//******************************************* End of Setup **********************************************************************//
//************************************* Main Loop - Runs Forever ***************************************************************//
//Moved Heavy Work To subroutines so you can call them from main loop without cluttering the main loop
void loop()
{
GetEC(); //Calls Code to Go into GetEC() Loop [Below Main Loop] dont call this more that 1/5 hhz [once every five seconds] or you will polarise the water
PrintReadings(); // Cals Print routine [below main loop]
delay(5000);
}
//************************************** End Of Main Loop **********************************************************************//
//************ This Loop Is called From Main Loop************************//
void GetEC(){
//*********Reading Temperature Of Solution *******************//
sensors.requestTemperatures();// Send the command to get temperatures
Temperature=sensors.getTempCByIndex(0); //Stores Value in Variable
//************Estimates Resistance of Liquid ****************//
digitalWrite(ECPower,HIGH);
raw= analogRead(ECPin);
raw= analogRead(ECPin);// This is not a mistake, First reading will be low beause if charged a capacitor
digitalWrite(ECPower,LOW);
//***************** Converts to EC **************************//
Vdrop= (Vin*raw)/1024.0;
Rc=(Vdrop*R1)/(Vin-Vdrop);
Rc=Rc-Ra; //acounting for Digital Pin Resitance
EC = 1000/(Rc*K);
//*************Compensating For Temperaure********************//
EC25 = EC/ (1+ TemperatureCoef*(Temperature-25.0));
ppm=(EC25)*(PPMconversion*1000);
;}
//************************** End OF EC Function ***************************//
//***This Loop Is called From Main Loop- Prints to serial usefull info ***//
void PrintReadings(){
Serial.print("Rc: ");
Serial.print(Rc);
Serial.print(" EC: ");
Serial.print(EC25);
Serial.print(" Simens ");
Serial.print(ppm);
Serial.print(" ppm ");
Serial.print(Temperature);
Serial.println(" *C ");
/*
//********** Usued for Debugging ************
Serial.print("Vdrop: ");
Serial.println(Vdrop);
Serial.print("Rc: ");
Serial.println(Rc);
Serial.print(EC);
Serial.println("Siemens");
//********** end of Debugging Prints *********
*/
};
Tuesday, January 17, 2017
Wednesday, January 11, 2017
arduino water flow
Features:
Model: YF-S201
Working Voltage: 5 to 18V DC (min tested working voltage 4.5V)
Max current draw: 15mA @ 5V
Output Type: 5V TTL
Working Flow Rate: 1 to 30 Liters/Minute
Working Temperature range: -25 to +80?
Working Humidity Range: 35%-80% RH
Accuracy: ±10%
Maximum water pressure: 2.0 MPa
Output duty cycle: 50% +-10%
Output rise time: 0.04us
Output fall time: 0.18us
Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)
Pulses per Liter: 450
Durability: minimum 300,000 cycles
Cable length: 15cm
1/2" nominal pipe connections, 0.78" outer diameter, 1/2" of thread
Size: 2.5" x 1.4" x 1.4"
Model: YF-S201
Working Voltage: 5 to 18V DC (min tested working voltage 4.5V)
Max current draw: 15mA @ 5V
Output Type: 5V TTL
Working Flow Rate: 1 to 30 Liters/Minute
Working Temperature range: -25 to +80?
Working Humidity Range: 35%-80% RH
Accuracy: ±10%
Maximum water pressure: 2.0 MPa
Output duty cycle: 50% +-10%
Output rise time: 0.04us
Output fall time: 0.18us
Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)
Pulses per Liter: 450
Durability: minimum 300,000 cycles
Cable length: 15cm
1/2" nominal pipe connections, 0.78" outer diameter, 1/2" of thread
Size: 2.5" x 1.4" x 1.4"
using interupt pin
const int PinSensorWaterFlowTaman=2;// intr 0 // pin 2
float flow_countertaman,litertaman,adcph,teg,ph;
const int PinKranTaman =9;//// kran untuk taman
void setup()
{
pinMode(PinSensorWaterFlowTaman, INPUT);
digitalWrite(PinSensorWaterFlowTaman, HIGH);
attachInterrupt(0, flowtaman, RISING); // Setup Interrupt 0 pada pin 2
Serial.begin(9600);
pinMode(PinKranTaman,OUTPUT);
digitalWrite(PinKranTaman,LOW);
}
void loop()
{
Serial.println(flow_countertaman);
Serial.println(litertaman);
delay(1000);
}
void flowtaman () // Interrupt function taman
{
flow_countertaman++;
litertaman=flow_countertaman/450;
}
Tuesday, January 10, 2017
ACS712 with AC POWER
GREEN = ARDE/GROUND
WHITE = PHASE
BLACK = 0V
copas dari https://www.facebook.com/dani.ardianto.rajacell
//Mengukur arus pada tegangan AC 220V dengan Sensor ACS712
//Analog Output ACS712 pada PIN A0
const int sensorIn = A0;
const int sensorIn = A0;
int mVperAmp = 185;
//Konversi A ke mV
// use 185 for ACS712 5A
// use 100 for ACS712 20A
// use 66 for ACS712 30A
//Konversi A ke mV
// use 185 for ACS712 5A
// use 100 for ACS712 20A
// use 66 for ACS712 30A
double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
double VRMS = 0;
double AmpsRMS = 0;
void setup(){
Serial.begin(9600);
}
Serial.begin(9600);
}
void loop(){
Voltage = getVPP();
VRMS = (Voltage/2.0) *0.707;
AmpsRMS = (VRMS * 1000)/mVperAmp;
Serial.print(AmpsRMS);
Serial.println(" Amps RMS");
Voltage = getVPP();
VRMS = (Voltage/2.0) *0.707;
AmpsRMS = (VRMS * 1000)/mVperAmp;
Serial.print(AmpsRMS);
Serial.println(" Amps RMS");
}
float getVPP()
{
float result;
int readValue; //value read from the sensor
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here
float getVPP()
{
float result;
int readValue; //value read from the sensor
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here
uint32_t start_time = millis();
while((millis()-start_time) < 1000) //sample for 1 Sec
{
readValue = analogRead(sensorIn);
// see if you have a new maxValue
if (readValue > maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the maximum sensor value*/
minValue = readValue;
}
}
while((millis()-start_time) < 1000) //sample for 1 Sec
{
readValue = analogRead(sensorIn);
// see if you have a new maxValue
if (readValue > maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the maximum sensor value*/
minValue = readValue;
}
}
// Subtract min from max
result = ((maxValue - minValue) * 5.0)/1024.0;
return result;
}
result = ((maxValue - minValue) * 5.0)/1024.0;
return result;
}
Monday, December 12, 2016
arduino HC-SR04 anti bounching
HC-SR04
unsigned long delay1,delay2;
if (jarak<=30){
if (millis()-delay1>=2000){
digitalWrite(relay,LOW);
}
}
else { delay1=millis();}
if (jaraK>=200){
if (millis()-delay2>=2000){
digitalWrite(relay,HIGH);
}
}
else { delay2=millis();}
unsigned long delay1,delay2;
if (jarak<=30){
if (millis()-delay1>=2000){
digitalWrite(relay,LOW);
}
}
else { delay1=millis();}
if (jaraK>=200){
if (millis()-delay2>=2000){
digitalWrite(relay,HIGH);
}
}
else { delay2=millis();}
Monday, November 28, 2016
NRF24L01 for remote relay
NRF24L01 for remote relay
//receiver
#include <SPI.h> // SPI Arayüzünü dahil ettik.
//#include "nRF24L01.h"
#include "RF24.h" // RF24 kütüpanelerini dahil ettik.
#include <Wire.h>
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
// Init a Time-data structure
Time t;
uint32_t targetTime = 0;
uint8_t hh = 0, mm = 0, ss = 0, dd = 0, bb = 0; //variable Unsignet int 0-255
int yy = 0; //variable integer
byte data[1]; // Göndereceğimiz data değişkenini oluşturduk.
boolean var; // Bit şeklinde var değişkeninini oluşturduk.
const uint64_t pipe = 0xF0F0F0F0E1LL;
RF24 radio(9, 10); // Modülün CE pinini 9.pin CS pinini de 10.pine bağlayacağımızı belirttik.
int r1 = 0, r2 = 0, r3 = 0;
void setup() {
Serial.begin(57600);
pinMode(3, OUTPUT); digitalWrite(3, HIGH);//kolam renang
pinMode(5, OUTPUT); digitalWrite(5, HIGH);//kolam naga
pinMode(7, OUTPUT); digitalWrite(7, HIGH); //lampu naga
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
rtc.begin();
}
void loop() {
// NRF remote
if (radio.available()) {
bool var = false;
while (!var) {
var = radio.read(&data, 1);
}//while
if (data[0] == 1 && r1 == 0) {
digitalWrite(3, LOW);
// Serial.println("RELAY 3 LOW");
r1 = 1; data[0] = 0;
}
if (data[0] == 1 && r1 == 1 ) {
digitalWrite(3, HIGH);
//Serial.println("RELAY 3 HIGH ");
r1 = 0; data[0] = 0;
}
if (data[0] == 2 && r2 == 0) {
digitalWrite(5, LOW);
//Serial.println("RELAY 5 LOW");
r2 = 1; data[0] = 0;
}
if (data[0] == 2 && r2 == 1 ) {
digitalWrite(5, HIGH);
//Serial.println("RELAY 5 HIGH ");
r2 = 0; data[0] = 0;
}
if (data[0] == 3 && r3 == 0) {
digitalWrite(7, LOW);
//Serial.println("RELAY 7 LOW");
r3 = 1; data[0] = 0;
}
if (data[0] == 3 && r3 == 1 ) {
digitalWrite(7, HIGH);
//Serial.println("RELAY 7 HIGH ");
r3 = 0 ; data[0] = 0;
}
}//if
t = rtc.getTime(); // gate all data time & date from RTC
hh = t.hour, DEC; //pengambilan data jam
mm = t.min, DEC; //pengambilan data menit
ss = t.sec, DEC; //pengambilan data detik
//Serial.print (hh); Serial.print (F(" : "));
//Serial.print (mm); Serial.print (F(" : "));
//Serial.println (ss);
//jam 9 pagi
if (hh == 10 && mm == 0 && ss == 0) {
digitalWrite(3, LOW);//kolam renang
digitalWrite(5, LOW);//kolam naga
digitalWrite(7, HIGH);//lampu naga //relay 3
}
if (hh == 15 && mm == 0 && ss == 0) {
digitalWrite(3, HIGH);//kolam renang
digitalWrite(5, HIGH);//kolam naga
digitalWrite(7, HIGH);//lampu naga
}
delay(1000);
}
// transmitter
#include <SPI.h>
//#include "nRF24L01.h"
#include "RF24.h"
#include <PinChangeInterrupt.h>
#include <avr/sleep.h>
volatile byte flag = 0;
void handler() {
flag = 1;
//Serial.println("wake up");
//delay(100);
detachPinChangeInterrupt(3);
detachPinChangeInterrupt(5);
detachPinChangeInterrupt(7);
}
byte data[1];
const uint64_t pipe = 0xF0F0F0F0E1LL;
RF24 radio(9, 10); // Modülün CE pinini 9.pin CS pinini de 10.pine bağlayacağımızı belirttik.
unsigned long nowTime;
unsigned long start1;
unsigned long previousMillis = 0;
unsigned long startSleep;
int kirim = 0,btn3,btn5,btn7;
int sleepStatus = 0; // variable to store a request for sleep
int count = 0; // counter
void wakeUpNow() {}
void setup() {
Serial.begin(57600);
pinMode(3, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(13, INPUT);
digitalWrite(13, LOW);
attachPCINT(digitalPinToPCINT(3), handler, CHANGE);
attachPCINT(digitalPinToPCINT(5), handler, CHANGE);
attachPCINT(digitalPinToPCINT(7), handler, CHANGE);
radio.begin();
radio.setRetries(15,15);
radio.openWritingPipe(pipe);
radio.startListening();
}
void sleepNow(){
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
attachPCINT(digitalPinToPCINT(3), handler, CHANGE);
attachPCINT(digitalPinToPCINT(5), handler, CHANGE);
attachPCINT(digitalPinToPCINT(7), handler, CHANGE);
sleep_mode();
sleep_disable();
detachPinChangeInterrupt(3);
detachPinChangeInterrupt(5);
detachPinChangeInterrupt(7);
}
void loop() {
//Serial.println("bgn");
btn3 = digitalRead(3);
btn5 = digitalRead(5);
btn7 = digitalRead(7);
if(flag == 1){
if (btn3==0) {
data[0] = 1;
Serial.println("RELAY 3 ");
}
else if (btn5==0) {
data[0] = 2;
Serial.println("RELAY 5 ");
}
else if (btn7==0) {
data[0] = 3;
Serial.println("RELAY 7 ");
}
radio.stopListening();
radio.write( &data, sizeof(unsigned long) );
radio.startListening();
delay(1000);
data[0]=9;
flag = 0;
}//flag
startSleep = millis();
if(startSleep - previousMillis >= 3000) {
previousMillis = startSleep;
Serial.println("sleep");
sleepNow();
}
}//end loop
//receiver
#include <SPI.h> // SPI Arayüzünü dahil ettik.
//#include "nRF24L01.h"
#include "RF24.h" // RF24 kütüpanelerini dahil ettik.
#include <Wire.h>
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
// Init a Time-data structure
Time t;
uint32_t targetTime = 0;
uint8_t hh = 0, mm = 0, ss = 0, dd = 0, bb = 0; //variable Unsignet int 0-255
int yy = 0; //variable integer
byte data[1]; // Göndereceğimiz data değişkenini oluşturduk.
boolean var; // Bit şeklinde var değişkeninini oluşturduk.
const uint64_t pipe = 0xF0F0F0F0E1LL;
RF24 radio(9, 10); // Modülün CE pinini 9.pin CS pinini de 10.pine bağlayacağımızı belirttik.
int r1 = 0, r2 = 0, r3 = 0;
void setup() {
Serial.begin(57600);
pinMode(3, OUTPUT); digitalWrite(3, HIGH);//kolam renang
pinMode(5, OUTPUT); digitalWrite(5, HIGH);//kolam naga
pinMode(7, OUTPUT); digitalWrite(7, HIGH); //lampu naga
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
rtc.begin();
}
void loop() {
// NRF remote
if (radio.available()) {
bool var = false;
while (!var) {
var = radio.read(&data, 1);
}//while
if (data[0] == 1 && r1 == 0) {
digitalWrite(3, LOW);
// Serial.println("RELAY 3 LOW");
r1 = 1; data[0] = 0;
}
if (data[0] == 1 && r1 == 1 ) {
digitalWrite(3, HIGH);
//Serial.println("RELAY 3 HIGH ");
r1 = 0; data[0] = 0;
}
if (data[0] == 2 && r2 == 0) {
digitalWrite(5, LOW);
//Serial.println("RELAY 5 LOW");
r2 = 1; data[0] = 0;
}
if (data[0] == 2 && r2 == 1 ) {
digitalWrite(5, HIGH);
//Serial.println("RELAY 5 HIGH ");
r2 = 0; data[0] = 0;
}
if (data[0] == 3 && r3 == 0) {
digitalWrite(7, LOW);
//Serial.println("RELAY 7 LOW");
r3 = 1; data[0] = 0;
}
if (data[0] == 3 && r3 == 1 ) {
digitalWrite(7, HIGH);
//Serial.println("RELAY 7 HIGH ");
r3 = 0 ; data[0] = 0;
}
}//if
t = rtc.getTime(); // gate all data time & date from RTC
hh = t.hour, DEC; //pengambilan data jam
mm = t.min, DEC; //pengambilan data menit
ss = t.sec, DEC; //pengambilan data detik
//Serial.print (hh); Serial.print (F(" : "));
//Serial.print (mm); Serial.print (F(" : "));
//Serial.println (ss);
//jam 9 pagi
if (hh == 10 && mm == 0 && ss == 0) {
digitalWrite(3, LOW);//kolam renang
digitalWrite(5, LOW);//kolam naga
digitalWrite(7, HIGH);//lampu naga //relay 3
}
if (hh == 15 && mm == 0 && ss == 0) {
digitalWrite(3, HIGH);//kolam renang
digitalWrite(5, HIGH);//kolam naga
digitalWrite(7, HIGH);//lampu naga
}
delay(1000);
}
// transmitter
#include <SPI.h>
//#include "nRF24L01.h"
#include "RF24.h"
#include <PinChangeInterrupt.h>
#include <avr/sleep.h>
volatile byte flag = 0;
void handler() {
flag = 1;
//Serial.println("wake up");
//delay(100);
detachPinChangeInterrupt(3);
detachPinChangeInterrupt(5);
detachPinChangeInterrupt(7);
}
byte data[1];
const uint64_t pipe = 0xF0F0F0F0E1LL;
RF24 radio(9, 10); // Modülün CE pinini 9.pin CS pinini de 10.pine bağlayacağımızı belirttik.
unsigned long nowTime;
unsigned long start1;
unsigned long previousMillis = 0;
unsigned long startSleep;
int kirim = 0,btn3,btn5,btn7;
int sleepStatus = 0; // variable to store a request for sleep
int count = 0; // counter
void wakeUpNow() {}
void setup() {
Serial.begin(57600);
pinMode(3, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(13, INPUT);
digitalWrite(13, LOW);
attachPCINT(digitalPinToPCINT(3), handler, CHANGE);
attachPCINT(digitalPinToPCINT(5), handler, CHANGE);
attachPCINT(digitalPinToPCINT(7), handler, CHANGE);
radio.begin();
radio.setRetries(15,15);
radio.openWritingPipe(pipe);
radio.startListening();
}
void sleepNow(){
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
attachPCINT(digitalPinToPCINT(3), handler, CHANGE);
attachPCINT(digitalPinToPCINT(5), handler, CHANGE);
attachPCINT(digitalPinToPCINT(7), handler, CHANGE);
sleep_mode();
sleep_disable();
detachPinChangeInterrupt(3);
detachPinChangeInterrupt(5);
detachPinChangeInterrupt(7);
}
void loop() {
//Serial.println("bgn");
btn3 = digitalRead(3);
btn5 = digitalRead(5);
btn7 = digitalRead(7);
if(flag == 1){
if (btn3==0) {
data[0] = 1;
Serial.println("RELAY 3 ");
}
else if (btn5==0) {
data[0] = 2;
Serial.println("RELAY 5 ");
}
else if (btn7==0) {
data[0] = 3;
Serial.println("RELAY 7 ");
}
radio.stopListening();
radio.write( &data, sizeof(unsigned long) );
radio.startListening();
delay(1000);
data[0]=9;
flag = 0;
}//flag
startSleep = millis();
if(startSleep - previousMillis >= 3000) {
previousMillis = startSleep;
Serial.println("sleep");
sleepNow();
}
}//end loop
Subscribe to:
Posts (Atom)



