microbit radio comms
I am now working on a project that uses two microbits that are using radio communication. I have some simple code, but not ready to post it.
The big problem that I am having is, I think, is a timing solution between the radio.send and the radio.receive(). When I get this settled then I will post.
Ray
Comments
This particular microbit will be outside gathering info upon request. The light and sound are values, I will try to add some info too the values, as it pertains to the location.
I am still working on the ther program.
Ray
Below is untested code of a general concept program. I still have not worked out the timing issue between the two programs. This a manual edition of getting some values from the other microbit, just to see what is really occurring. the next step would be to automate the logging procedure of that data while still show a scroll of the local temperature.
The hard part will be to add the gately RTC code, so I could have date and time added to the log file.
Ray
The problem that I am seeing is, in m_b_master, when I request a value (temp,sound,light), sometimes I get a value and most of the time I get nothing. I think it is a timing problem, but not sure how to resolve this.
Now I am thinking that on the module that is sending the requested value, maybe I should set that up as a separate task. So, basically I would have two tasks running, one task that handles the requests and the other task would handle the scrolling. I am not sure if the microbit can do this correctly. I also want to add some of the other sensor data to the request list.
Ray
I could be mistaken, but I think that in the "Get the temp" code, the value of inbuff will always be empty... Tabbing/spacing is crucial in micropython. That section of code needs an additional TAB or spacing, aligning it to the "if inbuff" above it.
Just my thought on this...
dgately
Sorry, I was doing some multiple copy and paste to get it into the post, and something got corrupted.
The one thing that I am really starting to dislike about Python is that indentation stuff. On a small program it is fairly easy to catch and fix, but on a larger more complex program, you will be pulling your hair out. Maybe a Raspberry Perl is something to think about.
Ray
What editor are you using? I've never had a problem with indentation in any of the editors I've used, but I wouldn't want to try writing Python (or anything else, for that matter) in e.g. Notepad.
I was using Geany then I switched over to Thonny, I also tried MU for micropython. Because I work between Win 10 and Linux, I have ti find something that works in both systems.
Ray
I have a Raspberry 5 and I have connected a micro:bit. I am using Thonny with the latest interpreter update for micro:bit. I am having a couple of issues, maybe if somebody has an RPi 5, if you could run the program below and see what kind of issues it will have, if any.
First issue, the quit function, not sure why it is taking such a long time for the command to respond.
Second issue, I am using '@run_every(s=5)', this seems to be bogging down the program. Not sure what the next problem would be, if I expanded the program.
This program, when run on my Win 10 machine, it does not have any of these issues. I get the feeling that Thonny runs just a little bit different on the different machines. This is making Thonny all most impossible to use, if you will be switching between different machines.
Ray