Xiaomi Miflora Sensor Integration

I don’t think it’s a question of RPi2 or RPi3. Let me look into that in the next couple of days…

Thanks, Merry Xmas to all… Maybe we can make a java binding at some point aswell,since this plant sensor is the best i have come across so far.

Waiting patiently for BLE support to appear in smarthome / openHAB. After that, I guess the first thing I’ll do is to convert my script based setup to a proper binding :smile:

1 Like

Hey Kim, just writing to inform you that I sadly didn’t find any time to test this till now… Any news on your side?

@ThomDietrich unfortunate not, I was in germany lately. However when I got home three more of these nice plant sensor had arrived.

They all show nicely up on the bluez bluetooth scan, but I can not compile the pyton script on openahbian, so thats where I am at the moment. I did however start some research to find out if there is an open plant library(to tell us when to water what plant, tell if its not enough light etc)

Is it still python3 gattlib that won’t be installed?
How much did you increase the swap?

Regards, S

Hi I tried searching around on the web for increasing the swap memory, but It seems to be several commands availble, and some says its also dangerous, so is the correct way to do it?

sudo nano /etc/dphys-swapfile 

change
CONF_SWAPSIZE=300


/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start

sudo pip3 install gattlib

sudo nano /etc/dphys-swapfile 

change
CONF_SWAPSIZE=100


/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start

I also came across this database for plants, maybe we can use som regex and grab pictures, waterlevel from it?
https://garden.org/plants

1 Like

Well the file /etc/dphys-swapfile does not exist and /etc/init.d/dphys-swapfile stop is not valid and the whole trying made my OH freeze(worked again after reboot) so I guess I wait for someone else who knows linux to figure it out:) Its minus 10 outside and I can not risk my OH to go down, because then my heating fails aswell…

I successfully installed it today on an RPI1 with 512mb memory

Step by step:

  1. Flash and install raspian Jessie Lite 2017-01-11
  2. Put ssh file in /boot/
  3. Raspi-config make sure to set memory split to 16
  4. Reboot
  5. sudo apt-get update; sudo apt-get dist-upgrade
  6. sudo apt-get install git pkg-config libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev bluetooth python3 python3-pip pylint wicd-curses rsync mosquitto-clients python-mosquitto

sudo nano /etc/dphys-swapfile
changed CONF_SWAPSIZE=100 to CONF_SWAPSIZE=500
sudo /etc/init.d/dphys-swapfile restart

sudo pip3 install gattlib

git clone https://github.com/open-homeautomation/miflora
cd miflora
./build.sh

Regards S

@skatun I’ve looked into that solution.
The problem is, that openHABian doesn’t provide dphys-swapfile. That’s not directly my decision but I’d say it’s a good one. Still, you should be able to follow these instructions, if you first installed dphys-swapfile following the instructions here:

http://neil.franklin.ch/Projects/dphys-swapfile

After the installation was successful, simply remove or disable it again. Sorry I can’t be of more help right now. Working on other details. Good luck!

Ok, i will try to look into next week.

Hello,

I was running into the same problem with my raspi3.
Then I started all over with a fresh openHABian installation … AND

sudo apt-get install git pkg-config libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev bluetooth python3 python3-pip pylint wicd-curses rsync mosquitto-clients python-mosquitto
sudo pip3 install gattlib

Did it for me without swapfile changes … SO, it works :slight_smile:

Now running demo.py brings:
Getting data from Mi Flora
FW: 2.8.6
Name: Flower care
Temperature: 21.4
Moisture: 46
Light: 34
Conductivity: 565
Battery: 100

But now both ways from Csongor & Seaside do not work for me …
For the java solution the sproute.properties is missing and I’m not familiar with java … But the idea with the plant files is really good
I’m looking for a mysql solution since this is already running for the thermo rules in OH.

Keep you posted

Cheers Jörg

Hey @sticki, that’s good news. Maybe something changed in gattlib in the meantime…

@skatun I feel somewhat sorry, that you had so much trouble with this idea. Please let me know if you did finally succeed. If that is not the case, you could always go with a standard Raspbian installation followed by a manual openHABian run: http://docs.openhab.org/installation/openhabian.html#manual-setup

Swap did the trick to get the gitlib to compile on rpi2, however In openhabian the mqtt fails with httperror 403,
But my question is why would you use mqtt? What if the internet goes down, will it still be able to communicate on local network. Why not use exec binding the python script and the miflora.json to get the values into openhab?

My biggest problem these days are that the rpi2 is running at 100%CPU almost all the time, I do have 270 items, httpbinding, netatmo,huemulator,gpio,dmx binding installed, but struggeling to figure where the bottleneck is… So I put the Miflora on hold untill I can free up some CPU time.

I got demo.py work and return the MiFlora data no problem.
But I’m stuck on the next Seaside’s step 10-11

I have no idea where is sproute.sh? Do I have to create one, or get one from somewhere and where shall I put?

hi, I am just getting start with it,
does mine normal with below response?

python3 demo.py
Getting data from Mi Flora
connect: Device or resource busy (16)
connect: Device or resource busy (16)
connect: Device or resource busy (16)
connect: Device or resource busy (16)
FW: 2.7.0
connect: Device or resource busy (16)
connect: Device or resource busy (16)
Name: Flower care
connect: Device or resource busy (16)
connect: Device or resource busy (16)
connect: Device or resource busy (16)
connect: Device or resource busy (16)
Temperature: 4804.2
Moisture: 136
Light: 61149
Conductivity: 26231
Battery: 100

I do a power reset on mi flower and looks better, but why keep have Device or resource busy (16)
python3 demo.py
Getting data from Mi Flora
connect: Device or resource busy (16)
connect: Device or resource busy (16)
FW: 2.7.0
Name: Flower care
connect: Device or resource busy (16)
Temperature: 24.7
Moisture: 0
Light: 94
Conductivity: 0
Battery: 100

Well, after 1 minutes power reset, output same as above
python3 demo.py
Getting data from Mi Flora
connect: Device or resource busy (16)
FW: 2.7.0
Name: Flower care
connect: Device or resource busy (16)
connect: Device or resource busy (16)
connect: Device or resource busy (16)
connect: Device or resource busy (16)
connect: Device or resource busy (16)
Temperature: 4804.2
Moisture: 136
Light: 61149
Conductivity: 26231
Battery: 100

Hi, first have to say thanks for the great works, I am stuck at creating items, I trace and found should due to missing of (SPROUTE_PROPS="/home/pi/sproute.properties"), would you mind explain how should I config this file?
also I found sproute.sh inside jar content is difference with you write in here, will it be a issue?

I bought this item and when it was connet to the phone, it updated th firmware and now i cant connet it again. I can see it from bluetooh but it doesnt connect.
How can i reinstall the firmware?.
Apologize for my english

Hello! Firmware vryatli you change it back to an older. Tell me, what firmware version you have now? I have everything working on 2.8.6.