Ralph - Please don't take my comments as being negative - but I would like to point out a couple of mis-statements you made in the video if people are actually attempting to implement some of the code you are presenting. At time 27:27 you suggest using a struct to compose the message packet to be sent. I think you were thinking of a 16 bit micro when you made that part of the video. The Blue Pill is a 32 bit cpu so ints - either signed or unsigned are 4 bytes in size. Double is most likely 8 bytes (depending on your compiler settings) and the size of your struct is MUCH larger than you stated. Besides the incorrect sizes for the ints and double -- most C and C++ compilers for the STM32 align struct elements on 4 byte boundaries - so your "byte" will be size 4 - not size 1. What you want to do is surround your struct definition with the #pragma pack(1). This will force all padding to be eliminated. You can check your struct size by using sizeof() to see what the actual message size is. I do all my work bare-metal - no libraries - using a GCC C compiler. I don't use the Arduino IDE. If what I stated is incorrect for the STM32 on Arduino - I'm sorry for making my comment and potentially confusing someone. Keep up the good work.
@RalphBacon2 жыл бұрын
I was most definitely thinking in Arduino terms (so 8-bit, really). Silly mistake that no-one else noticed, thank goodness. Good points you raise and I'll try some of them out next time I fire up a Blue Pill (or clone).
@JonHeckendorf5 жыл бұрын
Nice video. When I was doing some reliability and statistical analysis on military devices back in the sixties, I found what's now known as infant mortality which affects electronic devices. It turns out that nearly all electronic devices, if they are to die, will die during the first 20-hours of operation. If the device survives its first 20-hours of operation, plus or minus, it's more likely to last for its rated lifetime (MTBF, MTTR). Infant mortality is a factor to be aware of no matter if a device is a clone or not.
@RalphBacon5 жыл бұрын
I guess my soak test/burn-in sorted that nRF24L01+ out then! It's probably worthwhile letting something run for a day or so non-stop before deciding it's fit for full-time duty. Good job it failed when it did, in some ways. Thanks for your insights, Jon, a most valuable lesson for anyone reading your post.
@JonHeckendorf5 жыл бұрын
@@RalphBacon Thanks, Ralph. Burn-in is a real test and should be done for reliability purposes if the device is to used for an actual project. It's early in the morning for me so I hope that made sense. I enjoy your videos so keep them a coming.
@RalphBacon5 жыл бұрын
Made no sense at all Jon. Just kidding. Yes, I think I might adopt a burn-in process for all my components that I use in the field. It's one thing for something to stop working on a workbench, another thing entirely if it stops when implemented as a project in your attic or beehive.
@adrianolarescu51295 жыл бұрын
I found the struct method a year ago and used on a self made remote controlled boat using arduino and nrf24l01+ the modules with amplification and 2db antenna and tested them before using it in the boat and had a range of around 400m (the max I could walk that time) with no package lost, this are great modules and I got them from china under 2$ per module, probably clones but very good ones. I also got some bad clones which were useless, lost connection in under a meter, unreliable transmition.... When you find a good seller for this modules stick with that one
@RalphBacon5 жыл бұрын
Clones (or fakes) can really be hit and miss, Adrian. If you find a good supply, and the seller can confirm it's the same batch, buy more in one go (once you've tested a couple initially).
@superdau5 жыл бұрын
Even with those small adapter boards I suggest adding a capacitor between GND and VCC directly on the nRF-PCB. I had horrible reliability issues with the modules if I didn't. I have two other things I faintly remember having issues with and it might even have been when using "while (radio.available())". The auto-ack threw a wrench into my programs a few times, especially if you have ack-payload enabled. Also if I remember correctly, a sender will always receive the ACK back on pipe 0 (because pipe 0 is the source address the package was sent with in the first place). Another thing was that if you query the nRF too quickly (like reading its status with radio.available() does) it can't keep up and returns bogus over SPI. The library doesn't cope with that. Has been more than half a year that I did something with an nRF24, so what I wrote might not be accurate.
@RalphBacon5 жыл бұрын
What you're describing seems to tally with my results. When I artificially slowed it all down it all just worked so much better. It would be quite good to keep it like this in production, just for ease of debugging if nothing else!
@tonyfremont3 жыл бұрын
I've found that connecting an electrolytic cap on the power and ground pins, right on top of the board, it will greatly help with reliability and range. Greatly
@RalphBacon3 жыл бұрын
Indeed, power issues are one of the biggest problems with the nRF24L01. Using a capacitor across the power pins does help, ideally about 220uF or even larger if it fits!
@roberteliassen50205 жыл бұрын
11:44 Interesting question indeed. Do we need ACK for, say temperature readings in a greenhouse? First you have to answer the question: What do we do if we didn't get an ACK? If the answer is "nothing", then we do not need ACKs. :-) An UDP stream (like video) doesn't need ACK because an error or missing data doesn't matter. It's too late to do anything about it. I use UDP (unacknowledged of course) for temperature readings. I take a reading every 5 or 10 seconds and if one or two got lost it doesn't really matter. Anyway... Thanks for another great video, Ralph.
@RalphBacon5 жыл бұрын
That's fine, Robert (where have you been hiding?), but if you only send the data every 30 minutes a lost packet could seriously impact the accuracy of data. I suppose it might be a tradeoff between packet frequency (you send it every 5 or 10 seconds so plenty of redundancy) and infrequent but acknowledged packets. The reason for less frequent packets might be that you measuring a slow changing unit such as rainfall - you might want to measure it for a good 5 minutes or more before sending out the data to make it meaningful; a lost packet there could be bad news. Interesting point you make, thanks for posting, nice to hear from you again.
@roberteliassen50205 жыл бұрын
@@RalphBacon I've been following you, but not commenting that frequently. :-) I agree on the ACK being a nice feature, and sometimes you really need to be sure a packet has been received. Especially when the data is more than 32 bytes and you have to chop it up in 32 byte packets. Without ACK you are lost (or you might have an ACK for the entire transfer, but that might be a waste of bandwidth). There is a variety of different ways to deal with ACKs and NAKs (Negative ACK, or Not ACK). One way is to put a "serial number" (increasing index) on each frame (32-byte packet) and let the transmitter transmit many frames and then acknowledge the last one (with the serial number/frame number). That implies the receiver has got all the other frames. In that way you can transmit a "burst" of frames, and then expect an ACK for the last one. That saves bandwidth. If you get an ACK for, let's say the penultimate one, you know you have to resend the last one. This is of course way more advanced and impractical for a simple temperature reading from a greenhouse or a beehive.
@uwezimmermann54275 жыл бұрын
around minute 25: about your variable definitions - those are quite safe if you make sure that you do not change platform or compiler version. In order to make sure that your compiler does not mess up things when switching between different platforms I would recommend to define the variables in a different way: int16_t instead of signed int, uint16_t instead of unsigned, int32_t and uint32_t for the long int and avoid using floating point numbers alltogether in the communication protocol - those can be transformed into scaled integers, like giving them in 1/10 or 1/100 or 1/64 or whatever.
@RalphBacon5 жыл бұрын
You are correct of course, Uwe, but beginners to the Arduino world will not understand uint8_t and would get very confused. It's a pity Arduino did not insist on those terms from the start, it would have made things more understandable, but there we are.
@uwezimmermann54275 жыл бұрын
@@RalphBacon do you really think that uint8_t is so much more difficult to understand than "unsigned short"? Once one has grasped the idea of bits and bytes - which should be necessary to begin with - counting the number of bits and just using one pattern for the variable types is quite logical, much more so than arbitrary "short", "long", "long long" declarations.
@RalphBacon5 жыл бұрын
I totally agree, Uwe, but beginners get very easily put off by things that seem technical or mathematical, so I've discovered along the way. I hate the long, short, unsigned which can change with each platform. Perhaps I should promote the "correct" way, the C++ way of doing things in my video demo code?
@shaunstewart40645 жыл бұрын
Thanks for this. I have only recently stumbled across this channel and I am now an avid viewer. I have been struggling with getting my stm32s to talk reliably even with a stable power supply. I will give this library a try. I intend to use the devices to transmit telemetry from a remotely controlled vehicle to a base station. A video on how to communicate say a "JSON" string of arbitrary length would be great ;).
@RalphBacon5 жыл бұрын
An avid viewer you say, Shaun, I like you already! Now you may have heard me say things like "Don't send strings using this" because you only have 32 bytes, which would be a very short JSON string indeed. Another solution is probably needed, like the 433MHz solution I mentioned, like an HC-12 433 SI4463 device, see here: www.banggood.com/HC-12-433-SI4463-Wireless-Serial-Module-Remote-1000M-With-Antenna-p-973522.html?p=FQ040729393382015118& I'd love to investigate this device further but time is against me right now. Or see my Benny cat run (rain) device that works using a simple 433MHz device and has been error free for years: Videos #46, #48 and #54.
@shaunstewart40645 жыл бұрын
@@RalphBacon As it happens, I received a pair of HC-12s a few days ago. I am learning a great deal from your channel. All the best :)
@philchadwick94705 жыл бұрын
Regarding unexplained death of adaptor. Could be ESD. Not necessarily on your bench. I was reading up on how to incorporate ESD protection into designs and that led me to a page showing how ESD (at any point in time from production to the finished product) can partially damage a trace within a chip creating a high resistance hotspot which eventually pops like a fuse. There'll be no external sign of that.
@RalphBacon5 жыл бұрын
Sounds very likely, Phil, given that I was actually not near the chip when it died. Most of these devices have been absolutely fine, however. Thanks for that information, always useful to know these things.
@jacobdavis0005 жыл бұрын
I like how you chose to use the bluepill too. I love these boards and have using 15 of them for a few months. I ended up tryng the E22 boards by EByte and I have been having quite good luck with them. The devices have a choice between LoRa or FSK too. I'm going to try FSK soon. BTW: Great channel, sir!
@RalphBacon5 жыл бұрын
Thanks for your kind words, Dave, and I'm happy you're here with me on my Arduinite (we don't discriminate against other platforms) journey!
@tylerufen5 жыл бұрын
5:20 No, the ACK payload isn't returning the TX payload; the ACK payload is a payload of up to 32 bytes that you can attach to any one individual ACK signal, if you set it during RX, it will be sent along the ACK, but the next ACK after that won't have a payload unless you set one...
@RalphBacon5 жыл бұрын
I'm sorry if I was not clear on the ACK payload (I deliberately didn't talk about it as it just muddied the water). What you describe is spot on. In some ways we could deliver the Slave data as part of the ACK and not do a separate transmission at all - is that good practice, I wonder?
@svengaefgen59095 жыл бұрын
"f you set it during RX, it will be sent along the ACK" no, that is not true. It will enqueue an ACK payload, which in most cases will be the next ACK payload delivered. However, RX is a good place to reload the ACK data after a reception that consumed the waiting one. When a reception is signaled, the ACK process is at least already running, probably it will already be finished. ACK payload has to be loaded before a reception on that pipe takes place.
@RalphBacon5 жыл бұрын
Good to know, Sven, I would like to test this out... when I have a few nanoseconds to spare. What this means though is that I cannot send back the reply as the ACK, because I must get the ACK payload ready _before_ I read the transmission - the contents of which I don't know. Shame. But for a greenhouse temperature reading it would be ideal, where the Master is simply saying "Give me" and the Slave says "Message received and here is your data too" all in the one package.
@svengaefgen59095 жыл бұрын
@@RalphBacon The 'old' ACK payload problem can be solved easily by sending two requests directly adjacent. The first request gives the ACK payload responding node the chance to queue updated ACK payload data.
@svengaefgen59095 жыл бұрын
@@RalphBacon Yes, for a nice bidirectional connection I think that is the best way to go. Switching to TX blinds the node for some time, which can be avoided if it sends only via ACK payload, which could be done to three targets at the same time, due to the three entry TX fifo limitation. There is a Serial via NRF24L01+ modul set somewhere that probably uses that technique (at least I would implement it that way).
@roberteliassen50205 жыл бұрын
The if (radio.available()) and while (radio.available()) was a puzzle! I believe the reason has to do with timing. The only difference between the two is that the "if" will leave the loop() and the "while" will not. That means the "while" will check radio.avilable() a few clock ticks sooner than the "if". When you exit the loop() there will be a few clock ticks until you reenter the loop(). You can try to put a tiny delay (1 ms) at the end of the while-loop.
@RalphBacon5 жыл бұрын
I shall experiment with a simple 1ms delay and see if it helps, Robert. A bit weird though, I have no problems using this on the Arduino Uno. Perhaps the chips are too fast - they were not STM32s, one was a GD32, the other a CKS32. Maybe that's the reason?!
@roberteliassen50205 жыл бұрын
@@RalphBacon Ah, so it works on an Uno. Quite interesting. Now, what happens between the last } in the loop-function and the first { is a bit of a mystery. And it could even be different things depending on the MCU in use. One might think there is nothing going on after the MCU leave the loop and starts over, but there most certainly is. It could even be updating the radio object! In that case a delay will not help. I doubt that's the case however. We should be able to trust the state of that object. The "radio"-object is probably updated in a timer interrupt, which means there will be some delay in its state. Should be documented though... Edit: Read the source and I was wrong. The library is more or less just an SPI interface to the RF24. But I'm pretty sure SPI uses interrupt. That means the delay(1) should work.
@3v1Bunny4 жыл бұрын
maybe late. But auto ACK is via shockburst packets. the ack is only sent when the CRC (8 or 16) matches. So you do actually know it received that specific packet in one piece (sure even with crc 16 accidents can happen) .
@RalphBacon4 жыл бұрын
Does that mean that if the CRC does _not_ match no ACK is sent (ie you acknowledge a [probably] uncorrupted package or you don't respond so it be sent again)?
@3v1Bunny4 жыл бұрын
@@RalphBacon The documentation states that no packet that fails the CRC will be processed by shockBurst (copied to the rx buffer and interrupts set) so we can 'safely' assume no ack will be sent which will automatically trigger a resend in the TX on timeout.
@RalphBacon4 жыл бұрын
That's good news. No acknowledgement means "Send it again". That's a nice touch. I should read that datasheet more fully! Thanks for letting me know, appreciated.
@asagk5 жыл бұрын
18:42 I like the way you turn one screen downwards while turning another one into view. Whenever I try this, I break a monitor, if not even both. :)
@RalphBacon5 жыл бұрын
It was murder developing the circular frame at the back to allow that. And all the cables get tangled if I do it too much.
@asagk5 жыл бұрын
@@RalphBacon I was already having the impression you might use some sort of secret video magic to make it happen! It turns out, it is exactly like that, if I do understand you correctly. Nice video by the way!
@wonkastudio-johnny4 жыл бұрын
hi Ralph, how can you download the RF24-STM.h file ? i dont see a zip download ?
@RalphBacon4 жыл бұрын
Go to the GitHub. Click the big, green button that says *Code* and then select *Download ZIP* That way you get everything and can just unzip it and extract what you want.
@UpcycleElectronics5 жыл бұрын
28:41 I think you just explained what I've had trouble with, and why structs have not made much sense to me. I still don't fully understand the functionality of declaring a struct, defining it, and *then creating an instance of it.* I get the impression there is some use for multiple instances of a struct but I can't seem to intuitively navigate this on my own. I think my main issue is the instance declaration. Why isn't this created like a variable, pointer, or array? What is this struct instance in terms of ones, zeros, and registry level hardware? Is it like some higher level subroutine reference that contains a bunch of variables or something? How is this different than classes like the ones typically seen in Arduino libraries? Thanks for the upload. -Jake
@RalphBacon5 жыл бұрын
A struct is the very first introduction into Object Oriented Programming (aka OOP). It's not _real_ OOP, for that you would use classes (see my video #71 on how to create a Library) but this is the precursor to that. You have the design of how you want the receptacle to look, so you describe in the struct, a bit like an architect designing an extension to your house. It's not _the_ extension, just a paper description of it. In C++ having made the description to your liking you can then declare that _type_ just as you can an integer or long or string. Amazing! You've just invented a new data type (sort of). It's just a collection of other types, in the order you have declared them, but it's still a collection (bunch of variables). You can create as many _instances_ (another OOP word) as you like, just as you can when using integers, as long as each has a unique instance name (just like integers and the like). So you could declare 5 instances of this new struct type for 5 different nRF24L01s that you are communicating with. You seem to have already understood this, Jake. Don't doubt yourself! Play about with them using my example as a starting point. It's probably easier than you are thinking, and doing it will reveal all!
@UpcycleElectronics5 жыл бұрын
@@RalphBacon I think I understand. I was leaning towards the idea of a struct being sort of like a data type. I can think of a few times I've needed something like this but have used functions and strings to manipulate and print variables. The struct is basically (almost) like a framework for a special array with multiple data types. Sorry, I'm slow and always jumping around from one project to another (due to physical limitations mostly). Your upload got this subject on the back of my mind, while I've got a KiCAD dev board design in front of me, going on day 2, have two almost finished power supply projects on the bench and have been goofing around with Forth for the last 2 weeks. I need to clone myself to fill all the rabbit holes I've jumped down :-) The bit about naming multiple instances of a struct for multiple modules makes sense. Thanks. -Jake
@Bob_Burton5 жыл бұрын
@@UpcycleElectronics You can also do this if you only want one instance of a named struct struct { byte aByte; int anInt; } aStruct; void setup() { Serial.begin(115200); aStruct.aByte = 123; aStruct.anInt = 456; Serial.println(aStruct.aByte); Serial.println(aStruct.anInt); }
@RalphBacon5 жыл бұрын
Yes, excellent point to make, Bob, thumbs up!
@Roy_Tellason4 жыл бұрын
@@RalphBacon I got into c programming (a bit) many years ago, and always liked the idea of structs. They're not a c++ thing, particularly.
@dnarobo5 жыл бұрын
Big fan of this channel and a recent owner of a Atten solder unit a smart fellow suggested...while I don't want to do MESH....I would be interested in learning more about the code needed for a master slave setup, where perhaps there are three units in play. So many examples of master/slave are just one master one slave. The concepts/code needed to handle 2+ slaves is something that is eluding me.
@RalphBacon5 жыл бұрын
You're the third person to ask this, Dave, so it's obviously quite important. My (abbreviated) reply was that the Master (transmitter) used in this demo could poll up to 5 slaves asking each for their data. So, use a different pipe for each Slave, with a unique address, and ask each in turn in just the same way as I did it for one here. Just loop round every few seconds (or whatever your logic dictates), load the correct address/pipe and ask that slave. Make sense? Need more?
@Noxoreos5 жыл бұрын
If your data is just a series of the same type (up to 32 bytes), you could have just used a data array. Just don't forget to remove the ampersand character, when passing it to the write function, because arrays are basically references already.
@RalphBacon5 жыл бұрын
Yes, indeed, as long as the array is a collection from the same source, eg humidity over several readings. What I wouldn't want is a different _meaning_ to each of the array's elements; for example, array[0] is the humidity, array[1] is the UV strength and so on. In that case a struct is more suitable as it's self-documenting. Thanks for the reminder and good point about arrays already being references.
@ridvanmelihsahin94793 жыл бұрын
Hello Sir, I can use two devices on my pcb. These are using a SPI Communication so I made my pcb design with this in mind. I selected my microprocessor with this in mind. My Mcu is STM32F103C8T6. My first device is ADC and I selected SPI1 pins, and second device is NRF24L01 and I selected SPI2 pins. I try to some coding example but I failed. I think reason is that I can write or add some library and some coding line. But I didnt know. If you have an idea, reply this post and we discuss. Thank you!
@RalphBacon3 жыл бұрын
I would suggest you write a couple of simple sketches, using SPI-1 in one sketch and SPI-2 in the other. See if you can get them working. Only when you have, write a third simple sketch combining them both. That way you know the individual SPI busses are working and it can only be your combined code that is not doing something when it should.
@michaelhyde99715 жыл бұрын
Great video as usual Ralph. Can you do some more on pcb design. I have just made my first bord. Now I have the bug and wont to do more complex designs. Thanks for all the work you do for us.
@RalphBacon5 жыл бұрын
I want to design a new PCB asap but I don't know where the time goes to, Michael. I blame the dog. He won't help, that's the issue.
@SpeccyMan5 жыл бұрын
It's Friday again, it must be time for a video from Ralph. I've actually seen another channel produce a very nice PCB design for a radio control system using Pro Minis and these radio modules. It seems to work very well. My little robot buggy still uses bluetooth for now but I am thinking about a proper radio control system for it.
@RalphBacon5 жыл бұрын
Remember the major limitation of this device is the 32-byte package, Nick, does your robot buggy need more? Nice that you look forward to my videos, thanks for posting.
@daque19605 жыл бұрын
Hello. Have you noticed the cheap stm32F401 boards in the same layout as your blue pill that are under $5US on Aliexpress? Search for STM32F401CCU6 the black ones seem to have been updated so you dint have to move jumpers and 4x the program room plus a floating point unit on it if you do a lot of math can really help, 84 mhz too I think
@RalphBacon5 жыл бұрын
The list goes on, David! There is _always_ a better chip out there, including this one. Regarding the STM32f103 modules, if the bootloader is correctly loaded then there is no need to move the jumpers either. If you can't get the bootloader to connect successfully to USB then it most likely a fake STM32 chip. Do NOT ask me how I know this, and why it took me weeks before I got some decent boards that "just worked". Grrr.
@daque19605 жыл бұрын
Ralph S Bacon ti fulfill my need for speed I have a couple Teensy 4.0’s ($20) to play with. 600 mhz and 64-bit floating point unit. My first desktop was a 4K radio shack color computer at .9 mhz if I remember correctly. Have a wonderful day.
@RalphBacon5 жыл бұрын
The new Teensy 4.0? That is a ridiculous amount of power, but when you're running NASA I suppose it will come in useful! Just remember that 640K is enough for anyone.
@partouelectric23534 жыл бұрын
Hi Mr.Bacon, If I knew what editor and compiler you were using and how you set up your serial monitor, it would help me a great deal
@RalphBacon4 жыл бұрын
I'm using the Eclipse (Sloeber) IDE, but the very same avr-gcc compiler that everyone uses. eclipse.baeyens.it/
@paulyorke14375 жыл бұрын
Excellent Ralph, really helpful and for me, timely. Now just need your expertise to sort SPI display clues :-) Excellent tutorial, thanks
@RalphBacon5 жыл бұрын
Indeed, it never stops, Paul. So many platforms, so many projects. Have you managed to organise support for a 35 hour day yet?
@Roy_Tellason4 жыл бұрын
@@RalphBacon I used to think that 40 hours would be about right. Then I came to the conclusion (?) that maybe I'd been born on the wrong planet? I've since gotten over that, pretty much. The pile keeps on getting bigger, and if I get to it, fine, if I don't, then it's not a big deal because I'll have been busy getting into something else that was at least as much fun. Sound about right? And yeah, I blame the dog, too. :-)
@eduardbaciu88603 жыл бұрын
Just to make sure I understood, the voltage regulator of an arduino is capable of supplying enough power to nRF24 but the one from STM32 isn't? Using an adapter wouldn't it take power from the same place on STM32 ?
@RalphBacon3 жыл бұрын
The Arduino cannot deliver enough 3v3 to support the nRF24L01 for it to work reliably, that's for sure. The Arduino 5v supply can supply the adapter plate for the nRF24 because that has a 5v regulator on it. Regarding the STM32 you could take the 5v supply to the adapter plate of the nRF24 the same, and it would be fine, but I'd hesitate at using the STM32's 3v3 supply.
@gsuresh2u3 жыл бұрын
Hi, Good info What is the pin connections for STM32F411CE (Black Pill) ? Please help
@RalphBacon3 жыл бұрын
This should help: stm32-base.org/assets/img/boards/STM32F411CEU6_WeAct_Black_Pill_V2.0-2.jpg
@RalphBacon3 жыл бұрын
You choose the GPIO pin and then specify which one you have chosen in the code for the nRF24L01.
@skipdaniels58755 жыл бұрын
Ralph have you tried to have multiple transmitters on different channels to on receiver, looping through the channels, maybe using delays to change the channel e.g. 15 minute intervals. Just a thought. Great video and use for the blue pill
@RalphBacon5 жыл бұрын
No, I haven't, Skip, but you could use one Master and several (up to 5) Slaves, requesting each to send their data back on a different channel, see my reply to Mike Kendig above, we're all thinking along the same lines!
@leachim665 жыл бұрын
Another very helpful videos as always Ralph, thanks for the good content
@RalphBacon5 жыл бұрын
Thanks, Mike, nice to hear that. Thanks for posting.
@williammiller75435 жыл бұрын
If you wern't a teacher, you should have been .You have a very good way of getting the technical ideas translated into understandable english. In you case the "Kings English" but understood well in the US!. Thanks for all your good videos. I've run into the struct before but never understood it. If you get enough interest in it from your viewers, could you spend another video or portion thereof to go into structure a little deeper. I had been trying to use TimeLib and converting time_t , tmElements_t using epoch time, trying to get into TimeZone.. all very confuing usinga Reat Time Clock module. They all uses different basis for variables and structure of variables.
@RalphBacon5 жыл бұрын
If you look at my code for my Home Alone (vulnerable person) project on my GitHub, William, you will see that I use the TimeLib and successfully implement DST in two different zones (UK and Europe). It's working 100% reliably on an ESP8266 but the library works for the Arduino too. This may help you. Be warned the code is about 2000 lines but you are only interested in about 100 of those!
@williammiller75435 жыл бұрын
@@RalphBacon Thanks, I'll give it a look.
@nehiripere4277 Жыл бұрын
what is using IDE at 7:45?
@RalphBacon Жыл бұрын
That looks like an old version of the Eclipse IDE, no longer supported. These days I use Visual Studio Code with PlatformIO for all my coding.
@nehiripere4277 Жыл бұрын
@@RalphBacon Thank you
@partouelectric23534 жыл бұрын
HI Ralph, Thanks for your very nice video. I am trying to send a square wave signal of 30 Hz with NRF and STM 32 I am using Arduino 1.8.13, with FR24.h library, but it is doing nothing. of cores I am using a push button on the TX side with no luck. RF24-STM.h library does not compile even after putting it in the include library. Power supply wise I am using external 5V and 3.3 V power supplies.. I would appreciate your advice. Your code is .cpp, what compiler are you using
@RalphBacon4 жыл бұрын
Change the .cpp to .ino and it will compile the same. But sending a square wave signal is a bit strange. The Nrf24 is designed to send (up to) 32 bytes as a packet of data not stream a continuous signal. What are you trying to do?
@partouelectric23534 жыл бұрын
@@RalphBacon Thanks for your reply, Sir. I am sending a squire wave to a receiver close by, running a wire is not practical. I will count the number of pulses every 0.5 seconds my data will be an integer which I will send. The receiver will recoinstruct my data to a set of serial pulses. I am hopping the serial puls will not have a glitch between packets. This way transmission is taking place every 0.5 seconds with about 0.5 seconds delay which is OK. What do you think about using 433 meg transmitter. Which one is more reliable(Which is very important). Do you know who sels geniuand parts Thans again for your advice
@mikekendig67815 жыл бұрын
Greetings from Denver. Another great video. I have a question about using multiple sending units. I have a rather large garden and want to send data from 4 or 5 different areas. Is this possible using your code as a framework ? I had a thought about pulling each of the sending units to ensure that only 1 unit was sending at a time. I would love to hear your thoughts. Mike
@RalphBacon5 жыл бұрын
It certainly adds a level of complexity, Mike, because each sender does not know when another one might send at the same time and overlap. It would be better to initiate the transmission in much the same way as I have done it here, with the Master effectively asking each Slave in turn to send back their data. You can use all 5 channels for 5 (slave) units. Um, I think that's what you just said. I should read comments properly first. In which case, spot on, yes, that's the way I would do it!
@4994james3 жыл бұрын
Have you looked at my mysensors? I have successfully built an iot sensor network using their software and hardware ideas all using the same transceiver board. Takes all the pain out of it.
@RalphBacon3 жыл бұрын
I had a look, James, after which Google bombarded me with other sites offering the same sort of thing. all very professional but too pricey for me and takes away the fun of doing it ourselves. Great for commercial applications though.
@rexeveringham18175 жыл бұрын
Thanks for the detailed and informative video Ralph! I have a couple of the amplified versions that are waiting for me to try out for a remote water tank level monitor. Definitely saved this into my favourites list. Nice explanation of Structs too, and showcasing your STM Adapter boards. It’s nice to see ideas built on top of ideas - if you know what I mean.
@RalphBacon5 жыл бұрын
The amplified versions with an aerial can easy cover 1km or more in open ground, I'm reliably told, Rex. Glad you liked the structs walkthrough, very simple yet so few use it. You spotted the STM adapter boards being used, they were great for this project. They work with all my clones and FAKE STM32s too.
@Sexicosworth3 жыл бұрын
So helpful and well explained. Thanks!
@RalphBacon3 жыл бұрын
You're very welcome!
@partouelectric23534 жыл бұрын
Hi Mr. Bacon Thank you for your great video
@RalphBacon4 жыл бұрын
Thanks for watching!
@Stuart-AJC5 жыл бұрын
Great video as always, and a useful extension to the earlier one using Arduinos. One question though: how do you get the output from the two processors (TX & RX) to both appear on one serial monitor?
@RalphBacon5 жыл бұрын
I'm using Eclipse Sloeber edition which allows multiple COM ports in the same window, Stuart. With the Arduino IDE you will have to fire up two independent instances each looking at a different COM port. Trickier than you might think because changes in one instance end up being reflected in the other if you are not careful. But it can be done. Don't start the Arduino IDE from a shortcut. That often helps.
@Stuart-AJC5 жыл бұрын
@@RalphBacon Ahh, thanks. I saw you weren't using the Arduino IDE. I know what you mean about running it from a shortcut. BTDT. I have recently started using Microsoft Visual Studio Code which is, to me, surprisingly good. And I'm from a Microsoft development background. I'm using it for ESP32/MicroPython at the moment, but hope to use it for Arduino too. I don't know how well it handles multiple serial ports yet.
@RalphBacon5 жыл бұрын
I'm just starting out with that too; MS Visual Studio Code with Platformio for STM32 programming. I wish I had more time to experiment.
@bbowling49795 жыл бұрын
@@RalphBacon Hi Ralph! Great video as usual. Have you done a setup video for using Eclipse as your arduino IDE? I looked and only found one for Sublime. Thanks again for taking the time to make these videos!
@arimateiasilva45555 жыл бұрын
Ralph great videos, thanks. Keep up the good work. How about using fixed width integers (int8_t, uint8_t, etc) on 24:55 ? Greetings from Brazil.
@RalphBacon5 жыл бұрын
Yes, you can use those in exactly the same way, Arimateia, just put them in the struct and they only use up 1 byte. Tudo bem?
@KapalikKhanal5 жыл бұрын
@Ralpha Is it possible to transfer an image of size around 30-50kb that is stored on SD card via nrf to the receiver ?
@RalphBacon5 жыл бұрын
That will be a tough one. You can only transmit 32 bytes in one go. So whilst you could do it in a gazillion packets I suspect this is not the technology you need for that sort of application. Ethernet is probably better placed for this (Wired or Wireless).
@KapalikKhanal5 жыл бұрын
@@RalphBacon Actually i was working on a project on which i had to trasmit an image from the height of around 500m. So, technically i cannot use any wire, and i thought Nrflo1+ will do the job, but i think i am wrong 😅. And thank you for your quick response.
@aliuyank43744 жыл бұрын
@@KapalikKhanal you can transmit bro. Just you should write appropriate code. you can divide the code
@jeffbluejets262611 ай бұрын
So the model with the SI24R1 operate with the same code etc.....
@RalphBacon11 ай бұрын
Well... almost the same code. If you are just using standard Arduino C++ sketches then it will compile fine for the STM32F103 (and others too). If, however, you are doing some "bare metal" programming, using registers that are specific to the Arduino's ATMega328P it will not work.
@JeahBee664 жыл бұрын
Helpful high quality Video. Thanks for that.
@RalphBacon4 жыл бұрын
Glad you found it interesting and/or useful, Jörg!
@delboy47115 жыл бұрын
Apologies for the off topic comment, but do any of your experienced STM32 users know how to get I2C working on STM32? I have been using the official ST STM32duino core and cannot get I2C to go more than one transaction without locking up. Is there an alternative library available? I have tried with both platformio and Arduino IDE with the same results.
@RalphBacon5 жыл бұрын
I don't think I've got that far with my STM32 (yet) but are you SURE you have a genuine STM32? None of mine were until yesterday. Whilst I await your answer perhaps others will jump in with their experiences of I2C...
@noweare15 жыл бұрын
I could not get the I2C working on an official stm32f030 board. I put my logic analyzer on it and saw what was happening. It was broke. I ended up having to bit bang the I2C protocol to get it to work reliably.
@rene-jeanmercier65175 жыл бұрын
Hi Ralph. Please tell us what is your new software development environment. Thank you for all your very instructive videos. RJM
@RalphBacon5 жыл бұрын
It's not new, Rene-Jean, it's Eclipse for Arduino, Sloeber edition. However, it's being discontinued (so I hear) so I may have to switch to either Visual Studio Code with Platformio or Atom with Platformio. However, it is still available right now so you can have a look: eclipse.baeyens.it/
@rene-jeanmercier65175 жыл бұрын
Hi Ralph! Thank you for your quick reply. I suggest, as a great replacement, vscode with Platformio. I am compiling a 3000 lines C++ program on Debian 10 at the moment and it works flawlessly. Regards, RJM
@RalphBacon5 жыл бұрын
What are you compiling for, Rene-Jean? Not the Arduino, your program's too big for that, an STM32? My target is STM32, ESP8266 and ESP32 at the moment. Does Platformio cater for all those (I've only used it for STM32 so far)?
@rene-jeanmercier65175 жыл бұрын
Hi Ralph. I am compiling for the STM32 Bluepill (the one with 128kb flash ...but the 64kb works the same way). Environment is : [env:genericSTM32F103CB] platform = ststm32 board = genericSTM32F103CB framework = arduino board_build.core = maple upload_protocol = stlink upload_port = /dev/ttyACM0 monitor_speed = 115200 board_build.mcu = stm32f103cbt6 debug_port = stlink. It is based on Roger Clark (Melbourne) great adaptation/development of the original Maple. It works great. I can highly recommend it. Regards, RJM.
@fadial-baghdadi61573 жыл бұрын
thanks for you u have great video but what name this program i see like arduino
@RalphBacon3 жыл бұрын
You're probably referring to Eclipse sloeber IDE (much more powerful than Arduino IDE) but unfortunately no deprecated. I would recommend PlatformIO as a better replacement at least until the new Arduino IDE comes out later this year (also based on Eclipse).
@colepdx1875 жыл бұрын
I can't get sprintf to work with float values (i.e. %4.2f ). It just fills the string with a '?' where the number should be. Other than that it works great for formatting date and time into nice strings padded with zeroes in all the right (on the left) places. As for the auto acknowledge... I must have clones because it doesn't seem to work for me. I get what I have named fack's (fake acks) I have added manual acknowledgement logic into my code and that DOES work nicely. I guess $8 USD for 5 radios isn't for 'kosher' units. Thank you Ralph.
@RalphBacon5 жыл бұрын
This works for floats, Dirk: void setup() { Serial.begin(9600); } void loop() { float abc = 3.1415926; char buffer[100]; sprintf(buffer, "This is the value %1.8f", abc); Serial.println(buffer); // This prints: This is the value 3.14159250 // Note the rounding! } And I'm not surprised you have clones, they are rife. I'm surprised mine work.
@SpeccyMan5 жыл бұрын
The Arduino implementation of sprintf doesn't include support for floats. Use something like dtostrf() instead or investigate using the Arduino String class. My guess is the support for floats isn't there since the ATmega328p has a limited amount of RAM and they assume people won't be using them. It is generally accepted that if you need such support you code it in yourself I suppose.
@RalphBacon5 жыл бұрын
But using a double does not round: void setup() { Serial.begin(9600); } void loop() { double abc = 3.141592654321; char buffer[100]; sprintf(buffer, "This is the value %1.12f", abc); Serial.println(buffer); // This prints: This is the value 3.141592654321 }
@asagk5 жыл бұрын
@@RalphBacon It is because each "mantissa bit" in a float or double represents a "1/(2^n)". So if a vale cannot be represented as the sum of a number of 1/(2^n), then it is aready rounded when saved in the first place, like you did with the literal assigned to abc in "float abc = 3.14152926;". Since a double has more bits in its mantissa, it can approximate values better than a float (float=23bit mantissa vs double=52bit mantissa). So it is good for the understanding, that floats/double/long double are generally approximations constructed by the sum of fractions of "( (1/(2 to the power of n)) * exponent)" (e.g. "1/2 + 1/4 + 1/8 + 1/16 + 1/32 + 1/64" ... shifted by "exponent"), while the exponent part of a float/double etc. is just an ordinary binary. So floating point numbers can be quite imprecise when it comes to exact representation, if the value to be represented cannot be formed by a sum of fractions of " (1/(2^n)) * exponent ". [edit] Btw.: That is why "precise" floating point calculus is done in e.g. BCD (binary coded decimals).
@colepdx1875 жыл бұрын
I've tried both the sprintf examples verbatim and still get the same result. Just a '?' in the formatted string. I'm using Arduino IDE v1.8.9. I had reached the conclusion that, as Nick B stated, the floats are not implemented in the Arduino IDE sprintf. I was using sprintf to build a CSV string for a data-logger and ended up using the %s format specifier and the object 'String(floatValue,2) in the value list. Cheers.
@andymouse5 жыл бұрын
Hi Ralph, another informative vid, cheers!... here's something I would like your opinion on (if you you've seen it) Its called MCUdude/MiniCore and is found on Github, briefly, it can be installed easily by copying the URL into the appropriate place under preferences in the Arduino IDE..It gives you various board choices including the Atmega328p and others, also you can choose clock frequencies internal or external, you can set BOD (brown out detection) to off or another value, it can free up the pins used for the Crystal (Xtal) and give you two extra GPIO, various programer options Basically a whole bunch of goodies! I intend to play with it so my question is ...Have you played with it? and would you be interested in taking a look some time?..it can be found on github...MCUdude/MiniCore...cheers again.
@RalphBacon5 жыл бұрын
You must have hacked into my workshop camera, Andy; this could not have come at a better time, as I'm working on a simple project but need to change oscillators, frequency and so on, so it can run on a three AA batteries for a year or more. Thanks for the heads up, I shall definitely be investigating!
@andymouse5 жыл бұрын
@@RalphBacon No, I think you have hacked my lab because I'm playing around with running MCU's on batteries for long periods of time too!...haha!
@andymouse5 жыл бұрын
@@RalphBacon Just a quick one, I'm using CR2032 batteries in conjunction with this.. MT3608 DC-DC Step Up module it works well and using my hot plate I can whip off the components to use in my design.
@RalphBacon5 жыл бұрын
I thought about CR2032 batteries but even with a standby current of < 20µA I'm worried it would go flat within a relatively short time frame. How have you calculated your battery life?
@andymouse5 жыл бұрын
@@RalphBacon The C2032 capacity is about 200mah, divided by my circuit requirements (very simply!), but I'm seeing how small a draw I can get the 328 to sleep at, I no its all been done but it's quite fun! I'm aiming at hundreds of Nano amps which is reasonable so your 3x AAA should last some time. When you reveal you project a video on calculating all this stuff would be great...cheers!
@kaptenkeith3 жыл бұрын
Thanks very clear
@RalphBacon3 жыл бұрын
You're welcome!
@ArjanvanVught5 жыл бұрын
Great to see the best IDE for an ARM processor ;-) But including "Arduino.h" ? :-P That is introducing a lot of code overhead. And you do not get the best performance out of the ARM processor.
@RalphBacon5 жыл бұрын
My understanding, Arjan, is that if you include _any_ library but don't actually use any of the routines, the linker will optimise it out of the final code. Do you agree? But the Arduino.h contains all the language we're used to: pinMode, digitalWrite, analogRead and so on. Probability is that these are going to be used, I would have thought?
@primomechatronics38165 жыл бұрын
@@RalphBacon good day sir, whats the ide called ?
@RalphBacon5 жыл бұрын
The IDE is the Eclipse for Arduino: eclipse.baeyens.it/
@hansdegroot652 Жыл бұрын
4 years ago allready
@RalphBacon Жыл бұрын
Time certainly flies, Hans! I've been in my "new" home (and workshop) for nearly 3 years already!