Category: Non classé

Using bash and gatttool to get readings from Xiaomi Mijia LYWSD03MMC Temperature Humidity sensor

There is a new inexpensive Temperature and humidity sensor by xiaomi.
This time is no longer round ,

Xiaomi Mijia LYWSD03MMC Bluetooth 4.2 Temperature Humidity sensor

if you like me would like to get the temperature and humidity data from time to time to import in a graphing tool like grafana, there is a simple solution using classic bash tools and gatttool.
First you have to indentify the mac-address of your little sensor, for this , just make sure the sensor is in range of your linux device ans launch a
hcitool lescann

this command will spit out all the bluetooth devices in range
just find the line with the name of the device and copy the mac address A4:C1:38:8C:77:CA LYWSD03MMC

then you must start a little bash script like this :

#!/bin/bash
bt=$(timeout 15 gatttool -b A4:C1:38:8C:77:CA --char-write-req --handle='0x0038' --value="0100" --listen)
if [ -z "$bt" ]
then
echo "The reading failed"
else
echo "Got data"
echo $bt temphexa=$(echo $bt | awk -F ' ' '{print $12$11}'| tr [:lower:] [:upper:] )

humhexa=$(echo $bt | awk -F ' ' '{print $13}'| tr [:lower:] [:upper:])
temperature100=$(echo "ibase=16; $temphexa" | bc)
humidity=$(echo "ibase=16; $humhexa" | bc)'
echo "scale=2;$temperature100/100"|bc
echo $humidity
fi

this is a skeleton that you can improve , but for now it pretty much work like that ,

first it use gatttol to connect to the sensor and listen for 15 sec
During these fifteen seconds , you can be pretty much sure to receive at least some data like this :

Characteristic value was written successfully Notification handle = 0x0036 value: 58 03 47 a0 0b Notification handle = 0x0036 value: 55 03 47 a0 0b

this tell me that during the 15 sec of connection i received the information that i need two times.
what i’m after are the value 58 03 for the temperature , and 47 for the humidity.

the temperature is little endian format its mean that the two group must be inverted before decoding the data. i invert the values with awk and decode them using bc.
bc doesn’t like when the hex values are not capitalised so tr is used to do that.

bc then give you the temperature multiplied by 100. relaunch bc to divice per 100,

For the humidity its simpler , you get the value in one step without inverting anyting

Then you can do what you need with theses two vars , insert then in some database etc ..

there is room from improvement: for example this script is not capable of decoding negative temperature.
i will post an improved version when i figure out how to do it

Installing Jellyfin on a Rasberry PI4 (Rasbian Buster)

As soon as the raspberrypi foundation announcement of the new raspberry pi was made. I was sure it was going to be a great headless media server for my network.
with the Rasberry pi 3b and the severe lack of bandwidth on the ethernet and the USB2 ports , using the device as a media server wasn’t really practical.
Now that i received my Raspberry pi 4 B 2GB edition i looked at what was available in term of good media server and I heard about Jellyfin . a pretty features full media server .

I first installed the release of raspbian buster lite available on the raspberry pi website , then activated the ssh by creating an empty ssh file in the boot partition, ran sudo apt update && sudo apt upgrade and was soon ready for the next step

After i was ready to install Jellyfin , i went to the official jellyfin website and started reading the installation instructions.
Raspbian is a tuned version of debian so I chose the instructions regarding debian and launched the following commands :

After downloading more or less 400MB, the installation was completed ,
but the server wasn’t responding on the 8096 port !
after launching the command netstat -tlp on my raspberry I figured out the port wasn’t even opened.

Weirdly systemctl status jellyfin.service was telling me the service was active and running ,
shortly after that i located the log of the application ( /var/log/jellyfin/jellyfin )

/var/log/jellyfin/jellyfin

[2019-06-30 12:40:10.020 +01:00] [INF] Jellyfin version: "10.3.5.0"
[2019-06-30 12:40:10.113 +01:00] [INF] Arguments: ["/usr/lib/jellyfin/bin/jellyfin.dll", "--restartpath=/usr/lib/jellyfin/restart.sh", "--ffmpeg=/usr/lib/jellyfin-ffmpeg/ffmpeg", ""]
[2019-06-30 12:40:10.147 +01:00] [INF] Operating system: "Linux" "4.19.50.7"
[2019-06-30 12:40:10.148 +01:00] [INF] Architecture: Arm
[2019-06-30 12:40:10.156 +01:00] [INF] 64-Bit Process: False
[2019-06-30 12:40:10.156 +01:00] [INF] User Interactive: True
[2019-06-30 12:40:10.157 +01:00] [INF] Processor count: 4
[2019-06-30 12:40:10.158 +01:00] [INF] Program data path: "/var/lib/jellyfin"
[2019-06-30 12:40:10.159 +01:00] [INF] Web resources path: "/usr/lib/jellyfin/bin/jellyfin-web/src"
[2019-06-30 12:40:10.159 +01:00] [INF] Application directory: "/usr/lib/jellyfin/bin/"

this log wasn’t helping at all it was just the same 10 line repeating over and over again, i just knew something prevented the launch of the application ,it was a starting loop, but the log wasn’t verbose enough for useful information to be logged.

After unsuccessfully trying to remove and reinstall jellyfin i tried to run the application manually and not from her service.
i first stopped the service by launching


Then launched the app by

and BINGO , i got the message No usable version of the libssl was found

after a little googlefu I figured-out the libssl installed by default in raspbian buster was too new and was causing an issue with jellyfin

my version was ssl 1.1.1c and i needed a 1.0.x version

So , to force my system to use a old version of this library without having to recompile half the OS , i created the file : /etc/apt/sources.list.d/jessie.list
and written inside the following lines :

i then launched the commands

after theses last commands , your raspberrypi is now ready to launch Jellyfin.
you can do it with


you can now access the webserver of your media server on the tcp port 8096

Bazooka lance-patates

Un Allemand a ?t? arr?t? parce qu’il tirait sur les passants avec un bazooka lance-pommes de terre de fabrication artisanale, a-t-on appris vendredi aupr?s de la police d’Essen, dans l’ouest du pays.

“C’?tait comme un bazooka qui tirait des pommes de terre”, a expliqu? un porte-parole de la police. “Une arme rudement dangereuse ? courte port?e.”

Selon la police, l’homme avait fabriqu? lui-m?me son arme, constitu?e d’un tuyau de vidange long d’un m?tre cinquante reli? ? une bombe a?rosol, dont il enflammait le gaz pour propulser les pommes de terre vers leur cible.

Le suspect, ?g? de 33 ans, a ?t? inculp? pour tentatives de coups et blessures et violation de la l?gislation sur les armes ? feu.

source yahoo.fr actualit?e