Giter Site home page Giter Site logo

sensor.py TypeError about pi-sht1x HOT 8 CLOSED

drohm avatar drohm commented on July 22, 2024
sensor.py TypeError

from pi-sht1x.

Comments (8)

drohm avatar drohm commented on July 22, 2024

@elysio2 Can you give more details in how you got that error? Was that on install? Was it when you tried to take a temp reading? Any details you can give help in debugging the issue. Thanks.

from pi-sht1x.

elysio2 avatar elysio2 commented on July 22, 2024

@drohm Simply running the sensor.py file after a pip3 install makes this error. examples.py still works, as well as any custom code.

 File "sensor.py", line 46, in main
    logger=logger) as sensor:

from pi-sht1x.

drohm avatar drohm commented on July 22, 2024

Thanks @elysio2. Can you give details on how you're invoking sensor.py versus the examples.py?

from pi-sht1x.

elysio2 avatar elysio2 commented on July 22, 2024

@drohm
sensor.py : sudo python3 sensor.py 18 23
examples.py : sudo python3 temp2.py

(temp2.py is a copy/paste of examples.py)

from pi-sht1x.

drohm avatar drohm commented on July 22, 2024

The sensor.py isn't meant to be invoked that way. If you browse through the README, you'll see you can make calls like this:

from pi_sht1x import SHT1x

with SHT1x(18, 23, gpio_mode=GPIO.BCM) as sensor:
    temp = sensor.read_temperature()
    humidity = sensor.read_humidity(temp)
    sensor.calculate_dew_point(temp, humidity)
    print(sensor)

Give that a try and let me know.

from pi-sht1x.

elysio2 avatar elysio2 commented on July 22, 2024

That works , but FYI the readme clearly states

sensor.py

This script is callable from the terminal and the sensor parameters are passed into the script.

sudo python3 sensor.py 18 23 -g 'BCM'

This executes the sensor script using data_pin=18, sck_pin=23, and gpio_mode=GPIO.BCM. The script will then create an instance of the SHT1x class and read in the temperature, humidity, and calculate the dew point five times, sleeping 2 seconds in between each measurement.

I was only using this for testing purposes when I forgot the 10k pull-up resistor, just thought you should know.

from pi-sht1x.

drohm avatar drohm commented on July 22, 2024

@elysio2 Ahh, okay. I'll dig into this later today and update the README accordingly. Thanks for bringing this up.

from pi-sht1x.

drohm avatar drohm commented on July 22, 2024

@elysio2 What version of the pi-sht1x library is installed? If you could look at the SHT1x class, could you confirm that the version installed on your system has the logger parameter defined in the __init__() method?

from pi-sht1x.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.