Open saket424 opened 3 years ago
Certainly could. I like the idea. We've discussed this ourselves across the various Balena Docker projects I have.
What exactly would you want to run the Dockerfile on? Have you tried with a vanilla install?
I would like to first get it working on a buster-based raspios on a pi0 (vanilla) without balena
But I see references to balena kernel header builds and awscli in your docker file. So I was curious if we can possibly make a docjer-compose file without any balena dependency just yet
Later I also want to get it working on the google coral mini dev board running mendel linux
OK - I am creating a vanilla Dockerfile now. If I commit in can you give it a go with docker-compose build
and give me some feedback @saket424 ?
Yes I am eagerly looking forward to your commit and will most definitely provide the feedback on both these boards
OK see how that commit goes for you for now will you? If that looks useful I'll have a look into the sound driver
@ajlennon , I gave your image a whirl. It seems to build ok. I noticed it is missing vcgencmd and ps. Can you add those? You already know that the audio driver is missing
sensors_1 | insmod: ERROR: could not load module rpi0-i2s-audio.ko: No such file or directory
Where do I specify the mqtt broker etc ? I don't see any reference to it in the docker-compose file
I used docker exec -it to attach to your running container and manually ran this from the container after I commented out references to vcgencmd in ./enviroplus-python/examples/mqtt-all.py and it worked!
# Read values from BME280 and return as dict
def read_bme280(bme280):
# Compensation factor for temperature
comp_factor = 2.25
values = {}
#cpu_temp = get_cpu_temperature()
raw_temp = bme280.get_temperature() # float
#comp_temp = raw_temp - ((cpu_temp - raw_temp) / comp_factor)
comp_temp = raw_temp;
root@b04ce7085b53:/usr/src/app# python3 enviroplus-python/examples/mqtt-all.py --broker 172.17.0.1 --port 1883 --topic "enviroplus/ajlennon"
mqtt-all.py - Reads Enviro plus data and sends over mqtt.
broker: 172.17.0.1
client_id: raspi-00000000965b470f
port: 1883
topic: enviroplus/ajlennon
Press Ctrl+C to exit!
No PMS5003 sensor connected
RPi serial: 00000000965b470f
Wi-Fi: connected
MQTT broker IP: 172.17.0.1
connected OK
{'temperature': 23.566628721007145, 'pressure': 67320.0, 'humidity': 100.0, 'oxidised': 30.516853932584265, 'reduced': 37.47496206373293, 'nh3': 6.348178137651822, 'lux': 4.6474, 'serial': '00000000965b470f'}
mid: 1
{'temperature': 26.75501746750417, 'pressure': 98220.0, 'humidity': 19.05642588987805, 'oxidised': 0.46196150320806606, 'reduced': 54.19677996422183, 'nh3': 0.5137614678899082, 'lux': 4.6474, 'serial': '00000000965b470f'}
mid: 2
{'temperature': 26.755655475617118, 'pressure': 98220.0, 'humidity': 19.08101368639229, 'oxidised': 0.46196150320806606, 'reduced': 68.69635627530366, 'nh3': 0.6697332106715731, 'lux': 4.6474, 'serial': '00000000965b470f'}
mid: 3
mosquitto_sub -v -d -t '#'
Client mosqsub|24774-pi0gadget sending CONNECT
Client mosqsub|24774-pi0gadget received CONNACK (0)
Client mosqsub|24774-pi0gadget sending SUBSCRIBE (Mid: 1, Topic: #, QoS: 0)
Client mosqsub|24774-pi0gadget received SUBACK
Subscribed (mid: 1): 0
Client mosqsub|24774-pi0gadget received PUBLISH (d0, q0, r1, m0, 'enviroplus/ajlennon', ... (222 bytes))
enviroplus/ajlennon {"temperature": 26.755655475617118, "pressure": 98220.0, "humidity": 19.08101368639229, "oxidised": 0.46196150320806606, "reduced": 68.69635627530366, "nh3": 0.6697332106715731, "lux": 4.6474, "serial": "00000000965b470f"}
So I think you are very close. I look forward to the sound portion also with however you need to compile with the appropriate kernel headers. Hope that is enough feedback to get you going. Thanks again
Where do I specify the mqtt broker etc ? I don't see any reference to it in the docker-compose file
OK so I have been using Balena to set environment variables as in the README file. My gut feeling is there should be a way to specify those when you start the Docker container?
sensors_1 | insmod: ERROR: could not load module rpi0-i2s-audio.ko: No such file or directory
Ah yes. Issue with the sound driver. That should be just a warning rather than stopping anything working at I think?
I used docker exec -it to attach to your running container and manually ran this from the container after I commented out references to vcgencmd
Yes. Will have a think about how best to add this in then...
sensors_1 | insmod: ERROR: could not load module rpi0-i2s-audio.ko: No such file or directory Ah yes. Issue with the sound driver. That should be just a warning rather than stopping anything working at I think? yes it is not a fatal error and the docker container kept on running without the audio kmod
Where do I specify the mqtt broker etc ? I don't see any reference to it in the docker-compose file OK so I have been using Balena to set environment variables as in the README file. My gut feeling is there should be a way to specify those when you start the Docker container?
Here is the docker-compose file I tried to use. I think autorun.sh expects an AUTORUN env variable to be set, otherwise it runs sleep.sh. Just as well that it did, since that allowed me to tweak the script and run it manually successfully
version: '2'
services:
sensors:
build: ./sensors
image: ajlennon:latest
privileged: true
volumes:
- shared-data:/data
environment:
- MQTT_BROKER: "172.17.0.1"
- MQTT_PORT: 1883
- MQTT_TOPIC: "enviroplus"
volumes:
shared-data:
Looking forward to the next commit from you soon. I'll give it another whirl and provide you feedback
@ajlennon Any progress on this front ?
Do you have a Dockerfile that does not require balena and works standalone ?