Notifications
Clear all

nrf24l01 radio.write method screws up rotary encoder output

3 Posts
3 Users
0 Likes
730 Views
(@jeffreyjene)
Member
Joined: 4 years ago
Posts: 56
Topic starter  

I have a sketch where I am trying to send data by nrf24 radio. I am gathering data from a couple of rotary encoders as well. the encoder code works perfectly until I insert a radio.write statement, at which point the values go a bit haywire, decrementing instead of incrementing, etc. I take the statement out and the problem goes away. What could be causing this issue? There isn't really anything special about the code itself. Do rotary encoders not play nice with the radio library?

This is in the loop:

//rotary encoders
//rot 1
currentCLK1 = digitalRead(CLK1);
if (currentCLK1 != prevCLK1){

if (digitalRead(DT1) != currentCLK1){
rot1 --;
}
else{
rot1 ++;
}
Serial.println(rot1);
dataArray[1] = rot1;
}
prevCLK1 = currentCLK1;


}

radio.write(&dataArray, sizeof(dataArray));

 


   
Quote
noweare
(@noweare)
Member
Joined: 4 years ago
Posts: 110
 

Radio energy can turn on transistors if the field is strong enough or near enough. For the purpose of seeing if it is interference if you can try separating the encoder from the radio module and see if that helps.

 


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

Depending on how your code works you may want to also check the timers the libraries you are using. I know some of the radio libraries reserve timers and could be messing with your rotary decoding.


   
ReplyQuote