Outils pour utilisateurs

Outils du site


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

Status

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
dtparam=act_led_trigger=none
dtparam=act_led_activelow=on

Then, here a small python script to use it:

activityled.py
import warnings
import logging
from gpiozero import LED,PinNonPhysical
 
logger=logging.getLogger(__name__)
 
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...')
        self.led=LED(47,active_high=False)
 
    def blink(self):
        self.led.blink(n=1)
 
if __name__=='__main__':
    import time
    a=ActivityLED()
    a.blink()
    time.sleep(2)

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):

/etc/mosquitto/conf.d/cc1101hub2aio.conf
#
# 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

Postscripta

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
check_wlan.sh
#!/bin/bash
# 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
 
WLAN=wlan0
PING_IP_ROUTER=192.168.0.1
 
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
else
    echo "${WLAN} is okay"
fi

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