balena-labs-projects / sensor Goto Github PK
View Code? Open in Web Editor NEWAuto-detects connected i2c sensors and published data on HTTP or MQTT.
Auto-detects connected i2c sensors and published data on HTTP or MQTT.
sensor Transforming bme280 value(s)...
sensor Exception in thread Thread-1:
sensor Traceback (most recent call last):
sensor File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
sensor self.run()
sensor File "/usr/local/lib/python3.9/threading.py", line 892, in run
sensor self._target(*self._args, **self._kwargs)
sensor File "/usr/src/app/sensor.py", line 74, in background_web
sensor response = 'HTTP/1.0 200 OK\n\n'+ json.dumps(balenasense.sample())
sensor File "/usr/src/app/sensor.py", line 53, in sample
sensor return self.sensor.get_readings(self.context)
sensor File "/usr/src/app/reading.py", line 87, in get_readings
sensor x = reading.write_reading()
sensor File "/usr/src/app/reading.py", line 35, in write_reading
sensor new_fields = device_transform(dev.name, device_fields)
sensor File "/usr/src/app/transformers.py", line 20, in device_transform
sensor for field in fields:
sensor RuntimeError: dictionary keys changed during iteration
=> [ 2/10] WORKDIR /usr/src/app 0.2s
=> [ 3/10] RUN apt-get update && apt-get install -y libxml2 libxml2-dev bison flex libcdk5-dev git cmake build-essential 123.3s
=> [ 4/10] RUN apt-get install python3 python3-pip python3-setuptools python3-dev libffi-dev libssl-dev 55.1s
=> [ 5/10] RUN apt-get install -y libaio-dev libusb-1.0-0-dev libserialport-dev libxml2-dev libavahi-client-dev 17.6s
=> ERROR [ 6/10] RUN git clone https://github.com/pcercuei/libini.git && cd libini && mkdir build && cd build && cmake ../ && make && make install 7.5s
------
> [ 6/10] RUN git clone https://github.com/pcercuei/libini.git && cd libini && mkdir build && cd build && cmake ../ && make && make install:
#10 0.210 Cloning into 'libini'...
#10 2.157 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 2.157 list sub-command REMOVE_ITEM requires two or more arguments.
#10 2.157 Call Stack (most recent call first):
#10 2.157 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 2.157 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 2.157 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 2.157 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 2.157 CMakeLists.txt:2 (project)
#10 2.157
#10 2.158
#10 2.486 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 2.486 list sub-command REMOVE_ITEM requires two or more arguments.
#10 2.486 Call Stack (most recent call first):
#10 2.486 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 2.486 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 2.486 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 2.486 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 2.486 CMakeLists.txt:2 (project)
#10 2.486
#10 2.486
#10 2.786 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 2.786 list sub-command REMOVE_ITEM requires two or more arguments.
#10 2.786 Call Stack (most recent call first):
#10 2.786 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 2.786 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 2.786 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 2.786 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 2.786 CMakeLists.txt:2 (project)
#10 2.786
#10 2.786
#10 3.102 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 3.102 list sub-command REMOVE_ITEM requires two or more arguments.
#10 3.102 Call Stack (most recent call first):
#10 3.102 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 3.102 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 3.102 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 3.102 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 3.102 CMakeLists.txt:2 (project)
#10 3.102
#10 3.102
#10 3.400 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 3.400 list sub-command REMOVE_ITEM requires two or more arguments.
#10 3.400 Call Stack (most recent call first):
#10 3.400 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 3.400 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 3.400 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 3.400 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 3.400 CMakeLists.txt:2 (project)
#10 3.400
#10 3.400
#10 3.499 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 3.499 list sub-command REMOVE_ITEM requires two or more arguments.
#10 3.499 Call Stack (most recent call first):
#10 3.499 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 3.499 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 3.499 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 3.499 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 3.499 CMakeLists.txt:2 (project)
#10 3.499
#10 3.499
#10 3.782 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 3.782 list sub-command REMOVE_ITEM requires two or more arguments.
#10 3.782 Call Stack (most recent call first):
#10 3.782 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 3.782 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 3.782 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 3.782 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 3.782 CMakeLists.txt:2 (project)
#10 3.782
#10 3.782
#10 4.065 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 4.065 list sub-command REMOVE_ITEM requires two or more arguments.
#10 4.065 Call Stack (most recent call first):
#10 4.065 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 4.065 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 4.065 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 4.065 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 4.065 CMakeLists.txt:2 (project)
#10 4.065
#10 4.065
#10 4.338 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 4.338 list sub-command REMOVE_ITEM requires two or more arguments.
#10 4.338 Call Stack (most recent call first):
#10 4.338 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 4.338 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 4.338 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 4.338 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 4.338 CMakeLists.txt:2 (project)
#10 4.338
#10 4.338
#10 4.618 CMake Error at /usr/share/cmake-3.16/Modules/CMakeCompilerIdDetection.cmake:26 (list):
#10 4.618 list sub-command REMOVE_ITEM requires two or more arguments.
#10 4.618 Call Stack (most recent call first):
#10 4.618 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:211 (compiler_id_detection)
#10 4.618 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:230 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
#10 4.618 /usr/share/cmake-3.16/Modules/CMakeDetermineCompilerId.cmake:32 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
#10 4.618 /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:116 (CMAKE_DETERMINE_COMPILER_ID)
#10 4.618 CMakeLists.txt:2 (project)
#10 4.618
#10 4.618
#10 4.822 -- The C compiler identification is unknown
#10 4.869 -- Check for working C compiler: /usr/bin/cc
#10 6.160 -- Check for working C compiler: /usr/bin/cc -- works
#10 6.168 -- Detecting C compiler ABI info
#10 7.374 -- Detecting C compiler ABI info - done
#10 7.422 -- Configuring incomplete, errors occurred!
#10 7.422 See also "/usr/src/app/libini/build/CMakeFiles/CMakeOutput.log".
#10 7.422 See also "/usr/src/app/libini/build/CMakeFiles/CMakeError.log".
------
Dockerfile.raspberrypi3:18
--------------------
17 | # Build and install libini to have local context attributes.
18 | >>> RUN \
19 | >>> git clone https://github.com/pcercuei/libini.git && \
20 | >>> cd libini && \
21 | >>> mkdir build && cd build && cmake ../ && make && make install
22 |
--------------------
error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c git clone https://github.com/pcercuei/libini.git && cd libini && mkdir build && cd build && cmake ../ && make && make install]: exit code: 1
Right now, the block is hard-coded to only use bus 1: https://github.com/balenablocks/sensor/blob/main/idetect.py#L80
"On the original Raspberry Pi with the 26 pin GPIO header you may need to change the “-y 1” to “-y 0” for the command to work."
More info on Pi buses: https://raspberrypi.stackexchange.com/questions/97973/raspberry-pi-multiple-i2c-busses
Also information about why I2C-0 "User access at runtime is problematic."
https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial/all
Hi guys,
Thanks for creating an excellent balena block! I use it to read temperature data from an outdoor enclosure and feed the data via MQTT to my Home Assistant instance.
Recently, Home Assistant has deprecated support for anonymous MQTT. Would it be possible to implement username and password support in this block?
The docker-compose snippet in README.md
does not include a label for supervisor-api, but docker-compose.yml
does. I would expect the them to be consistent.
test
I'm poking around the code and I'd like some guidance on how to make a PR that enables DHT-22 support.
After enabling the overlay in the boot settings, I'm able to read the raw values via IIO_READER
in python like so:
from reading import IIO_READER
import iio
sensor = IIO_READER()
sensor.get_readings(iio.Context())
However, idetect
is only scanning for i2c devices and the DHT-22 is not initialized. What do I have to do to fix this?
If I skip the check for the device count in sensors.py
, everything seems to work fine, except the raw values from the sensor are shown. We need to convert these to actual temp/humidity units.
I consistently see this error after a boot/reboot:
Error looking for MQTT service: HTTPConnectionPool(host='10.114.104.1', port=48484): Max retries exceeded with url: /v2/applications/state?apikey=d530c94d742e47c3895754d6e777786d (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fb02a9700>: Failed to establish a new connection: [Errno 111]
The sensor service does not terminate on this error. Instead, the mqtt_detect()
function that makes the HTTP request just returns false. If I later restart the sensor service, the error does not occur. So, somehow then the system is not ready for this request. Does it make sense to add a retry over several seconds? See 70ace12 for example.
This failure is serious for another service that depends on receiving sensor messages. As a workaround, I manually set the MQTT_ADDRESS
environment variable to 'mqtt', and the sensor service sends the expected messages.
If the user configures the sensor block to push data measurements via MQTT, the measurement interval is fixed at 8 seconds. However, a user may have a strong opinion on this value based on the context for the measurement. The interval could range from sub-second to once an hour. The interval may change dynamically depending on the circumstances. Communication bandwidth may affect this value as well.
It would be useful to have a default value for the interval but allow the user to specify it via a device variable.
It also would be useful to specify in the README that the sensor block pushes data via MQTT while it expects an external service to pull data via HTTP.
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.