adafruit / adafruit_circuitpython_si1145 Goto Github PK
View Code? Open in Web Editor NEWCircuitPython helper library for the SI1145 Digital UV Index IR Visible Light Sensor
License: MIT License
CircuitPython helper library for the SI1145 Digital UV Index IR Visible Light Sensor
License: MIT License
I have an Adafruit SI1145 sensor. I have tested it on an Arduino Uno and it works great. I am shining a red laser on it for testing. The readings for infrared are in the 0-100,000 ballpark.
However, I switched over to CircuitPython on both a Pi Pico and FeatherS2. In both cases, when the reading exceeds 65,535, I get the following error (the first value is the IR reading from the sensor):
(305, 0, 100000)
(304, 0, 100000)
(303, 0, 100000)
(301, 0, 100000)
(304, 0, 100000)
(306, 0, 100000)
(303, 0, 100000)
(302, 0, 100000)
(300, 0, 100000)
(65535, 0, 100000) <------ shine red laser on it
Traceback (most recent call last):
File "code.py", line 16, in <module>
File "/lib/adafruit_si1145.py", line 109, in als
File "/lib/adafruit_si1145.py", line 165, in _send_command
RuntimeError: SI1145 Error: 0x80
Code done running.
Is this a programming problem where the value is stored in a UINT16 instead of something higher or some limitation in the Pico and ESP32 chips?
There are missing type annotations for some functions in this library.
The typing
module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:
try:
from typing import List, Tuple
except ImportError:
pass
Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:
def wrap_text_to_pixels(
string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:
If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github
There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: Sharing docs on ReadTheDocs
and Check your code with pre-commit
contain the tools to install and commands to run locally to run the checks.
If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @FoamyGuy and @kattni or reach out to us on Discord: https://adafru.it/discord in the #circuitpython-dev
channel.
Per request here:
https://forums.adafruit.com/viewtopic.php?f=60&t=192880#p934156
Per request here:
https://forums.adafruit.com/viewtopic.php?f=60&t=192880#p934156
Re this thread:
https://forums.adafruit.com/viewtopic.php?p=938230#p938230
Add ability to get/set the various gain and range settings.
With code from #8, which has been merged, so opening new issue:
Adafruit CircuitPython 7.3.2 on 2022-07-20; Adafruit QT Py M0 with samd21e18
>>> import board, adafruit_si1145
>>> si1145 = adafruit_si1145.SI1145(board.I2C())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_si1145.py", line 84, in __init__
File "adafruit_si1145.py", line 127, in uv_index_enabled
File "adafruit_register/i2c_struct.py", line 43, in __set__
TypeError: 'int' object is not iterable
>>>
I think these need to be tuples?
Adafruit_CircuitPython_SI1145/adafruit_si1145.py
Lines 127 to 130 in 216640c
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.