AQI Celsius Output

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

AQI Celsius Output

Post by Powderjockey »

I recently completed the AQI in the Learn section, https://learn.adafruit.com/aqi-case and was wanting to change the output from Fahrenheit to Celsius. I tried to change the code around to calculate the reverse of the supplied code. Also, the Faherenheit to Celsius symbol on the screen.

Thanks in advance,
Scott

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: AQI Celsius Output

Post by Franklin97355 »

This is the part that converts the temperature:

Code: Select all

def c_to_f(temp_data):
    temperature_celsius = temp_data
    temperature_fahrenheit = temperature_celsius * 9 / 5 + 32
    return temperature_fahrenheit
And this is the part that uses the function:

Code: Select all

sensor_check:
        co2 = scd4x.CO2
        temp = c_to_f(scd4x.temperature)
        humidity = scd4x.relative_humidity
Just temp = scd4x.temperature should work.

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: AQI Celsius Output

Post by Powderjockey »

Thanks @Franklin97355. I'll give it ago.

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: AQI Celsius Output

Post by Powderjockey »

I commented out the "def c_to_f(temp_data):" section and then made "temp = scd4x.temperature" the line.

The temperature has changed, but I don't think it is correct. Showing 28 degrees in the house and that is out about 5. Also, the degree Farhenheit symbol is still on the screen. Line 78, temp_text = bitmap_label.Label(small_font, text="%d" % temp, x=130, y=107, color=0xFFFFFF)
pulls the symbol from somewhere.

Thanks

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: AQI Celsius Output

Post by Powderjockey »

Powderjockey wrote: Mon Jun 05, 2023 3:37 pm I commented out the "def c_to_f(temp_data):" section and then made "temp = scd4x.temperature" the line.

The temperature has changed, but I don't think it is correct. Showing 28 degrees in the house and that is out about 5. Also, the degree Farhenheit symbol is still on the screen. Line 78, temp_text = bitmap_label.Label(small_font, text="%d" % temp, x=130, y=107, color=0xFFFFFF)
pulls the symbol from somewhere.

Thanks
The image that ships with the program has the Farhenheit symbol aready imbedded on it, so the symbol will never change to Celsius.

Thoughts for an update?

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: AQI Celsius Output

Post by Franklin97355 »

There is a file called airBG.bmp that you can edit. I did but I can't include it in the forum ( it won't let me)I renamed it with an extension .txt you can see if renaming it .bmp will work. Let me know.
airBG.txt
(31.89 KiB) Downloaded 3 times

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: AQI Celsius Output

Post by Powderjockey »

FRANKLIN97355, that worked. What did you use to edit it?

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: AQI Celsius Output

Post by Franklin97355 »

I used GIMP on a Linux system but it will work with Windows and Mac

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”