NRF24L01P Water Sensor Case

NRF24L01P Water Sensor Case

thingiverse

A small case for a custom water sensor based around the PIC12F615 and NRF24L01+. The two connectors at the base of the transistor are there so if desired you can cut the PCB in two separating the main board and the sensing element. I made this to detect if my sump pump fails. I prototyped another version with a piezo buzzer, test button, and latching power supply which I will try to upload soon. I tried it on a breadboard but ultimately decided to make this minimal version for myself instead. You may have to experiment with the transistor/FET and base/gate resistor. My first version consumed up to 5mA with the sensing element under water which was enough for electrolysis to start eating away the copper on the PCB. It wasn't too rapid or a major concern since these are cheap and should rarely if ever get wet. Just an F.Y.I. A future version may disconnect power to the sensing element, or pulse to minimize long term damage. Standby current draw is less than 1uA (The limit of my meter -- which just read 0.000uA). Operating current draw is about 9-11.75mA for < 1.5 seconds. Once the alert has been sent or the maximum number of retries have occurred, the current draw is 2uA (not including the current consumed by the sensing stage). Print Settings Printer: Monoprice Maker Select Rafts: No Supports: No Resolution: 0.2mm Infill: 17% C Code #include #include "NRFComm.h" #include "NRFConfig.h" #include "NRFFunctions.h" #pragma config FOSC = INTOSCIO #pragma config WDTE = OFF #pragma config PWRTE = ON #pragma config MCLRE = OFF #pragma config CP = OFF #pragma config IOSCFS = 4MHZ #pragma config BOREN = OFF #define _XTAL_FREQ 4000000 #define NRF_CE GP1 #define NRF_CSN GP2 #define NRF_SCK GP4 #define NRF_MOSI GP5 #define NRF_MISO GP3 unsigned char NextRand = 0; unsigned char LastRand = 7; unsigned char rand(void){ NextRand = LastRand * 2917 + 353 | TMR0; LastRand = NextRand; return NextRand; } void main(void) { unsigned char attempts = 0; unsigned char NRFStatus = 0; OPTION_REG = 0b11001000; ANSEL = 0b00000000; WPU = 0b00000000; IOC = 0b00000000; TRISIO = 0b11001000; GPIO = 0b00110100; NRFInit(); NRFTXMode(); NRFOn(); ANSEL = 0b00110000; // Measure current battery voltage and send with water alert ADCON0 = 0b10010101; __delay_us(20); GO = 1; while(GO); ADCON0 = 0b00000000; ANSEL = 0b00000000; NRFpayload[0] = 0; // Sensor ID (Useful if you have multiple sensors sharing one pipe) NRFpayload[1] = rand(); // I use a pseudo random number as a data byte. // The NRF24L01+ will discard packets that are identical but still // respond with an ACK. Since the NRF will always be in the same state // once water is detected, we need the data to change to be reliably // detected on the receiving side. NRFpayload[2] = ADRESH; // Battery Status High Byte NRFpayload[3] = ADRESL; // Battery Status Low Byte NRF_writePayload(NRF_COMMAND_W_TX_PAYLOAD, 4); NRFTransmit(); while(1){ NRFStatus = NRF_readRegister(NRF_REGISTER_STATUS); if(NRFStatus & NRF_BIT_TX_DS){ NRF_setBit(NRF_REGISTER_STATUS, NRF_BIT_TX_DS); NRFOff(); GPIO = 0b00110100; // Forcing the SPI output pins high before sleep greatly reduces current draw. asm("sleep"); // Use minimum amount power until the water is dealt with } if(NRFStatus & NRF_BIT_MAX_RT){ NRF_setBit(NRF_REGISTER_STATUS, NRF_BIT_MAX_RT); NRF_writeCommand(NRF_COMMAND_FLUSH_TX); if(++attempts == 20){ // The NRF will already retry a packet up to 15 times but I added this increase the number of attempts just in case. NRFOff(); GPIO = 0b00110100; asm("sleep"); }else{ NRFpayload[1] = rand(); // Change the data byte for the same reason given above. Probably not needed here but why not. NRF_writePayload(NRF_COMMAND_W_TX_PAYLOAD, 1); NRFTransmit(); } } } }

Download Model from thingiverse

With this file you will be able to print NRF24L01P Water Sensor Case with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on NRF24L01P Water Sensor Case.