0

Circuitpython, Raspi and TFMini
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Circuitpython, Raspi and TFMini

by dwarrenku on Fri Sep 13, 2019 11:22 am

I'm working on a project that requires the TFMini on the raspberry pi.
From what I can see, pip3 installed circuitpython and it's dependencies appropriately. When I run blinka to test i2c and spi it returns successfully.
But, when I run the example script for the TFMini, it returns with an error:
Running:
Code: Select all | TOGGLE FULL SIZE
import time
import board  # comment this out if using pyserial
import busio  # comment this out if using pyserial
import adafruit_tfmini

# Use hardware uart
uart = busio.UART(board.TX, board.RX)

# Or, you can use pyserial on any computer
#import serial
#uart = serial.Serial("/dev/ttyS2", timeout=1)

# Simplest use, connect with the uart bus object
tfmini = adafruit_tfmini.TFmini(uart)

# You can put in 'short' or 'long' distance mode
tfmini.mode = adafruit_tfmini.MODE_SHORT
print("Now in mode", tfmini.mode)

while True:
    print("Distance: %d cm (strength %d, mode %x)" %
          (tfmini.distance, tfmini.strength, tfmini.mode))
    time.sleep(0.1)


Returns:
Code: Select all | TOGGLE FULL SIZE
  File "tf_text.py", line 7, in <module>
    uart = busio.UART(board.TX, board.RX)
AttributeError: module 'board' has no attribute 'TX'

I'm running this on a Raspi 3 model A. Should I switch to using pyserial? This is my first project with a raspberrypi and python, but I'm fairly capable with arduino, so I'm at a loss on how to debug and troubleshoot this error.
Thanks!
dwarrenku
 
Posts: 5
Joined: Wed Feb 16, 2011 10:29 am

Re: Circuitpython, Raspi and TFMini

by franklin97355 on Sat Sep 14, 2019 2:14 am

Unfortunately, this is a known issue with the Pi. read https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/uart-serial

franklin97355
 
Posts: 21071
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Circuitpython, Raspi and TFMini

by dwarrenku on Sat Sep 14, 2019 3:20 pm

Thanks! I was wondering if the serial was being used for something else by default. This is similar to needing to disconnect the RX pin on an Arduino Uno when progrmaming, right?
So, if I disable the serial console, and enable the serial GPIO through config, the board module will automagically figure it out?
dwarrenku
 
Posts: 5
Joined: Wed Feb 16, 2011 10:29 am

Please be positive and constructive with your questions and comments.