diff --git a/circuitpython/code/lib/adafruit_bme280.mpy b/circuitpython/code/lib/adafruit_bme280.mpy new file mode 100644 index 0000000..48a638b Binary files /dev/null and b/circuitpython/code/lib/adafruit_bme280.mpy differ diff --git a/circuitpython/lib/adafruit_bus_device/__init__.py b/circuitpython/code/lib/adafruit_bus_device/__init__.py similarity index 100% rename from circuitpython/lib/adafruit_bus_device/__init__.py rename to circuitpython/code/lib/adafruit_bus_device/__init__.py diff --git a/circuitpython/code/lib/adafruit_bus_device/i2c_device.mpy b/circuitpython/code/lib/adafruit_bus_device/i2c_device.mpy new file mode 100644 index 0000000..2e70715 Binary files /dev/null and b/circuitpython/code/lib/adafruit_bus_device/i2c_device.mpy differ diff --git a/circuitpython/code/lib/adafruit_bus_device/spi_device.mpy b/circuitpython/code/lib/adafruit_bus_device/spi_device.mpy new file mode 100644 index 0000000..780ada3 Binary files /dev/null and b/circuitpython/code/lib/adafruit_bus_device/spi_device.mpy differ diff --git a/circuitpython/code/lib/adafruit_gps.mpy b/circuitpython/code/lib/adafruit_gps.mpy new file mode 100644 index 0000000..8bd4f80 Binary files /dev/null and b/circuitpython/code/lib/adafruit_gps.mpy differ diff --git a/circuitpython/code/lib/neopixel.mpy b/circuitpython/code/lib/neopixel.mpy new file mode 100644 index 0000000..c4c3bf6 Binary files /dev/null and b/circuitpython/code/lib/neopixel.mpy differ diff --git a/circuitpython/firmware/feather_M0_express/firmware-3.0.0-2-g08def6b51-dirty.uf2 b/circuitpython/firmware/feather_M0_express/firmware-3.0.0-2-g08def6b51-dirty.uf2 deleted file mode 100644 index 8339d1b..0000000 Binary files a/circuitpython/firmware/feather_M0_express/firmware-3.0.0-2-g08def6b51-dirty.uf2 and /dev/null differ diff --git a/circuitpython/firmware/feather_M0_express/firmware-4.0.0-alpha-918-gdfa2581ff-dirty.uf2 b/circuitpython/firmware/feather_M0_express/firmware-4.0.0-alpha-918-gdfa2581ff-dirty.uf2 deleted file mode 100644 index 61469b8..0000000 Binary files a/circuitpython/firmware/feather_M0_express/firmware-4.0.0-alpha-918-gdfa2581ff-dirty.uf2 and /dev/null differ diff --git a/circuitpython/lib/adafruit_bme280.mpy b/circuitpython/lib/adafruit_bme280.mpy deleted file mode 100644 index 252e9be..0000000 Binary files a/circuitpython/lib/adafruit_bme280.mpy and /dev/null differ diff --git a/circuitpython/lib/adafruit_bus_device/i2c_device.mpy b/circuitpython/lib/adafruit_bus_device/i2c_device.mpy deleted file mode 100644 index 0cd7576..0000000 Binary files a/circuitpython/lib/adafruit_bus_device/i2c_device.mpy and /dev/null differ diff --git a/circuitpython/lib/adafruit_bus_device/spi_device.mpy b/circuitpython/lib/adafruit_bus_device/spi_device.mpy deleted file mode 100644 index 2a44783..0000000 Binary files a/circuitpython/lib/adafruit_bus_device/spi_device.mpy and /dev/null differ diff --git a/circuitpython/lib/adafruit_gps.mpy b/circuitpython/lib/adafruit_gps.mpy deleted file mode 100644 index 9193605..0000000 Binary files a/circuitpython/lib/adafruit_gps.mpy and /dev/null differ diff --git a/circuitpython/lib/neopixel.mpy b/circuitpython/lib/neopixel.mpy deleted file mode 100644 index d9e5480..0000000 Binary files a/circuitpython/lib/neopixel.mpy and /dev/null differ diff --git a/circuitpython/firmware/feather_M4_express/3.0.0-7-gcac760aa6-dirty+frozzen-mod.uf2 b/circuitpython/tools/firmware/feather_M4_express/3.0.0-7-gcac760aa6-dirty+frozzen-mod.uf2 similarity index 100% rename from circuitpython/firmware/feather_M4_express/3.0.0-7-gcac760aa6-dirty+frozzen-mod.uf2 rename to circuitpython/tools/firmware/feather_M4_express/3.0.0-7-gcac760aa6-dirty+frozzen-mod.uf2 diff --git a/circuitpython/firmware/feather_M4_express/3.0.0-7-gcac760aa6-dirty.uf2 b/circuitpython/tools/firmware/feather_M4_express/3.0.0-7-gcac760aa6-dirty.uf2 similarity index 100% rename from circuitpython/firmware/feather_M4_express/3.0.0-7-gcac760aa6-dirty.uf2 rename to circuitpython/tools/firmware/feather_M4_express/3.0.0-7-gcac760aa6-dirty.uf2 diff --git a/circuitpython/tools/firmware/feather_M4_express/adafruit-circuitpython-feather_m4_express-3.0.1.uf2 b/circuitpython/tools/firmware/feather_M4_express/adafruit-circuitpython-feather_m4_express-3.0.1.uf2 new file mode 100644 index 0000000..0e72ff9 Binary files /dev/null and b/circuitpython/tools/firmware/feather_M4_express/adafruit-circuitpython-feather_m4_express-3.0.1.uf2 differ diff --git a/circuitpython/tools/firmware/feather_M4_express/feather_m4_express-ERASE-CIRCUITPY.uf2 b/circuitpython/tools/firmware/feather_M4_express/feather_m4_express-ERASE-CIRCUITPY.uf2 new file mode 100644 index 0000000..640b3aa Binary files /dev/null and b/circuitpython/tools/firmware/feather_M4_express/feather_m4_express-ERASE-CIRCUITPY.uf2 differ diff --git a/circuitpython/tools/mpy-cross b/circuitpython/tools/mpy-cross new file mode 100755 index 0000000..0e8c525 Binary files /dev/null and b/circuitpython/tools/mpy-cross differ diff --git a/raspberry/python/picam_mqtt.py b/raspberry/python/picam_mqtt.py new file mode 100644 index 0000000..0352674 --- /dev/null +++ b/raspberry/python/picam_mqtt.py @@ -0,0 +1,103 @@ +#!/usr/bin/python3 +# -*- coding: UTF8 -*- + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +Take a picture with the Pi Camera module and publish the path +and name of the file on a MQTT broker + +@author: arofarn +""" + +import os +from time import sleep +from datetime import datetime +import picamera +import paho.mqtt.publish as mqtt +from cameteo_conf import CONFIG_MQTT, CONFIG_PI_CAMERA, PICTURES_EXTENSIONS + +MQTT_CLIENT_ID = "picamera" +NOW = datetime.utcNOW() + +######## +# Main # +######## + +if not os.path.exists(CONFIG_PI_CAMERA['PICT_DIR']): + print("Create photos directory : " + CONFIG_PI_CAMERA['PICT_DIR']) + os.mkdir(CONFIG_PI_CAMERA['PICT_DIR']) + +FILE_NAME = os.path.extsep.join((datetime.strftime(NOW, CONFIG_PI_CAMERA['PICT_NAME']), + PICTURES_EXTENSIONS[CONFIG_PI_CAMERA['PICT_FORMAT']])) +FILE_PATH = os.path.join(CONFIG_PI_CAMERA['PICT_DIR'], FILE_NAME) + +print("Shooting " + FILE_PATH) + +# Taking a photo +################# + +# Tell the MQTT that we start shooting +mqtt.single(CONFIG_PI_CAMERA['MQTT_TOPIC'] + "/shooting", + payload=1, + qos=1, + retain=True, + hostname=CONFIG_MQTT['HOST'], + port=CONFIG_MQTT['PORT'], + client_id=MQTT_CLIENT_ID, + auth=CONFIG_MQTT['AUTH']) + +# Camera settings +cam = picamera.PiCamera(resolution=CONFIG_PI_CAMERA['RESOLUTION']) +cam.iso = CONFIG_PI_CAMERA['ISO'] +cam.awb_mode = CONFIG_PI_CAMERA['AWB'] +cam.rotation = CONFIG_PI_CAMERA['ROTATION'] +cam.contrast = CONFIG_PI_CAMERA['CONSTRAST'] +cam.exposure_mode = CONFIG_PI_CAMERA['EXPO_MODE'] +cam.image_effect = 'none' + +#Add some EXIF tags +cam.exif_tags['EXIF.UserComment'] = 'Cameteo !' + +# Warm-up +cam.start_preview() +sleep(CONFIG_PI_CAMERA['WARMUP_TIME']) + +cam.capture(FILE_PATH, format=CONFIG_PI_CAMERA['PICT_FORMAT'], + quality=95, thumbnail=None) + +cam.close() + +# MQTT publication +################### + +MQTT_DATA = [{'topic': CONFIG_PI_CAMERA['MQTT_TOPIC'] + "/shooting", + 'payload': 0, + 'qos': 2, + 'retain': True}, + {'topic': CONFIG_PI_CAMERA['MQTT_TOPIC'] + "/photos_path", + 'payload': CONFIG_PI_CAMERA['PICT_DIR'], + 'qos': 2, + 'retain': True}, + {'topic': CONFIG_PI_CAMERA['MQTT_TOPIC'] + "/last_photo", + 'payload': CONFIG_PI_CAMERA['PICT_NAME'], + 'qos': 2, + 'retain': True}, + ] + +mqtt.multiple(MQTT_DATA, + hostname=CONFIG_MQTT['HOST'], + port=CONFIG_MQTT['PORT'], + client_id=MQTT_CLIENT_ID, + auth=CONFIG_MQTT['AUTH'])