mstenta / atmospi

Atmospheric monitoring app for logging and graphing temperatures and humidities over time using a Raspberry Pi and DS18B20, DHT11, DHT22, and AM2302 sensor(s).
31 stars 9 forks source link

TypeError: unsupported operand type(s) for *: 'NoneType' and 'float' #34

Closed alexbergsland closed 5 years ago

alexbergsland commented 5 years ago

First of all I found no info on how to add a new sensor into config.py. I read ".. so you need to specify which ones are connected in your config.py file (see below)." and then I found no example of that, but I did find the answer to that in another issue here. so my default_setting.py looks like:

# Atmospi settings.
settings = {

    # Absolute path to the SQLite database file.
    'db': '/home/pi/atmospi/log.db',

    # How far into the past should data be loaded (in seconds)?
    # Default to 1 week.
    'range_seconds': 60 * 60 * 24 * 7,

    # The number of digits after the decimal place that will be stored.
    'precision': 1,

    # Temperature unit of measure (C or F).
    't_unit': 'C',

    'dht_devices': {
        'Varm': {
            'type': 'DHT22',
            'pin': 17
        }
    }
}

With that I get an error:

Traceback (most recent call last):
  File "/home/pi/atmospi/Atmospi/measure-dht.py", line 73, in <module>
    if con:
NameError: name 'con' is not defined

And I googled it and found that there was an import missing, so I added from arcpy.sa import Con to measure-dht.py. That gives me another error:

Traceback (most recent call last):
  File "/home/pi/atmospi/Atmospi/measure-dht.py", line 56, in <module>
    data = read_sensor(device[1], device[2])
  File "/home/pi/atmospi/Atmospi/measure-dht.py", line 30, in read_sensor
    tf = tc * 9.0 / 5.0 + 32.0
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

I changed to Farenheit in the config but that gave the same error. I am sure this has something to do with a typo error on my side. I can get a reading from the Adafruit example using:

python Adafruit_Python_DHT/examples/AdafruitDHT.py 22 17
Temp=23.5*  Humidity=27.2%

I also have a DS1820 that was showing reading on the Flask site until I changed the default_setting.py.

Kind Regards Alex

mstenta commented 5 years ago

Oops! You're right @alexbergsland - the README.md is just outdated I think.

so you need to specify which ones are connected in your config.py file (see below).

should be instead:

so you need to specify which ones are connected in your Devices database table (see step 3 below).

Step 3 shows how to add DHT sensors to Atmospi by adding a record for them in the Devices table like so:

INSERT INTO Devices (DeviceID, Type, SerialID, Label) VALUES (NULL, 'dht22', '22', 'Upstairs DHT22');

Hope that helps!

Do you want to update the README.md and create a pull request?

alexbergsland commented 5 years ago

Oh, so I can rewove my edits in the config? I have done the insert into the db but I get no readings on the atmos page, not from the DHT22 at least.

I have never done a pull request but I can try.

alexbergsland commented 5 years ago

Seems I found my error, I used: INSERT INTO Devices (DeviceID, Type, SerialID, Label) VALUES (NULL, 'dht22', '22', 'Varm'); to add my sensor to the database. I should have used: INSERT INTO Devices (DeviceID, Type, SerialID, Label) VALUES (NULL, 'dht22', '17', 'Varm'); It's working now.

Maybe Ill clarify that in the readme as well.

mstenta commented 5 years ago

Great! Yes - you figured it out. The pin column needs to be set to the pin you are plugged into. :-)

Pull requests are easy: click "Fork" in the top right, edit the file and commit it to your fork, then Github will give you a link to create a pull request from that.

Thanks!