-
AuthorPosts
-
April 28, 2020 at 7:53 PM #15373makszParticipant
Hi! I have a problem with SPI after wakeup. I use nrf24l01 radio. When I set powerDown arduino gets wrong data. The program lights diode when it receives 0 and vice versa. The problem is when it goes power down and wakes up from an interrupt (onReceive), it reads byte wrong. I checked on serial port and it reads 1 instead of 0, 0 instead of 1 and it randomly changes. The data which the radio receives is correct. If there is no power down the program is working as expected. I can’t figure it out. I use version 1.8. Thanks.
#include <LowPower.h> #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> #define diode 5 RF24 radio(7, 8); // CE, CSN const byte address[6] = "00001"; volatile unsigned long pingTime = 0;; void onReceive(){ bool message; radio.read(&message, sizeof(message)); digitalWrite(diode, !message); pingTime = millis(); } void connectionLost(){ digitalWrite(diode, LOW); delay(424); digitalWrite(diode, HIGH); delay(424); } void setup() { pinMode(diode, OUTPUT); digitalWrite(diode, HIGH); radio.begin(); radio.openReadingPipe(0, address); radio.setPALevel(RF24_PA_MAX); radio.maskIRQ(1,1,0); radio.setChannel(29); radio.setDataRate(RF24_2MBPS); radio.startListening(); attachInterrupt(0, onReceive, LOW); if (radio.available()){ onReceive(); } pingTime = millis(); } void loop() { unsigned long timeNow = millis(); noInterrupts(); bool isTimeout = timeNow - pingTime > 9000; bool ISRErrCheck = pingTime <= timeNow; interrupts(); if(isTimeout && ISRErrCheck){ connectionLost(); } LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF); //NOT working if present }
December 23, 2020 at 5:42 PM #15848RileyMuellerParticipantIf you are looking for the best zero turn mower for 3 acres, you need to read more articles about this topic. Before I get started, however, please make sure that you are ready to get your hands dirty by mowing your lawn or even your garden because some of the information in this article is a little controversial.
-
AuthorPosts
- You must be logged in to reply to this topic.