Outils pour utilisateurs

Outils du site

(Rpi Zero W + CC1101)-based receiver for wireless thermometers


Status du project
Date de début automne 2019
Fin tôt en 2020
Status DONE!
Initiateur Magnus

Configuring the LED of the Rpi Zero

Let us make more use of the the on-board green power/status LED!

See also: - https://www.jeffgeerling.com/blogs/jeff-geerling/controlling-pwr-act-leds-raspberry-pi - https://gpiozero.readthedocs.io/en/stable/recipes_advanced.html#controlling-the-pi-s-own-leds

Add these lines to /boot/config.txt:

# disable status led

Then, here a small python script to use it:

import warnings
import logging
from gpiozero import LED,PinNonPhysical
warnings.simplefilter('ignore', category=PinNonPhysical)
class ActivityLED:
    def __init__(self):
        if not '[none]' in open('/sys/class/leds/led0/trigger','r').read():
            logger.warn('LED trigger not set to none...')
    def blink(self):
if __name__=='__main__':
    import time

Configuration MQTT

I am using Eclipse Mosuitto a local MQTT broker, setting up a bridge to the io.adafruit.com. This decouples their web service quite nicely from my other listener (an e-ink display in the corridor). The config was quite some trial and error, so here what eventually works (modulo the XXXX):

# Bridge to Adafruit.IO
# see: https://learn.adafruit.com/manually-bridging-mqtt-mosquitto-to-adafruit-io/the-right-way-to-have-built-this
# and better: https://gist.github.com/damoclark/b182e6af0987be7e8130a22f1a8c34c9
connection cc1101hub
address io.adafruit.com:1883
bridge_attempt_unsubscribe false
cleansession false
notifications false
remote_username magnustron
remote_password XXXX
start_type automatic
try_private false
topic "" out 0 cc1101hub/terrasse/temperature magnustron/feeds/terrasse-temperature 
topic "" out 0 cc1101hub/salon/temperature    magnustron/feeds/salon-temperature
topic "" out 0 cc1101hub/salon/humidite       magnustron/feeds/salon-humidite 
topic "" out 0 cc1101hub/enfants/temperature  magnustron/feeds/enfants-temperature
topic "" out 0 cc1101hub/enfants/humidite     magnustron/feeds/enfants-humidite 
topic "" out 0 cc1101hub/chambre/temperature  magnustron/feeds/chambre-temperature 
topic "" out 0 cc1101hub/chambre/humidite     magnustron/feeds/chambre-humidite
topic "" both 0 test     magnustron/feeds/test

Liens externes


Script to keep WiFi running

My home router seems to require a reconnection from time to time. Running this script every five minutes from cron works for that (note that it typically needs to be run as root, i.e. to be added to cron via:

sudo crontab -e
# see: https://gist.github.com/mharizanov/5325450
# to crontab (via "sudo crontab -e"):
# */5 * * * * /home/pi/check_wlan.sh 2>&1 | logger -t check_wlan.sh
echo "Performing Network check for $wlan"
/bin/ping -c 2 -I $WLAN $PING_IP_ROUTER
if [ $? -ge 1 ] ; then
    echo "${WLAN} seems to be down somewhat. Attempting reconnection."
    /sbin/ifconfig $WLAN down
    /bin/sleep 5
    /sbin/ifconfig $WLAN up
    echo "${WLAN} is okay"

Reduce power

No need for HDMI here. Add this to /etc/rc.local:

# disable HDMI (save energy)
/usr/bin/tvservice -o
projects/electronics/tfa-whub-cc1101.txt · Dernière modification: 2020/04/05 22:47 par magnustron