XLoBorg back in stock or similar product recommendation

Forums:

Hi are there plans to continue sales of the XLoBorg board? if not could you recommend a similar product. Also will the XLoBorg examples be compatible?

Cheers
John

piborg's picture

Unfortunately we had to discontinue XLoBorgs as one of the chips it uses is no longer in production.

As an alternative Pimoroni offer these three options:

  1. Same capabilities as XLoBorg: https://shop.pimoroni.com/products/lsm303d-6dof-motion-sensor-breakout
  2. Just motion sensing, but cheaper: https://shop.pimoroni.com/products/msa301-3dof-motion-sensor-breakout
  3. More functionality than XLoBorg: https://shop.pimoroni.com/products/icm20948

The XLoBorg examples are not directly compatible with these boards, but they have their own Python library and examples provided :)

Thanks I took your advice and have invested in a https://shop.pimoroni.com/products/icm20948. The documentation is dire to say the least. I've managed to connect it to my Pi and using the examples given am able to see changes in orientation.
In the past your knowledge ad advice has always helped so am coming to you for more.
Converting output data from the sensor seems to be rather difficult. Can you suggest any Code that could convert this output data to degrees for direction 0-360 and also degrees for tilt.
Also how could I use this sensor with you XLoBorg examples?
Thanks
John

Hi, after fiddling with one of the examples included by Pimoroni with the https://shop.pimoroni.com/products/icm20948 I can eventually discern all compass points , 360 deg (North) (90 West) 180 (South) 270 (East), and all points in between.
The code prints the heading in Degrees. Initially I would like to alter the code to print the compass points North when reaching 360 and 180 South etc. I would at a later date like to have a LED that lights when reaching North etc. I realise this is pretty ambitious. Any help would be appreciated.
I've attached the script hopefully it may of use to others.
Cheers
John

Attachments: 

Hi, after fiddling with one of the examples included by Pimoroni with the https://shop.pimoroni.com/products/icm20948 I can eventually discern all compass points , 360 deg (North) (90 West) 180 (South) 270 (East), and all points in between.
The code prints the heading in Degrees. Initially I would like to alter the code to print the compass points North when reaching 360 and 180 South etc. I would at a later date like to have a LED that lights when reaching North etc. I realise this is pretty ambitious. Any help would be appreciated.
I've attached the script hopefully it may of use to others.
Cheers
John

Attachments: 
piborg's picture

First you want to create a limit for how close to exactly north/south you want to be matched and some variables to hold the results in before the loop:

tolerance = 5     # How many degrees from exact to match
isNorth = False
isSouth = False

Then in the loop after you have calculated the heading you want to check if the new heading is within the specified limits.

You can see if the previous loop was already pointing the same way to do an action once, or simply repeat the action for each loop while it is pointing that way.

    if (heading >= 360 - tolerance) or (heading <= 0 + tolerance):
        # Pointing north
        if not isNorth:
            # This runs once each time you start facing north
            print("North")
        # This runs each loop while pointing north
        isNorth = True
        isSouth = False
    elif (heading >= 180 - tolerance) and (heading <= 180 + tolerance):
        # Pointing south
        if not isSouth:
            # This runs once each time you start facing south
            print("South")
        # This runs each loop while pointing south
        isNorth = False
        isSouth = True
    else:
        # Not pointing at any of the above
        isNorth = False
        isSouth = False

Thank you for the help I modified my working code but no matter what I do it wont run as expected. It runs without any issues but when passing through North /South nothing changes. Any ideas ?

John

Attachments: 
piborg's picture

The whole if (heading >= 360 - 5) or (heading <= 0 + 5): section needs to be indented so that it is within the while True: loop.

For example:

    heading = round(heading)
    
    if (heading >= 360 - 5) or (heading <= 0 + 5):
        # Pointing north
        if not isNorth:
            # This runs once each time you start facing north
            print("North")

Without the indentation this section is not being run during the loop, but after it ends. Since the loop never ends it is never run.

See https://www.askpython.com/python/python-indentation

Thank you all working now My new mantra is check indentation! and count spaces 1..2..3..4.

Thanks again

Morning, in my previous posts Ive been using https://shop.pimoroni.com/products/icm20948 sensor as a compass.
How would I be able to view my sensor readings on the diddyborg webui.

Thanks in advance

piborg's picture

There are different options depending on if you need to read the sensor at a regular interval, or just when you need an update.

As a starting point, this example adds UltraBorg readings to the Web UI: Diddiborg with Ultraborg over Web UI.

In that code the distances-once block takes the Ultrasonic readings and sends them back. The simplest thing would be to replace the code in this section so it performs a single read of the sensor and sends the result back.

Reading at a regular interval is a bit more work. In that case you would need to create a new thread in which your sensor reading code runs in its own loop. You can use a global value to pass the result back to the main thread. This time the distances-once section just needs to read the global result and send it back.

Very basic example with two threads sharing a global value: https://www.adamsmith.haus/python/answers/how-to-use-a-global-variable-w...

Subscribe to Comments for &quot;XLoBorg back in stock or similar product recommendation&quot;