Hi,
I tried to use a KY-040 with the BluePill to create a menu on an Oled display, using Arduino IDE, and the Encoder.h library, but when I compile, it tells me that the library needs and interrupt pin, but the board does not. So, any solutions to just read the a value from the encoder !?
almost every library on GitHub has a subfolder examples
The one for STM32-encoder has a lot of examples.
You should choose one of these example that seem to be promising for you
and then try to use it. It might well be that it does not work by connect your encoder and just uploading the example.
Then you post this example demo-code together with a description what results you have combined with a question like "what do you recommend doing as the next step for narrowing down the problem?"
the code has to detect each single pulse.
The code has to determine the rotating-direction from the difference which pulse occured first
and based on that count up/down
The KY-40-rotary encoder has mechanical switches which means that the code has to do debouncing. (=filtering out the fast ON/OFF-switching that all mechanical switches suffer from)
There are two ways to achieve this:
polling: which means your main program has to run very fast to be able to check the two IO-pins 1000 times per second to really detect each change in the switch-state
This means you can't use a single delay() in your code. At least not in case you want to read from the rotary-encoder
using an interrupt to detect each change in the switch-state
@MicroBahner
have you ever thought about expanding your library to support rotary-encoders based on a timer-interrupt?
post your complete sketch.
How should I know which example-code you used?
How should I know what this example-code has for additional information that explains which IO-pins are used?
You'll need to consult the processor's datasheet. The pins that you connect the encoder to depend on which STM32 device you're using and which timer within that device. See the comments in the example code:
STM32encoder enc(TIM2); // create a manager encoder by TIM2.
// You have to use TIM input pin to connect encoder to.
// i.e. for STM32F103 TIM2 has PA0 and PA1 inputs. See device documentation for other TIMs input pins
BTW, is there some specific reason you're using an STM32 board? There are many other boards out there that will work with the more standard encoder libraries .... Teensy, Adafruit, Arduino, ESP8266, ESP32
Well, trying to make an RC Transmitter with the NRF24L01, I first tried to use an ESP32 DOIT DevKit V1, but the NRF24L01 didn't work with it. Then, I opted for the BluePill because it's easy to program with the Arduino IDE (wich turns out to be a bit of a problem) has a lot of pins, a small size, and a big flash memory (wich then turns out to be small because apparently when the Arduino IDE compiles the code, it adapts it to make it compatible with the STM32, wich uses a lot of space in the Flash Memory, but if there is an alternative that works with the NRF24L01, an oled display, an encoder, and has at least 7 analog in pins, and in total at least 25pins you can tell me about it
Why do you say NRF24L01 doesn't work with ESP32? If seen no discussion along those lines in the forums.
As for other choices, the PJRC Teensy Line is my go-to choice for many projects.
All that being said, as long as you have the BluePill, I don't think there's a reason not to use it. The STM32encoder library that @StefanL38 linked seems pretty comprehensive. Just use the pins associated with the timer that you select .... as I advised in Post #14.
There may also be other Encoder libraries that work with STM32 that I'm simply not aware of. Finally, you could roll your own encoder-handling code based the the link I posted in Post #11.
Because apparently it does not pack data packages, and it could't even send a text. I think it's a power issue.
There is a problem, and it is the huge amount of memory occupied by the IDE when compiling, and the NRF module is not stable in communication, for example, I programmed it to sent a text every one second, but it does send it on random moments. For example it sends now, then after 3 seconds, then it stops for a long moments, so I reset, and it does the same thing again and again
Lacking real details, I'm thinking Pilot Error. If you power it properly (not from the processor board's regulator) it will work. But, make sure you buy extra because every now and then you'll find one that's no good. I guessing nowadays they all have knock-off Chinese NFR chips, not genuine Nordic.
That doesn't even make any sense. The IDE occupies memory on your PC, not the target board.
Again, most likely due to hardware setup. Power it properly and follow Robin2's Tutorial. Hundreds of people have had success with it.
In tunisia, everything is overpriced, 25$ in TND equals to max 80 dinars (wich is still a lot) but it is sold for 180dinars
A 16Kb code compiled for an arduino card is equal to 16Kb, but for the STM32 it is much above that
I tried powering it with an external fully charged 21700 battery, with the M.1 power regulator, but it was somehow worse than the onboard board's regulator, the led was not as bright as from the onboard regulator, and it did not even send anything.
Ahhhhh ..... That is indeed unfortunate. It's a decent argument for staying with the hardware that you have. But, I think the original topic of this thread has been addressed. Use the STM32encode Library Linked in Post #4 to make working with the rotary encoder easier.
If you like, you can start a new thread asking for help with your NRF24L01 problems. You'll need to post a complete schematic, pictures of your wiring connections, and the results you get when using the code from Robin2's Tutorial. Using that code (that has worked for hundreds of people) will make debugging any hardware problems easier.
Finally, regarding your concerns about code size .... you can start another new thread. Post your complete code and your explanation as to why you think the size is a problem.