Qingping ClearGrass CGDK2 factory reset

The Qingping Temp & RH Monitor Lite is a cool little BLE device to monitor the temperature inside your home ,

If you are like me , you don’t really like the mihome app and want to use Home Assistant to automate your place.
Unlike the LYWSDCGQ/01ZM the CGDK2 encrypt the message broadcasted , so you can’t just add the device to home assistant and get readings, you need the encryption key or pairing key ,
The problem that I encountered to get that key is that you need to use a modified version of mihome , create a logs folder in the /vevs/ folder in your phone storage , and then, add the device to mihome for the key to be written in /vevs/logs/misc/pairings.txt
in my case , i added the device before creating the logs folder , so i didn’t have the pairing key .
I figured I just needed to delete and re-add the device to mi-home , but it didn’t go that way !
I tried and tried again and all I got was the error standard verification failed (-29).

Since I resolved this issue , I figured I share how i managed to re-add the Qingping Temp & RH Monitor Lite to mi-home .
I needed to do a factory reset on the device .
to do that you need to :
– Keep the pairing button pressed for 8 sec until all the segments of the lcd become black.
– Release the button for 1 sec ,
– Then push the pairing button again for 2 sec ,

The display flash then get back to displaying the temperature as usual, but now you device is factory reseted .
You can now add the device to mihome app and fetch the pairing key in /vevs/logs/misc/pairings.txt

now continue your configuration in home assistant using the Passive BLE Monitor integration

Orange Pi Zero 2 : A new Raspberry Pi contender ?

The new Orange Pi Zero 2 Single Board computer

If you were searching for a very small and capable SBC to run some linux app on arm cpu , you were already able to buy the original Orange PI zero ,
but the board has some obvious flaws like .

  • 100mbps ethernet
  • very unreliable wifi
  • no display connector
  • Unreliable power connector (MicroB)

Now after a few years, the company responsible for the original board has created a successor with updated specs.
The size of the board is larger than the first , but this is still one of the smallest SBC available on the market at 60 x 53 mm

Bigger than the original OrangePi Zero

Here are the complete specs :

  • SoC – Allwinner H616 64-bit quad-core Arm Cortex-A53 processor @ up to 1.5 GHz with Arm Mali G31 MP2 GPU
  • Memory – 512MB or 1GB DDR3
  • Storage – MicroSD card slot
  • Wired Networking – Gigabit Ethernet
  • Wireless Networking – Dual-band 802.11 b/g/n/ac WiFi 5 + Bluetooth 5.0
  • USB – 1x USB 2.0 host port, 2x USB 2.0 interfaces via 13-pin header
  • 13-pin header with 2x USB, analog stereo audio output, CVBS video output, IR input, 3x GPIOs
  • 26-pin IO header with I2C, SPI, UART, multiple GPIOs
  • Debugging – 3-pin UART header for serial console
  • Power Supply – USB Type-C port 5V
  • Dimensions – (60 x 53 mm)

All this for a board that cost less than 20euros !
looking at the cpu, we have a quad core that might be able to match the performance of a raspberry pi4 but when you look at the cost , it’s more in competition with the Raspberry PI zero W witch has a lot less features than this board and is way less powerful !

I can completely see that board screwed behind a screen and used has an emulation machine .
Or a IP security camera server using MotionEyeOs
Or connected to a ISP router to run pihole (but i would still prefer the original pi zero for this , this one is too powerful for pihole).
Maybe a domotic server like Domoticz or Jeedom , the possibilities are endless !

The main flaw of this new board is the USB port . It’s only a USB2.0 port , and it will limit pretty severely the kind of projects that you can realistically do on this board,
Even if USB2 still has a 300mbps bandwidth. I would choose a board with USB3 to run a server like OpenMediaVault.

you can buy this board here

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

Using a old intel cpu cooler on the raspberry pi 4.

Intel cpu cooler on raspberry pi

The raspberry pi 4 has one of the fastest CPU on a SBC , but it doesn’t come with any cooler ,
The raspberry is indeed capable of running without a cooler , but if you do anything other than idling, or something very lightweight like pihole, you are going to thermal throttle.

Since i have a old intel cpu cooler laying around i figured i could adapt it to cool my raspberry pi.

A old intel cpu cooler without the fan.

the cooler is way to big to be used the way it was designed. so i need to cut the cooler with a metal saw to make a new flat face , and put part of the cooler on the raspberry pi CPU.

sawing the intel cooler in two parts

after cutting the cooler you can see that i was far from having a flat surface to put in contact with the cpu.

To flatten the surface , I used a sanding disc fixed on my drill

After sanding the bumps , I obtained a kind of flat surface ,
i’m aware that it’s not truly flat , so to remedy that fact , i putted some thermal paste on the cpu surface.
The thermal compound will fill any irregularities enabling a good contact between the cpu and cooler.

Intel cpu cooler on raspberry pi
raspberry with cooler installed

Then to maintain the cooler flat on the cpu surface , i added a rubber band around the raspberry .
It will help put pressure on the radiator keeping it well pressed on the raspberry cpu

With this cooler the idle temp is aroud 50c and jump to 65c under load (ffmepg encoding)
The thermal throttling temperature of 85c is nevec reached

Installing Jellyfin on a Rasberry PI4 (Rasbian Buster)

The openSSL problem is now corrected , you should not be obliged to do what is described in this page

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

bash : Random number in OpenWRT

On some light linux environement running busybox or openWRT you will notice that you don’t have access to the $RANDOM variable ,
the date command is also incomplete so you can’t use the tail of the nanosecond date to have a random number.

.

Using this command you will get a random number beetween 0 and 69.
if you wish to change the range of the random numbers , just edit the regex in the grep part

Using AWK to display the min the max and the average of a list

awk is a extremely powerful tool !
i’m always surprised how much you can do with it.

My latest finding is pretty amazing.

Lets say you have a list of numbers , and you want to figure out the bigger number , the lower number , and the average of all the numbers in the list.

you can use the following awk code to print minimum, maximum and average.

The output is going to  be :
avg 32.93 | max 100.1 | min 1.5

you can also use this code with decimal numbers