What is the best way to see if students understood? I am teaching classes of a size of 20-25 persons.

During a class, what is the best way to get feedback from students? Concretely, I would want to get the following questions answered every ~15-20 minutes:


Did the students understand what I was explaining?
Are there any questions related to what was just discussed?


Ideally, I would also like to encourage weaker students to ask questions---without them being afraid of asking those questions.

Do you have any advise on how to best phrase such questions from my side?
I'm going to suggest that you are probably over-using lecture as a teaching technique. If that is the case, there is hardly any way to achieve the goals you set. Students don't learn something by hearing it once, or even twice. They learn by engaging with the material and that is impossible in the short term available in a lecture. At most, what you can elicit is a bit of ephemera from their short term memories. But that isn't learning. Let me suggest two techniques, but the first is, by far, the least effective. 


Force the students to take extensive notes with paper and pencil. They can use full size sheets of paper, but should also each have a deck of index cards. Encourage/require the students to record on the index cards the three most important ideas from any given lecture (one idea per card). Take time periodically, if you like, but the end of the class period is likely enough, to ask them what were the most important three ideas. Students volunteer from their already prepared cards. You can accept or veto any idea. Do this every day. Also, encourage/require students to write questions on the cards and pass them to you periodically (this is your every 15 minute solution). Quickly sift through the questions and either answer them immediately or just incorporate them into what you do going forward. At the start of the next class, ask the question, what were the three most important ideas from the previous lecture. Again, volunteers can offer suggestions. Also, see my answer to a different, but related question at CSEducators
The above, still assumes that you use lecture primarily, but this is not an optimal teaching technique. Instead, you want to learn about and use a flipped classroom. A search for "flipped classroom" on this site will reveal a lot of discussion. I point you to an answer I gave for slightly younger students but which also applies here. I try, there, to outline the idea. But the key to it is that in a flipped classroom you use the face time to work with the students, rather than to perform for them. In a situation like this, you have no doubt about their understanding as you are involved directly in developing it. 


Of these two techniques, the second is much more likely to be effective. In CS, it also gives you the opportunity to use pairing and group work so that the students can reinforce one another's learning, so that not every idea needs to come from you and so that you don't need to individually reinforce the learning of every student. Lots of wins can be achieved here. 

Since it came up in a comment, let me add that one reason to dis-favor lecture as a primary teaching technique is that students have different "learning modalities" and lecturing disadvantages some students - those who are not primarily visual or aural learners. Active learning, combined with other things, is much more effective as it reinforces the learning immediately and drives it deeper into the brain's pathways. Every student is different and instructors should realize that most students are not like themselves unless they are doing doctoral level education.