Hello everyone,
I am using a code with the fonction: pinMode(5, INPUT_PULLUP);
when the button is pushed, a led turns on. its
works perfectly on USB but the push button doesn't work with a 9v battery.
Does someone have an advice ?
Thanks a lot
Hello everyone,
I am using a code with the fonction: pinMode(5, INPUT_PULLUP);
when the button is pushed, a led turns on. its
works perfectly on USB but the push button doesn't work with a 9v battery.
Does someone have an advice ?
Thanks a lot
yes ➜ please read How to get the best out of this forum and post accordingly (including code with code tags and necessary documentation for your ask like your exact circuit and power supply, links to components etc).
Hi,
Can you please post some images of your project?
So we can see your component layout?
Where are you connecting the 9V battery?
Can you please post a copy of your circuit, 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
Do you have a DMM? (Digital MultiMeter)
What model Nano are you using?
Thanks.. Tom..
![]()
Hello, here is the code. Everything is working well in usb. I put the 9v battery in Vin and the ground.
For the Push button I have any information about it, something found somewhere.
// Receiveur
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
#include <printf.h>
// Variable pour suivre si le message "Message reçu" a été reçu
RF24 radio(9, 8); // CE, CSN
const byte address[][6] = {"00001","00002"};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
radio.begin();
radio.setChannel(124);
radio.openReadingPipe(1,address[1]);
radio.openWritingPipe(address[0]);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
pinMode(4,OUTPUT);
pinMode(5, INPUT_PULLUP);
//printf_begin();
// radio.printDetails();
}
void loop() {
// put your main code here, to run repeatedly:
char appareil[16];
int nombre;
radio.available();
char msg[32]="";
radio.read(&msg,sizeof(msg));
Serial.println(msg);
if (strcmp(msg, "STOP") == 0) {
digitalWrite(4,LOW);}
separerTexte(msg,appareil,&nombre);
Serial.println(appareil);
Serial.println(nombre);
delay(500);
if (strcmp(appareil, "A01") == 0) {
radio.stopListening();
const char envoi[]="Recu";
radio.write(&envoi, sizeof(envoi));
digitalWrite(4,HIGH);
delay(100);
radio.startListening();
char appareil ="";
}
if ((digitalRead(5) == LOW) && (digitalRead(4) == HIGH)){
digitalWrite(4,LOW);
radio.stopListening();
const char done[]="Done1";
radio.write(&done, sizeof(done));
radio.write(&done, sizeof(done));
radio.write(&done, sizeof(done));
radio.write(&done, sizeof(done));
radio.write(&done, sizeof(done));
radio.write(&done, sizeof(done));
radio.write(&done, sizeof(done));
Serial.println(done);
radio.startListening();
}
}
void separerTexte(const char *msg, char *appareil, int *nombre) {
// Copier le texte original dans une variable temporaire pour ne pas le modifier
char temp[32];
strcpy(temp, msg);
// Diviser le texte en parties en fonction de l'espace comme délimiteur
char *token = strtok(temp, " ");
// La première partie est l'appareil
strcpy(appareil, token);
// La deuxième partie est le nombre
token = strtok(NULL, " ");
*nombre = atoi(token);
}
Hi,
Are you using one of these to power a radio module as well?

They are not designed to provide much current.
Do you have a DMM? (Digital MultiMeter)
Thanks.. Tom...
![]()
Is the battery connected to VIN and GND?
Is the battery good?
Does the power (ON) LED light come ON?
Yes, this kind of battery. Everything is working properly but not the push button
Yes, the battery is connected to Vin and the ground. I tried with different new batteries but same result. The light and the other components are working properly
The push button in your code starts the radio when it pressed. The radio requires more current than such a battery can supply - so it does not work.
Thanks.. Tom..
![]()
![]()
PS. Do you have a DMM?
Are you using the NRF24L01+PA+LNA or just the NRF24L01+
NRF24L01 + adaptateur
It does before and It works well
well as you said...
that's what @b707 tells you. The 9V battery can't supply the current needed by your system. Get a better battery (a pack of 6 AA for example if you want to stay with 9V)
okay thank you ! I'm going with AA battery !
If it’s a good alkaline 9V, I don’t see why it should not work, but I don’t have one here for testing.
I would wait for a forum member to join this post who has actually used the nRF24L01 with a battery and can provide a definitive answer.