Cov txheej txheem:

Yuav Ua Li Cas Tswj Npias Fermentation Kub thiab Nqus Los Ntawm Koj Lub Smartphone: 4 Kauj Ruam (nrog Duab)
Yuav Ua Li Cas Tswj Npias Fermentation Kub thiab Nqus Los Ntawm Koj Lub Smartphone: 4 Kauj Ruam (nrog Duab)

Video: Yuav Ua Li Cas Tswj Npias Fermentation Kub thiab Nqus Los Ntawm Koj Lub Smartphone: 4 Kauj Ruam (nrog Duab)

Video: Yuav Ua Li Cas Tswj Npias Fermentation Kub thiab Nqus Los Ntawm Koj Lub Smartphone: 4 Kauj Ruam (nrog Duab)
Video: 1 20 22 tshuaj tiv thaiv kab mob-19 yog dab tsis tiag 2024, Hlis ntuj nqeg
Anonim
Yuav Ua Li Cas Tswj Npias Fermentation Kub thiab Nqus Los Ntawm Koj Lub Xov Tooj
Yuav Ua Li Cas Tswj Npias Fermentation Kub thiab Nqus Los Ntawm Koj Lub Xov Tooj

Thaum npias fermenting, koj yuav tsum saib xyuas nws qhov nqus thiab qhov kub txhua hnub. Nws yog ib qho yooj yim kom hnov qab ua li ntawd, thiab ua tsis tau yog tias koj nyob deb.

Tom qab qee qhov googling, Kuv pom ntau qhov kev daws teeb meem rau kev tswj xyuas lub ntiajteb txawj nqus (ib, ob, peb). Ib ntawm lawv, nrog lub tswvyim ntse heev, hu ua Tilt. Qaij yog ntab hauv koj npias thiab ntsuas nws tus kheej qaij kaum. Lub kaum sab xis no nyob ntawm cov kua ntom ntom, thiab yog li ntawd tuaj yeem ntsuas qhov nqus ntawm npias fermenting.

Qaij los nrog lub mobile app, uas txuas rau nws thiab tuaj yeem tshaj tawm cov ntaub ntawv rau txhua qhov kev pabcuam hauv web. Qhov teeb meem yog tias koj yuav tsum tsis txhob nyob deb ntawm Tilt thiaj tuaj yeem ua tau. Kuj tseem muaj Raspberry Pi program uas ua haujlwm nrog Tilt.

Kauj Ruam 1: Tau Tilt Cov Ntaub Ntawv hauv Python

Tau Tilt Cov Ntaub Ntawv hauv Python
Tau Tilt Cov Ntaub Ntawv hauv Python

Kuv twb tau siv Raspberry Pi los tshuaj xyuas qhov ntsuas kub hauv chav, thiab huab tswj hwm kev pabcuam cloud4rpi.io. Yog Tilt tuaj yeem tham nrog Raspberry Pi, nws yuav tsum muaj peev xwm txuas tau cloud4rpi rau nws. Qaij yog siv cov txheej txheem wireless, yog li koj yuav xav tau Raspberry Pi nrog lub wireless nti (Rasbperry Pi 3 lossis Zero W).

Hmoov zoo, muaj GitHub repo rau Tilt software nrog qee qhov piv txwv. Saib ntawm https://github.com/baronbrew/tilt-scan koj tuaj yeem pom tias Tilt zoo li lwm tus li BLE iBeacon, nrog "Xim" coded hauv UUID, thiab qhov kub thiab lub ntiajteb txawj nqus yog qhov loj thiab me me.

Lawv cov qauv piv txwv yog rau Node.js, thiab kuv muaj Python tswj qhov program raws cloud4rpi template

Yog li kuv yuav tsum tau txais Tilt cov ntaub ntawv hauv Python. Tom qab qee qhov googling, Kuv pom https://github.com/switchdoclabs/iBeacon-Scanner-- Python iBeacon scanner. Nov yog qhov haujlwm, tsis yog lub tsev qiv ntawv, yog li kuv hloov kho nws kom rov txhais phau ntawv txhais lus tsis siv txoj hlua. Thiab kuv kuj tau sau Tilt-tshwj xeeb module kom tau txais xim, qhov kub thiab lub ntiajteb txawj nqus ntawm thawj Tilt pom (Kuv tsuas muaj ib qho), thiab qhov kev sim yooj yim los tshuaj xyuas yog tias nws tuaj yeem pom kuv Qaij:

ntshuam sij hawm ntshuam qaij

thaum Muaj Tseeb:

res = tilt.getFirstTilt () print res lub sij hawm.sleep (2)

Khiav thiab xyuas tias nws ua haujlwm. Tam sim no kuv tuaj yeem ntsaws nws rau kuv qhov program tswj. Kuv twb muaj qhov kev pab cuam nab nab txuas nrog cloud4rpi.io, tab sis cia kuv qhia yuav ua li cas los ntawm kos.

Kauj Ruam 2: Txuas Cov Ntaus rau Huab

Txuas Tus Ntaus rau Huab
Txuas Tus Ntaus rau Huab
Txuas Tus Ntaus rau Huab
Txuas Tus Ntaus rau Huab

Ua ntej, kos npe rau hauv cloud4rpi.io, tom qab ntawd tsim lub cuab yeej tshiab.

Koj yuav tau txais lub cim ntaus cim thiab cov lus qhia teeb tsa. Txog Raspberry Pi ua raws cov lus qhia ntawm no https://docs.cloud4rpi.io/start/rpi/-xyuas kom tseeb tias koj lub kaw lus tau hloov kho tshiab:

sudo apt hloov tshiab && sudo apt hloov tshiab

Nruab qhov yuav tsum tau ua ua ntej:

sudo apt nruab git python nab hab sej-pip

Nruab cloud4rpi python pob:

sudo pip nruab cloud4rpi

tom qab ntawd tau txais tus qauv nab npawb app rau Raspberry Pi (rau hauv daim nplaub tshev tswj):

git clone https://github.com/cloud4rpi/cloud4rpi-raspberryp… tswj

cd tswj

hloov pauv control.py - qhia koj lub cim ntaus cim hauv kab

DEVICE_TOKEN = '_YOUR_DEVICE_TOKEN_'

Tshem tawm cov ntawv tsis tseem ceeb los ntawm kev tshaj tawm cov cuab yeej hloov pauv, tawm tsuas yog CPUTemp los ntsuas cov cuab yeej txuas:

# Muab cov ntawv tshaj tawm sib txawv ntawm no hloov pauv = {'CPU Temp': {'hom': 'lej', 'khi': rpi.cpu_temp}}

Tam sim no ua qhov kev xeem khiav:

sudo python control.py

Yog tias txhua yam zoo, koj nplooj ntawv ntaus ntawv yuav raug hloov kho tam sim nrog cov ntaub ntawv kuaj mob.

Kauj Ruam 3: Xa Cov Ntaub Ntawv mus rau Huab

Xa Cov Ntaub Ntawv rau Huab
Xa Cov Ntaub Ntawv rau Huab

Tam sim no peb yuav tsum hloov kho control.py los nyeem thiab tshaj tawm Tilt xim, kub thiab lub ntiajteb txawj nqus. Cov txiaj ntsig zoo li no:

los ntawm os ntsaws unamefrom qhov ntshuam ntshuam gethostname ntshuam sys ntshuam sijhawm ntshuam cloud4rpi ntshuam rpi ntshuam qaij

# Muab koj lub cim ntaus cim ntawm no. Kom tau txais lub cim, # zwm npe ntawm https://cloud4rpi.io thiab tsim khoom siv. DEVICE_TOKEN = '_YOUR_DEVICE_TOKEN_'

# Tsis tu ncua

DATA_SENDING_INTERVAL = 60 # secs DIAG_SENDING_INTERVAL = 600 # secs POLL_INTERVAL = 0.5 # 500 ms

lub teeb = {}

def F2C (degreesF):

rov qab (degreesF - 32) / 1.8

def getTemp (): ua

rov F2C (int (beacon ['Temp'])) yog lub teeb ci ntxiv Tsis muaj

def tauGravity ():

rov teeb tsa ['Lub ntiajteb txawj nqus'] yog lub teeb ci ntxiv Tsis muaj

def lub ntsiab ():

# Muab cov ntawv tshaj tawm sib txawv ntawm no

variables = {'Lub ntiajteb txawj nqus': {'hom': 'tus lej', 'khi': getGravity}, 'Npias Temp': {'hom': 'tus lej', 'khi': getTemp}}

diagnostics = {

'CPU Temp': rpi.cpu_temp, 'IP Address': rpi.ip_address, 'Host': gethostname (), 'Operating System': "".join (uname ())}

ntaus ntawv = cloud4rpi.connect (DEVICE_TOKEN)

device.declare (hloov pauv) device.declare_diag (kuaj mob)

device.publish_config ()

# Ntxiv qhov ncua sijhawm thib ob thib ob kom ntseeg tau tias cov cuab yeej hloov pauv tau tsim

sijhawm.sleep (1)

sim:

data_timer = 0 diag_timer = 0 thaum Tseeb: yog data_timer <= 0: thoob ntiaj teb teeb beacon = tilt.getFirstTilt () device.publish_data () data_timer = DATA_SENDING_INTERVAL

yog diag_timer <= 0: device.publish_diag () diag_timer = DIAG_SENDING_INTERVAL

time.sleep (POLL_INTERVAL)

diag_timer -= POLL_INTERVAL data_timer -= POLL_INTERVAL

tshwj tsis yog KeyboardInterrupt:

cloud4rpi.log.info ('Cov keyboard cuam tshuam tau txais. Nres …')

tsuas yog Kev zam raws li e:

error = cloud4rpi.get_error_message (e) cloud4rpi.log.error ("ERROR! %s %s", yuam kev, sys.exc_info () [0])

thaum kawg:

sys.exit (0)

yog _name_ == '_main_':

lub ntsiab ()

Tam sim no khiav nws tus kheej kom pom tias nws ua haujlwm li cas:

sudo python control.py

Yog tias txhua yam zoo, koj yuav pom koj cov kev hloov pauv online.

Txhawm rau khiav tswj.py ntawm kev pib ua haujlwm, nruab nws ua qhov kev pabcuam. Cloud4rpi muab kev teeb tsa tsab ntawv service_install.sh ua li ntawd. Kuv tau suav nws rau hauv kuv qhov repo. Txhawm rau nruab control.py ua qhov kev pabcuam, khiav

sudo bash service_install.sh control.py

Tam sim no koj tuaj yeem pib | nres | rov pib qhov kev pabcuam no los ntawm kev hais kom ua

sudo systemctl pib cloud4rpi.service

Cov kev pabcuam khaws nws lub xeev dhau los ntawm lub zog, yog li nws tau ua haujlwm, nws yuav ua haujlwm tom qab rov pib dua lossis lub zog poob.

Kauj Ruam 4: Qhov Kawg

Zaum Kawg
Zaum Kawg

Nov yog nws, tam sim no kuv muaj kuv Tilt tsis raug xa mus rau huab, yog li kuv tuaj yeem teeb tsa huab huab zoo tswj rau nws. Mus rau https://cloud4rpi.io/control-panels thiab tsim vaj huam sib luag tswj hwm tshiab, ntxiv cov cuab yeej thiab xaiv/Lub ntiajteb txawj nqus thiab Npias Kub li cov ntaub ntawv. Tam sim no kuv tuaj yeem saib xyuas dab tsi tshwm sim txawm tias kuv nyob deb ntawm tsev.

Cov cai kuv tau theej thiab sau yog muaj nyob ntawm no: https://github.com/superroma/tilt-cloud4rpi. Nws nyob deb ntawm qhov zoo tshaj plaws, nws ua haujlwm nkaus xwb nrog Tilt ib leeg, nws tsis quav ntsej txog "Xim" ntawm lub cuab yeej, txawm nws txhais li cas, thiab kuv tsis yog Python txiv leej tub hlo li, yog li kho, tawm tswv yim lossis rab diav rawg raug txais tos !

Pom zoo: