Skip to content

BBC micro:bit using serial comms to Flightgear

Yesterday I had a small tinker with one of the kids Micro:bits, and got the button presses to send to properties of FGFS over serial, using the generic protocol.

https://microbit.org/

Just out of interest, I will experiment some more and publish how its done, like maybe using the x,y tilt sensors to operate the stick would be fun!

I can't find any other posts online about using a micro:bit with Flightgear, so these may be the first experiments.

It struck me that a lot of senior schools tinker with micro:bits in IT classes, so if a few fun projects can be devised, then it may encourage a few more younger people to try flightgear.

Cheers, Scott

Comments

  • No clue.....carry on.

    VooDoo

  • The micro:bit is a small educational device, a processor on a PCB with a buncch of LEDs that form a rough display matrix, two buttons, some sensors, and external access to some GPIO pins. It has a USB connection to program it, but I also used this to connect it to the computer to send serial data to Flightgear to control the simulator.

    Think Arduino, but with a few on-board input and output devices.

  • I feel like VooDoo...no clue!

    But you have ideas...carry on,Scott

  • That is a fantastic idea Scott.

    Its an ARM Cortex M4 processor on it - pretty neat! And with all its onboard sensors that is a fun device! Wish I had some time .. :S

    I think, combining those sensors with effects in FG could be a nice bridge to get the kids being interested in sim tech via FG and some haptic interaction with it built by them.

    Could be a nice idea to just build some sort of bridge to real time property read/write in FG. But I guess that would need some sort of library being available for the code and of course a lib or a program transporting the device outputs to FG's property tree.

    An idea could be to create a Bluetooth device driver for Windows that reads from the BT protocol and write to a running FG application via the network maybe.

    The kids could then maybe write an integer or float value to a property given by it's property path.

    Something like that.

    And then they could start tinkering :)

  • So, I have just had success using the micro:bit's gyro roll and pitch variables to control the stick x/y angles and fly the T5 Lightning!

    Quite odd to be tilting a circuit board around and watching the simulator fly quite nicely! Imagine this action resembles using a WII nunchuck controller.

    One snag with using serial on the micro:bit with FGFS (I've not had this with Arduinos): the first variable sent seems to not be read properly or at all by FGFS. I have been able to monitor the micro:bit's serial output using "screen" at the command line, and it looks ok, but FGFS can't seem to make sense of the first variable. So as a workaround, I initially send a "0" as the virst variable, and use the protocol xml config to dump this to a "spare" property, and form there on, the roll and pitch floats come through lovely.

    Interestingly I haven't been able to successfully use "cat" at the command line to monitor the serial output, only "screen". "cat"" works well with Arduino boards, as does FGFS, so I wonder if there's a clue there.

    Cheers, Scott.

  • Scott, you could also try out minicom which basically is the industry standard for port communication.

    I wouldn't know why there is a difference between cat and screen reading from a port. I could think of maybe the ability of screen to "stay open", even when there is no data incoming or maybe cat interpreting certain bits or bytes as basic endlines or carriage returns or something like that. Things that would indicate the end of a buffer. I really don't know.

    Maybe open two consoles and execute both commands at the same time. Then watch at what sequence or non-sequence cat exits.

    And of course there is FGFS ability to read and write serial ports so no need for some program in between :D

  • edited December 2023

    Hi Geed,

    Sorry, i confused things, I was only using screen and cat for test purposes to see the data. I am using Flightgear's Generic protocol to directly communicate with the micro:bit.

    I will do some more experimenting to confirm the behaviour of the first variable sent, but there seems to be something different between how an Arduino board sends serial data and how the micro:bit does.

    Thanks for the tip about minicom, I hadn't heard of it before, and will give it a shot.

Sign In or Register to comment.