Cov txheej txheem:

Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi: 9 Cov Kauj Ruam (nrog Duab)
Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi: 9 Cov Kauj Ruam (nrog Duab)

Video: Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi: 9 Cov Kauj Ruam (nrog Duab)

Video: Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi: 9 Cov Kauj Ruam (nrog Duab)
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi
Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi
Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi
Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi
Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi
Kev Tsim Khoom Tsim Tawm - Txhawb los ntawm Raspberry Pi

Kev Tsim Khoom Tsim Tawm yog daim iav khawv koob, tab sis tsis txhob siv lub sijhawm, huab cua thiab cov lus txhawb siab, nws nthuav tawm 4 yam;

Feem pua ntawm lub sijhawm koj tau siv cov khoom tsim tau ntawm koj lub khoos phis tawj thiab xov tooj rau hnub ntawd. (RescueTime)

Koj daim ntawv yuav tsum ua los ntawm Trello

Cov duab qhia radar qhia ntau npaum li cas koj siv sijhawm nrog rau pawg ntawm cov haujlwm-apps uas koj siv piv rau kev siv yav tas los. (RescueTime)

Kev txheeb xyuas txhua lub lim tiam. (RescueTime)

Thiab yog tias feem pua ntawm lub sijhawm koj tau siv cov khoom lag luam muaj ntau dua 50% cov LEDs yuav pom xim ntsuab ntsuab. Yog tias nws qis dua 50% nws yuav tso tawm xim liab, qhia rau koj kom ua haujlwm tau zoo dua! Koj kuj tuaj yeem teeb lub hom phiaj koj tus kheej.

Tus qauv

Hauv thawj kauj ruam, Kuv yuav piav qhia lub tswv yim tom qab tsim khoom-tracker. Tom ntej no, Kuv yuav muab koj ob lub cuab yeej sib txawv & cov npe khoom, yog li koj tuaj yeem tsim qhov project tag nrho lossis cov qauv yooj yim (Tsis suav nrog LEDs) uas tsis xav tau kev txawj ntse. Tom qab ntawd kuv yuav qhia koj li cas kuv tsim qauv ntawm kuv qhov project, yog li koj muaj lub tswv yim yuav ua li cas ua tus qauv rau koj tus kheej. Tsis tas li, Kuv yuav nkag mus rau qhov nthuav dav ntawm ntu kab lus yog li koj tuaj yeem hloov kho txoj cai rau koj tus kheej xav tau. Thaum kawg, Kuv yuav muab phau ntawv qhia teeb meem rau koj raws li cov teeb meem kuv tau ntsib thaum lub sijhawm tsim no. Thiab nthuav cov npe nrog koj cov lus nug.

Lub hom phiaj ntawm cov lus qhia no tsis yog tsuas yog muab phau ntawv qhia zaub mov rau koj. Kuv yuav qhia koj txoj hauv kev kuv tsim txoj haujlwm no thiab muab cov lus nug qhib rau koj, yog li koj tuaj yeem ntxiv koj tus kheej lub tswv yim, thiab ua qhov haujlwm no ntxiv mus ntxiv. Kuv txhawb koj kom qhia koj qhov tsim thaum nws ua tiav! Cia peb pib.

Kauj Ruam 1: Lub Tswv Yim

Lub Tswv Yim
Lub Tswv Yim

Kuv tau npaj siab yuav sau Cov Lus Qhia no rau lub hlis. Tab sis ib tus phooj ywg qub ntawm kuv uas mus los ntawm lub npe "Ncua Sijhawm" tsis tso cai rau kuv. Kev ncua sijhawm yog kev ua qeeb lossis ncua sijhawm ua haujlwm lossis teeb tsa cov haujlwm, thiab tsis txhob ua cov haujlwm ntawd kom puv sijhawm nrog saib cov vis dis aus los ntawm qhov tob tob ntawm YouTube.

Muaj ib hnub thaum nyeem kab lus ntawm kev ncua sijhawm Kuv tau hla ntau lub apps/programs uas yuav pab kuv nrog kuv cov teeb meem, Trello ua haujlwm tswj hwm app thiab RescueTime ua lub sijhawm tswj app. Ob leeg ua haujlwm tau zoo rau kuv cov kev xav tau, rau lub sijhawm tsawg kawg. Tom qab ib pliag, kuv nres tshuaj xyuas cov apps zoo thiab tsis quav ntsej cov ntawv ceeb toom. Nov yog thaum kuv tuaj nrog txoj haujlwm no. Kuv yuav tso saib cov ntaub ntawv los ntawm cov apps ntawm daim iav dai rau ntawm kuv phab ntsa. Txoj kev no tsis muaj kev khiav tawm ntawm kuv lub luag haujlwm.

Thawj qhov kev kos kuv kos rau kuv txoj haujlwm yog yooj yim heev. Kuv yuav siv RescueTime API los tso saib kuv li Kev Ua Haujlwm/cuam tshuam feem pua. Thiab siv Trello API los tso saib kuv cov npe ua-ua rau hnub ntawd. Tab sis tom qab ib pliag, kuv tau ntxiv cov yam ntxwv uas kuv yuav tau piav qhia ntxaws hauv cov kauj ruam tom ntej.

Kauj Ruam 2: Cov Cuab Yeej & Qhov

Nco tseg: Nov yog cov npe cuab yeej uas kuv tau siv thaum kuv tsim, lawv tsis tas yuav zoo ib yam rau koj qhov kev tsim!

Rau lub hauv paus:

4 Meters ntawm 7x15cm playwood - 6 $ - Nws nyob ntawm koj lub vijtsam loj

30x40cm ib daim iav ib sab - nyob ntawm koj lub vijtsam loj

25x35cm Samsung saib - 15 $ - Pom ntawm lub khw muag khoom. txhua tus saib yuav ua

Raspberry Pi 3 Qauv B- 35 $ - Raspberry pi 2 kuj tseem zoo tab sis koj yuav xav tau wifi module

HDMI cable - 2 $

Rau Led Lightning:

200cm smd5050 RGB Led strip- 4 $ - Nws yuav tsum yog smd5050 ntau ntxiv ntawm qhov no tom qab …

  • Peb N -channel MOSFETs (piv txwv li IRLZ34N) - 2 $
  • 12V -2A lub zog hloov hluav taws xob - 3.15 $
  • Prototyping PCB - 1 $

Cov Cuab Yeej:

  • Ntoo pom
  • Ntoo kua nplaum
  • Soldering Hlau (Rau LED teeb pom kev zoo)

Kauj Ruam 3: Txoj Cai

Txoj Cai
Txoj Cai

Cov kauj ruam no yuav yog 3 ntu, koj tsis xav tau txhua ntu uas tau teev tseg hauv cov kauj ruam dhau los. Raspberry Pi thiab tus saib xyuas koj yuav siv rau txoj haujlwm no yuav tsum txaus rau theem pib ua qauv.

Teeb koj li Raspberry Pi

Yog tias koj tsis tau teeb tsa koj li Raspberry Pi tseem mus tom ntej thiab ua nws ntawm no. Rau qhov kev tsim no, koj yuav tsum teeb tsa Apache rau lub web server thiab PHP-LED-controller.

Txhawm rau nruab Apache ua raws cov ntawv qhia no.

Txhawm rau teeb tsa PHP-LED-maub los ua raws phau ntawv qhia no los ntawm Christian Nikkanen

Tam sim no rub tawm cov ntaub ntawv index.php los ntawm qhov chaw cia khoom rau koj li Raspberry Pi thiab muab tso rau ntawm txoj kev no:

/var/www/html/

Yog tias koj tsis paub txav cov ntaub ntawv ib puag ncig hauv Linux Terminal, koj tuaj yeem saib ntawm phau ntawv qhia no kom koj pib.

Customize Code

Nco tseg: Qhov no xav tau me ntsis ntawm kev paub HTML/CSS yog tias koj siv tus saib xyuas sib txawv.

Qhov kev hloov kho yuav ua tiav ntawm cov ntawv index.php uas yog lub hearth ntawm qhov kev tsim no. Tam sim no mus tom ntej thiab txuas koj lub monitor rau koj Raspberry Pi yog tias koj tsis tau ua dua.

Tam sim no yog tias koj sim qhib cov ntawv index.php nws yuav tsis ua haujlwm vim tias koj yuav tsum xub sau tus lej API hauv tus lej, rau qhov ntawd mus rau RescueTime lub vev xaib thiab qhib tus account. Tom ntej no, mus rau ntu tsim tawm thiab tsim tus lej API los ntawm nias Activate Key no. Sau koj tus lej API rau qee qhov chaw.

Ua tib yam rau koj tus lej Trello API, Qhib tus as khauj thiab mus rau tus tsim tawm portal los tsim tus lej API.

Tom ntej no, qhib cov ntawv index.php uas koj muab tso rau hauv/var/www/html/hauv qhov koj nyiam cov ntawv sau, thiab hloov [API_KEY] nrog koj tus kheej tus lej API uas koj tau txais los ntawm RescueTime thiab Trello raws li. [List_number] yog tus lej naj npawb uas koj siv rau koj daim ntawv yuav tsum ua Trello. Txhawm rau kom tus lej ntawd xub tsim cov npe tshiab ntawm Trello thiab hu nws "To-Do", qhov no yuav yog cov npe uas koj yuav siv rau koj daim ntawv yuav tsum ua thiab nws yuav tshwm rau ntawm daim iav.

Tom ntej no, Siv qhov URL ntawm koj qhov chaw nyob bar uas zoo li:

trello.com/b/3hS6yyLo/board-name

thiab ntxiv.json rau nws zoo li no:

trello.com/b/3hS6yyLo/board-name.json

thiab nias nkag mus, tom ntej no koj yuav pom ib qho chaws cuam tshuam ntawm lub vijtsam. Sim nrhiav koj daim ntawv teev npe '' To-Do 'ntawm qhov kev tsis txaus ntseeg. Nws yuav tsum zoo li qhov no: {"name": "To Do", "id": "5981c123cd1b23f13907cd18"}, Tus ID ntawd yog koj daim ID. tus lej ntawd rau [list_number] ntawm cov ntawv index.php.

Tam sim no qhib koj tus browser thiab ntaus localhost rau qhov chaw nyob bar thiab nias sau. Koj yuav tsum pom koj cov ntaub ntawv tso tawm ntawm kab ntawv.

Nco tseg: Cov ntawv tso rau hauv kab duab tuaj yeem sib txawv vim yog qhov kev daws teeb meem ntawm lub saib uas koj siv. Koj tuaj yeem hloov kho qhov dav, qhov siab thiab qhov chaw ntawm cov ntsiab lus hauv CSS ib feem ntawm txoj cai.

Tam sim no txhua yam uas tau ua yog tsim lub thawv nyob ib puag ncig saib thiab txuas cov LEDs.

Nco tseg: Yog tias koj tsis txaus siab rau API's kom ntxaws koj tuaj yeem hla mus rau kauj ruam tom ntej. Hauv API ntu kuv yuav tau qhia meej tias tag nrho txoj haujlwm ua haujlwm li cas thiab tau txais cov ntaub ntawv los ntawm APIs.

API's (hauv kev nthuav dav)

Qhov siab ntawm txoj haujlwm no yog Ob Qhov APIs;

  • Trello API
  • RescueTime API

Txawm hais tias cov ntaub ntawv muaj cov ncauj lus kom ntxaws muaj, Kuv yuav piav qhia cov ntaub ntawv twg los ntawm API qhov haujlwm no siv.

Ntawm lub sijhawm tswj hwm, RescueTime API hu uas tau txais cov ntaub ntawv sijhawm rau hnub tam sim no yog, "https://www.rescuetime.com/anapi/data?key=[API_KEY]&perspective=rank&interval=hour&restrict_begin=".date('Ym-d')."&restrict_end=".date('Ym-d '). "& hom = json"

qhov twg, date ('Y-m-d') yog hnub tam sim no

kev xav = qib yog cov ntaub ntawv txheeb hom hauv qhov no "qeb" uas sawv cev rau feem ntau siv sijhawm

Qhov kev hu no yuav muab cov ntaub ntawv hauv JSON hom uas zoo li no: (saib cov ntaub ntawv. Json thaum kawg ntawm cov kauj ruam no)

Cov ntaub ntawv peb siv los ntawm cov ntaub ntawv no yog "Lub Sijhawm Siv (vib nas this)" thiab "Kev tsim khoom" uas muaj qhov tseem ceeb ntawm -2 thiab 2, -2 cuam tshuam thiab 2 ua haujlwm tau zoo. Nrog cov ntaub ntawv no, peb tuaj yeem tsim tus nqi ntau dua 100 rau cov qhab nia tsim khoom.

Lwm qhov API hu rau RescueTime, "https://www.rescuetime.com/anapi/daily_summary_feed?key=[API_KEY]"

Uas muab rau koj cov ntsiab lus txhua lub lim tiam ntawm koj cov ntaub ntawv, uas zoo li qhov no: (saib cov ntsiab lus.json ntawm qhov kawg ntawm cov kauj ruam no.) Kuv siv cov ntaub ntawv no los tsim cov ntawv qhia ntxaws txhua lub lim tiam uas muab rau koj lub ntsiab lus ntawm lub lim tiam.

Trello API hu, "https://api.trello.com/1/lists/[list_number[/cards?fields=name&key=[API_KEY]&token=[Token]"

Qhov no yuav muab koj daim npav ntawm koj daim ntawv teev npe Trello zoo li no:

[{"id": "5a4160103bfcd14994852f59", "name": "ceylan cinemagraph"}, {"id": "59e8241f6aa8662a51eb7de6", "name": "Kawm GitHuB"}, {"id": "5981c19577c732" ":" Tshaj tawm Kev Qhia "}, {" id ":" 5a341dba7f17d235d7c5bbd1 "," name ":" SPACE PROGRAM "}]

dua koj tuaj yeem rub cov ntawv ntawm daim npav ntawd thiab muab tso rau lwm qhov.

data.json

Formatted JSON Cov Ntaub Ntawv
{
"sau ntawv": "cov ntaub ntawv yog cov kab ntawm cov kab (kab), cov npe kab rau kab hauv kab hauv kab hauv kab",
"kab_headers": [
"Qib",
"Sijhawm Siv (vib nas this)",
"Tus naj npawb ntawm Cov Neeg",
"Kev ua",
"Qeb",
"Ua Tau Zoo"
],
"kab": [
[
1,
1536,
1,
"en.0wikipedia.org",
"Uncategorized",
0
],
[
2,
1505,
1,
"youtube.com",
"Yees duab",
-2
],
[
3,
1178,
1,
"OpenOffice",
"Sau ntawv",
2
],
[
4,
709,
1,
"moodle.bilkent.edu.tr",
"General Reference \u0026 Learning",
2
],
[
5,
602,
1,
"google.com.tr",
"Nrhiav",
2
],
[
6,
439,
1,
"reddit.com",
"Xov Xwm General \u0026 Lub Tswv Yim",
-2
],
[
7,
437,
1,
"tr.sharelatex.com",
"Sau ntawv",
2
],
[
8,
361,
1,
"yemeksepeti.com",
"General Khw",
-2
],
[
9,
356,
1,
"Gmail",
"Email",
0
],
[
10,
328,
1,
"Google Chrome",
"Cov browser",
0
],
[
11,
207,
1,
"stars.bilkent.edu.tr",
"General Reference \u0026 Learning",
2
],
[
12,
179,
1,
"whatsapp",
"Cov lus tam sim",
-1
],

saib rawdata.json tuav nrog ❤ los ntawm GitHub

ntsiab lus.json

[
{
"ID": 1515657600,
"hnub tim": "2018-01-11",
"productivity_pulse": 54,
"heev_productive_percentage": 34.2,
"khoom_ %": 10.6,
"nruab nrab_ %": 25.6,
"distracting_percentage": 0.0,
"heev_distracting_percentage": 29.6,
"tag nrho_productive_percentage": 44.8,
"tag nrho_distracting_percentage": 29.6,
"tsis muaj npe nyob hauv %": 16.1,
"lag luam_ %": 6.0,
"kev sib txuas lus_and_scheduling_percentage": 4.3,
"social_networking_percentage": 0.0,
"tsim_and_composition_percentage": 0.0,
"kev lom zem_ %": 15.2,
"xov xwm_ %": 3.3,
"software_development_percentage": 5.4,
"reference_and_learning_percentage": 22.8,
"khw_ %": 12.9,
"utilities_percentage": 14.1,
"tag nrho cov teev": 2.51,
"ua_productive_hours": 0.86,
"tsim khoom_hours": 0.27,
"nruab nrab_hours": 0.64,
"cuam tshuam_hours": 0.0,
"heev_distracting_hours": 0.74,
"all_productive_hours": 1.12,
"txhua_distracting_hours": 0.74,
"Uncategorized_hours": 0.4,
"lag luam_hours": 0.15,
"kev sib txuas lus_and_scheduling_hours": 0.11,
"social_networking_hours": 0.0,
"tsim_and_composition_hours": 0.0,
"lom zem_hours": 0.38,
"news_hours": 0.08,
"software_development_hours": 0.13,
"reference_and_learning_hours": 0.57,
"khw_hours": 0.32,
"nqi hluav taws xob_hours": 0.35,
"total_duration_formatted": "2h 30m",
"very_productive_duration_formatted": "51m 26s",
"tsim khoom_duration_formatted": "15m 56s",
"nruab nrab_duration_formatted": "38m 34s",
"distracting_duration_formatted": "tsis muaj sijhawm",
"heev_distracting_duration_formatted": "44m 30s",
"all_productive_duration_formatted": "1h 7m",
"tag nrho_distracting_duration_formatted": "44m 30s",
"tsis muaj qeb_duration_formatted": "24m 11s",
"lag luam_duration_formatted": "9m 6s",
"communication_and_scheduling_duration_formatted": "6m 26s",
"social_networking_duration_formatted": "tsis muaj sijhawm",
"design_and_composition_duration_formatted": "tsis muaj sijhawm",
"entertainment_duration_formatted": "22m 49s",
"news_duration_formatted": "4m 55s",
"software_development_duration_formatted": "8m 3s",
"reference_and_learning_duration_formatted": "34m 17s",
"shopping_duration_formatted": "19m 22s",
"nqi hluav taws xob_duration_formatted": "21m 17s"
},
{
"ID": 1515571200,
"hnub": "2018-01-10",
"productivity_pulse": 33,
"heev_productive_percentage": 21.9,
"khoom_ %": 2.3,
"nruab nrab_ %": 14.4,
"cuam tshuam_ %": 11.0,
"heev_distracting_percentage": 50.3,
"tag nrho_productive_percentage": 24.2,
"tag nrho_distracting_percentage": 61.4,
"tsis muaj npe nyob hauv %": 0.3,
"lag luam_ %": 0.0,
"kev sib txuas lus_and_scheduling_percentage": 13.5,
"social_networking_percentage": 0.0,
"tsim_and_composition_percentage": 6.3,
"kev lom zem_ %": 44.7,
"xov xwm_ %": 4.2,
"software_development_percentage": 0.0,
"reference_and_learning_percentage": 15.5,
"khw_ %": 0.0,
"utilities_percentage": 15.4,
"tag nrho cov teev": 2.24,
"ua_productive_hours": 0.49,
"tsim khoom_hours": 0.05,
"nruab nrab_hours": 0.32,
"cuam tshuam_hours": 0.25,
"heev_distracting_hours": 1.13,
"tag nrho_productive_hours": 0.54,
"txhua_distracting_hours": 1.37,
"Uncategorized_hours": 0.01,
"lag luam_hours": 0.0,
"kev sib txuas lus_and_scheduling_hours": 0.3,
"social_networking_hours": 0.0,
"tsim_and_composition_hours": 0.14,
"kev lom zem_hours": 1.0,
"news_hours": 0.09,
"software_development_hours": 0.0,
"siv_and_learning_hours": 0.35,
"khw_hours": 0.0,
"nqi hluav taws xob_hours": 0.34,
"total_duration_formatted": "2h 14m",
"very_productive_duration_formatted": "29m 22s",
"tsim khoom_duration_formatted": "3m 8s",
"neutral_duration_formatted": "19m 18s",
"cuam tshuam_duration_formatted": "14m 48s",
"heev_distracting_duration_formatted": "1h 7m",
"all_productive_duration_formatted": "32m 30s",
"tag nrho_distracting_duration_formatted": "1h 22m",
"tsis muaj qeb_duration_formatted": "27s",
"business_duration_formatted": "1s",
"kev sib txuas lus_and_scheduling_duration_formatted": "18m 5s",
"social_networking_duration_formatted": "tsis muaj sijhawm",
"design_and_composition_duration_formatted": "8m 30s",
"kev lom zem_duration_formatted": "59m 54s",
"news_duration_formatted": "5m 39s",
"software_development_duration_formatted": "tsis muaj sijhawm",
"reference_and_learning_duration_formatted": "20m 51s",
"shopping_duration_formatted": "tsis muaj sijhawm",
"nqi hluav taws xob_duration_formatted": "20m 39s"
},
{
"ID": 1515484800,
"hnub tim": "2018-01-09",
"productivity_pulse": 68,
"heev_productive_percentage": 60.4,
"khoom_ %": 0.5,
"nruab nrab_ %": 11.0,
"cuam tshuam_ %": 7.1,
"heev_distracting_percentage": 21.0,
"tag nrho_productive_percentage": 60.9,
"tag nrho_distracting_percentage": 28.1,
"uncategorized_percentage": 9.1,
"lag luam_ %": 21.9,
"communication_and_scheduling_percentage": 7.2,
"social_networking_percentage": 5.1,
"tsim_and_composition_percentage": 1.2,
"kev lom zem_ %": 1.6,
"xov xwm_ %": 12.5,
"software_development_percentage": 9.1,
"reference_and_learning_percentage": 28.2,
"khw_ %": 2.9,
"nqi hluav taws xob_ %": 1.2,
"tag nrho cov teev": 2.78,
"ua_productive_hours": 1.68,
"tsim khoom_hours": 0.01,
"nruab nrab_hours": 0.31,
"cuam tshuam_hours": 0.2,
"heev_distracting_hours": 0.58,
"tag nrho_productive_hours": 1.69,
"txhua_distracting_hours": 0.78,
"Uncategorized_hours": 0.25,
"lag luam_hours": 0.61,
"kev sib txuas lus_and_scheduling_hours": 0.2,
"social_networking_hours": 0.14,
"tsim_and_composition_hours": 0.03,
"entertainment_hours": 0.04,
"xov xwm_hours": 0.35,
"software_development_hours": 0.25,
"siv_and_learning_hours": 0.78,
"khw_hours": 0.08,
"Utilities_hours": 0.03,
"total_duration_formatted": "2h 46m",
"very_productive_duration_formatted": "1h 40m",
"tsim khoom_duration_formatted": "47s",
"neutral_duration_formatted": "18m 23s",
"cuam tshuam_duration_formatted": "11m 49s",
"heev_distracting_duration_formatted": "34m 57s",
"all_productive_duration_formatted": "1h 41m",
"tag nrho_distracting_duration_formatted": "46m 46s",
"tsis muaj npe nyob rau qib_duration_formatted": "15m 7s",
"business_duration_formatted": "36m 26s",
"communication_and_scheduling_duration_formatted": "11m 59s",
"social_networking_duration_formatted": "8m 28s",
"design_and_composition_duration_formatted": "2m 4s",
"entertainment_duration_formatted": "2m 39s",
"news_duration_formatted": "20m 49s",
"software_development_duration_formatted": "15m 5s",
"reference_and_learning_duration_formatted": "46m 59s",
"shopping_duration_formatted": "4m 51s",
"nqi hluav taws xob_duration_formatted": "2m 3s"
}
]

saib rawsummary.json tuav nrog ❤ los ntawm GitHub

Kauj ruam 4: Prototyping

Qhov khoom plig loj hauv Raspberry Pi Contest 2017

Pom zoo: