CS, ECE硕士项目调研 /life/cs-ece-master-programs.html

为了准备2021硕士申请,我对一些喜欢的项目做了一些调查,并汇总在这里。

To prepare for my master’s application in 2021, I did some research on some of my favorite projects and summarized them here.

排名来源:QS2020, USNews2020, 上海交大2019,csrank.global.2010-2020
四个排名代表四种视角(QS->英国,USNews->美国,上海交大->中国,csrank->cs专业贡献)

以下信息部分摘自互联网,可能有错误!!

英国 (选2-3所)

帝国理工

QS: 9
USNews: 20
上海交大: 23
csrank: 73

申请模式:

两个志愿,录取时可以看到你的第二志愿。一年只能提交一次申请。

MSc Computing Science

  • 学费£33,250
  • 时长一年

条件

  • 任何专业一等学位
  • 雅思6.5小分6/托福92小分20

案例

  • 均分85, con 85 (校友利)
  • gre330 (优留)

MSc Applied Machine Learning

  • 学费£32,500
  • 时长一年

条件

  • EEE专业一等学位
  • 雅思6.5小分6/托福92小分20

UCL

QS: 8
USNews: 21
上海交大: 15
csrank: 50

申请模式:

可以申请多次。申请由授课老师处理,不同院系不互通。

MSc Integrated Machine Learning Systems

  • 学费£28,530
  • 时长一年

条件

  • EE/CS专业二等一学位
  • 雅思6.5小分6/托福92小分读写24-30听说20-30

案例

  • 88均分 (校友利)
  • 85通信(优留)

MSc Computer Science

  • 学费£30,400
  • 时长一年

条件

  • 非CS专业二等一学位
  • 雅思7.0小分6.5/托福100小分读写24-30听说20-30

爱丁堡大学

QS: 20
USNews: 28
上海交大: 31
csrank: 33

MSc Computer Science

  • 学费-
  • 时长一年

条件

  • 大部分工程理学专业二等一学位
  • 雅思6.5小分6.0/托福92小分20

案例

  • 无录取案例,据说因为与军工有关不收亚裔

MSc Signal Processing and Communications

  • 学费-
  • 时长一年

条件

  • EE与信号相关专业二等一学位
  • 雅思6.5小分6.0/托福92小分20

美国 (选1-2所)

康奈尔大学

QS: 14
USNews: 23
上海交大: 13
csrank: 7 (参考清华8)

M.Eng. Electrical and Computer Engineering (Ithaca)

  • 学费$56,550
  • 时长一年(大部分延期一年半)

条件

  • GPA 3.8+
  • GRE 320+
  • 雅思7.0/托福小分说22读20听15写20
  • 两封推荐信

案例

  • gre320,强科研

M.Eng. Electrical and Computer Engineering (NewYork)

  • 学费$58,586
  • 时长一年

条件

  • GPA 3.8+
  • GRE 320+
  • 雅思7.0/托福小分说22读20听15写20
  • 两封推荐信

卡耐基梅隆大学

QS: 48
USNews: 82
上海交大: 95
csrank: 1

Master of Science in Information Networking

  • 学费$50,100
  • 时长两年

条件

  • GPA 3.9+
  • GRE 330+
  • 托福102
  • 三封推荐信

案例

  • 宁诺85+gre326美国暑研(优留)

哥伦比亚大学

QS: 18
USNews: 7
上海交大: 8
csrank: 15

Master of Science in Electrical Engineering

条件

  • GPA 3.7+
  • GRE 320+
  • 托福102
  • 三封推荐信
  • 可能有面试

新加坡 (选1-2所)

新加坡国立大学

QS: 11
USNews: 34
上海交大: 67
csrank: 16

  • 不同学院可申请多个专业

Master of Technology in Software Engineering

  • 学费S$5,350.00
  • 时长一年
  • 偏向有工作经验者

条件

  • GPA 3.8+
  • GRE 320+
  • 雅思6.0/托福85
  • 面试

Msc. Electrical Engineering - CE方向

  • 偏向有工作经验者

条件

  • GPA
  • 雅思6.0/托福90 (可免)

Msc. Computer Science

  • 偏向有工作经验者
  • 转专业可能有限制

条件

  • GPA 3.8+
  • GRE 320+
  • 雅思6.0/托福90 (可免)

南洋理工大学

QS: 11
USNews: 43
上海交大: 73
csrank: 53

  • 不同学院可申请多个专业

Msc Artificial Intelligence

  • 学费S$58,000.00
  • 时长一年

条件

  • GPA 3.8+
  • 雅思6.5/托福100 (可免)

MSc Computer Control & Automation

  • 学费S$3,350.00
  • 时长一年

条件

  • GPA 3.6+
  • 雅思6.5/托福100

加拿大 (选0-1所)

多伦多大学

QS: 29
USNews: 18
上海交大: 24
csrank: 18

MEng. Electrical and Computer Engineering

  • 时长12-24
  • 学费+生活费40万/年

条件

  • GPA 3.6+
  • 雅思6.5小分6.0/托福100写作22
  • gre
  • 三封推荐信

瑞士 (选0-2所)

苏黎世联邦理工

QS: 6
USNews: 25
上海交大: 19
csrank: 10

  • 转专业不友好
  • 本科学校很重要
  • 每个地区人数有配额

Master Electrical Engineering and Information Technology

  • 时长1.5年

条件

  • GPA 3.8+ (top 5-10%)
  • 雅思7.0/托福100
  • gre 320+ (不强制)
  • 三封学术推荐信
  • 学费生活费一共20-30
  • 有奖学金

洛桑联邦理工

QS: 18
USNews: 45
上海交大: 78
csrank: 28

  • 只能申一个专业
  • 没有地区配额,全球申请者竞争

Electrical and electronic Engineering

  • 时长1.5年
  • 转专业不友好
  • 学费生活费一共20-30
  • 有奖学金

条件

  • GPA 3.8+
  • 雅思7.0/托福100
  • 三封推荐信
  • gre 320+ (不强制)

Ranking Source:QS2020, USNews2020, ARWU2019,csrank.global.2010-2020
The four rankings represent four perspectives (QS->UK,USNews->US,ARWU->China,csrank->cs Industry)

The following information section is taken from the Internet and may contain errors!!

UK

Imperial College London

QS: 9
USNews: 20
ARWU: 23
csrank: 73

Application mode:

Two choices. You can see your second choice when you are admitted.Applications can only be submitted once a year.

MSc Computing Science

  • Fee£33,250
  • 1 year

Condition

  • A first class degree in any major
  • Ielts 6.5 score 6/ TOEFL 92 score 20

Case

  • con 85 (校友利)
  • gre330 (优留)

MSc Applied Machine Learning

  • Fee£32,500
  • 1 year

Condition

  • EEE first class
  • Ielts 6.5 score 6/ TOEFL 92 score 20

UCL

QS: 8
USNews: 21
ARWU: 15
csrank: 50

Apply Method:

You can apply multiple times.The application is handled by the instructor and is not interchangeable between different departments.

MSc Integrated Machine Learning Systems

  • Fee£28,530
  • 1 year

Condition

  • First class degree in EE/CS
  • Ielts 6.5 score 6/ TOEFL 92 score reading and writing 24-30 listening and speaking 20-30

Case

  • con 88 (校友利)
  • 85 Telecom(优留)

MSc Computer Science

  • Fee£30,400
  • 1 year

Condition

  • One second class degree in a non-CS major
  • Ielts 7.0 score 6.5/ TOEFL 100 score reading and writing 24-30 listening and speaking 20-30

University of Edinburgh

QS: 20
USNews: 28
ARWU: 31
csrank: 33

MSc Computer Science

  • Fee-
  • 1 year

Condition

  • First class degree in most engineering majors
  • Ielts 6.5 score 6.0/ TOEFL 92 score 20

Case

  • No case of admission, it is said that because of military industry related not to accept Asians

MSc Signal Processing and Communications

  • Fee-
  • 1 year

Condition

  • EE and signal related major first class degree
  • Ielts 6.5 score 6.0/ TOEFL 92 score 20

USA

Cornell University

QS: 14
USNews: 23
ARWU: 13
csrank: 7

M.Eng. Electrical and Computer Engineering (Ithaca)

  • Fee$56,550
  • Duration: one year (most extensions: one and a half years)

Condition

  • 3.8 GPA
  • the GRE 320 +
  • IELTS 7.0/ TOEFL small say 22 Read 20 listen 15 write 20
  • Two letters of recommendation

Case

  • gre320,Strong scientific research

M.Eng. Electrical and Computer Engineering (NewYork)

  • Fee$58,586
  • 1 year

Condition

  • GPA 3.8+
  • GRE 320+
  • IELTS 7.0/ TOEFL small say 22 Read 20 listen 15 write 20
  • Two letters of recommendation

Carnegie Mellon University

QS: 48
USNews: 82
ARWU: 95
csrank: 1

Master of Science in Information Networking

  • Fee$50,100
  • 2 Years

Condition

  • GPA 3.9+
  • GRE 330+
  • Toefl 102
  • Three letters of recommendation

Case

  • 宁诺85+gre326(优留)

Columbia University

QS: 18
USNews: 7
ARWU: 8
csrank: 15

Master of Science in Electrical Engineering

Condition

  • GPA 3.7+
  • GRE 320+
  • the toefl 102
  • Three letters of recommendation
  • There might be an interview

Singapore

National University of Singapore

QS: 11
USNews: 34
ARWU: 67
csrank: 16

  • Different colleges can apply for multiple majors

Master of Technology in Software Engineering

  • FeeS$5,350.00
  • 1 year
  • Prefer people with work experience

Condition

  • GPA 3.8+
  • GRE 320+
  • IELTS 6.0/ TOEFL 85
  • the interview

Msc. Electrical Engineering - CE

  • Prefer people with work experience

Condition

  • GPA
  • Ielts 6.0/ TOEFL 90

Msc. Computer Science

  • Prefer those with work experience
  • There may be restrictions on changing majors

Condition

  • GPA 3.8+
  • GRE 320+
    • IELTS 6.0/ TOEFL 90 (optional)

Nanyang Technological University

QS: 11
USNews: 43
ARWU: 73
csrank: 53

  • Different colleges may apply for multiple majors

Msc Artificial Intelligence

  • FeeS$58,000.00
  • 1 year

Condition

  • GPA 3.8+
    • IELTS 6.5/ TOEFL 100 (optional)

MSc Computer Control & Automation

  • FeeS$3,350.00
  • 1 year

Condition

  • GPA 3.6+
    • IELTS 6.5/ TOEFL 100

Canada

University of Toronto

QS: 29
USNews: 18
ARWU: 24
csrank: 18

MEng. Electrical and Computer Engineering

  • Length12-24months
  • All Fee400,000 RMB/year

Condition

  • GPA 3.6+
    • IELTS 6.5 score 6.0/ TOEFL 100 writing 22
  • gre
    • Three letters of recommendation

Switzerland

Eth Zurich

QS: 6
USNews: 25
ARWU: 19
csrank: 10

  • Switching majors is not friendly
  • Undergraduate school is important
  • There is a quota for each region

Master Electrical Engineering and Information Technology

  • 1.5 year

Condition

  • GPA 3.8+ (top 5-10%)
    • IELTS 7.0/ TOEFL 100
    • GRE 320+ (not mandatory)
    • Three academic letters of recommendation
    • Total tuition and living expenses are 200,000 to 300,000 YUAN
    • With a scholarship.

Federal Institute of Technology in Lausanne

QS: 18
USNews: 45
ARWU: 78
csrank: 28

  • Only one major
  • No regional quotas, global competition for applicants

Electrical and electronic Engineering

  • 1.5 year
    • Switching majors is not friendly
    • Total tuition and living expenses are 200,000 to 300,000 YUAN
    • With a scholarship.

Condition

  • 3.8 GPA
  • IELTS 7.0/ TOEFL 100
  • Three letters of recommendation
  • GRE 320+ (not mandatory)
]]>
life master investigation
Hello Hexo /tech/hello-hexo.html

将blog从Typecho迁移到了Hexo。

Migrated blog from Typecho to Hexo.

]]>
tech hexo
认知派生论 /thoughts/cognitive-derived-theory.html

拜读了毛主席的实践论和矛盾论,第一次系统地接触了辩证唯物论这一方法论,深感其强大与自然。综合我自己先前的所经所悟,提炼出认知派生这一观点。

After reading Chairman Mao’s theory of practice and contradiction, it was the first time to systematically come into contact with the methodology of dialectical materialism, and I deeply felt its power and nature. Combining my own previous experience and understanding, I refined the view of cognitive derivation.

从巴甫洛夫的狗铃实验[1],到上世纪50年代费斯汀格的认知失调理论[2],再到1971年津巴多教授主导的斯坦福监狱实验[3],这一系列打破预期的心理学生理学实验,一步一步揭示出,人们心理的作用形式,似乎并非大多数人所认为的那样。实际上,这看似重大的心理学发现,其实早在两个世纪前,便已被马克思,恩格斯等人从社会学角度提出,并完善成为理论。后经列宁,斯大林等人通过实践进行完善。传入国内后,被毛泽东所集大成,结合了中国传统文化的底蕴,发展成为唯物辩证法的毛泽东思想。这一论理的形成,源自于这些人对自己所观察到的社会现象以及自己基于论理所实践的社会运动的归纳总结。而这一论理,又指导了中国共产党建国,扎实地完成国内资本原始积累地奇迹。

辩证唯物论是一套自洽的方法论,它能够有效地指导我们生活实践,从实践中总结论理,再将论理运用于实践的过程。而这一循环的高效运转,正是人类进化出认知的终极意义。

结论

方法论是一种十分有效而重要的工具,它为人们提供了一套范式(习惯),帮助人们更有效地践行“社会实践->认识->论理->社会实践”这一模式。

参考文献

[1] 巴甫洛夫 - 维基百科
[2] 認知失調 - 维基百科
[3] 斯坦福监狱实验 - 维基百科

Preface

From Pavlov’s dog bell experiment[1] to Festinger’s cognitive dissonance theory in the 1950s[2], to the Stanford prison experiment led by Professor Zimbardo in 1971[3], this A series of psychology students’ physical experiments that broke expectations reveals step by step that the role of people’s psychology does not seem to be what most people think. In fact, this seemingly important psychological discovery was actually put forward by Marx, Engels and others from a sociological point of view two centuries ago and perfected it into a theory. Later, Lenin, Stalin and others improved it through practice. After being introduced to China, it was collected by Mao Zedong, combined with the heritage of Chinese traditional culture, and developed into Mao Zedong’s thought of materialist dialectics. The formation of this theory stems from these people’s summary of the social phenomena they observe and the social movements they practice based on the theory. And this reasoning guided the founding of the Communist Party of China and solidly completed the miracle of domestic capital accumulation.

Dialectical materialism is a set of self-consistent methodology, which can effectively guide our life practice, conclude the theory from practice, and then apply the theory to the process of practice. The efficient operation of this cycle is precisely the ultimate meaning of human cognition.

in conclusion

Methodology is a very effective and important tool. It provides people with a set of paradigms (habits) to help people practice the model of “social practice -> knowledge -> theory -> social practice” more effectively.

references

[1] 巴甫洛夫 - 维基百科
[2] 認知失調 - 维基百科
[3] 斯坦福监狱实验 - 维基百科

]]>
thoughts
左宗棠鸡块 /cook/zuozongtang-chiken.html

分享一下改进版炸鸡块做法哦~

Share the improved version of fried chicken nuggets~

材料准备

  • 鸡胸肉
  • 一个鸡蛋
  • 葱末蒜末

预备步骤

  • 鸡肉切小块,加料酒,生抽,淀粉,鸡蛋清,搅匀腌10分钟
  • 鸡块在面粉中打滚

核心步骤

  • 热油炸鸡块至焦黄
  • 植物油蒜末炝锅
  • 加入一勺生抽,一勺多白醋,一把白糖,番茄酱翻一下
  • 加入鸡块,让鸡块上沾上酱汁
  • 撒上葱末

成品图

左宗棠鸡块 2020-02-17

Material preparation

  • Chicken breast
  • An egg
  • Chopped green onion and garlic

Preliminary steps

  • Cut chicken into small pieces, add cooking wine, light soy sauce, starch, egg white, stir well and marinate for 10 minutes
  • Chicken nuggets rolled in flour

Core steps

  • Hot fried chicken nuggets until browned
  • Vegetable oil minced garlic pot
  • Add a spoonful of light soy sauce, a spoonful of white vinegar, a handful of sugar and ketchup
  • Add chicken nuggets, so that the chicken nuggets are covered with sauce
  • Sprinkle with chopped green onions

Finished picture

Zuo Zongtang Chicken Nuggets 2020-02-17

]]>
cook chiken
欧洲旅行支票兑换攻略 /travel/traveler-cheque.html

之前去欧洲旅游办签证,由于没有三个月的银行流水,不得已购买了旅行支票作为资金证明。可是到了欧洲才发现旅行支票很难使用,如果不了解行情会被骗收15%-20%的手续费。这篇Blog记录了我们发现的兑换旅行支票的坑和Tips!

Before I went to Europe for a tourist visa, I had to buy a traveler’s cheque as a proof of funds because I did not have a three-month bank flow. However, when I arrived in Europe, I found that traveler’s cheques were difficult to use. If I didn’t understand the market, I would be defrauded of 15%-20% handling fees. This blog records the pits and Tips we found in redeeming traveler’s checks!

[scode type=”info”]经验一: 尽可能不使用旅行支票[/scode]
[scode type=”info”]经验二: 旅支兑换最低手续费在4%左右[/scode]

若不想看经历,可直接调至文末兑换旅行支票的Tips处哦!

我的经历

圣诞假和室友一行四人一起DIY游欧洲,去了意大利和奥地利两个国家,共5个城市。由于英国的银行卡还没有使用到三个月,无法通过打印流水来办签证,我们选择了另一种方法—购买American Express的欧元的旅行支票。殊不知啊,兑换和使用旅行支票真真是一个大坑。

最开始据旅行支票的官网上所说,欧洲很多城市的店铺里都能直接使用旅行支票,照这样来说,旅游时花掉它肯定比回英国后把它换回英镑划算的多(换回英镑的过程需要损失8%)。然鹅,出发前我们通过看他人的游记发现,欧洲现在很多店都无法直接花旅行支票(按我们后来实际旅行情况来看,只在威尼斯的好几家店看到了旅行支票的标识),于是我们决定去了就在机场红色标识的Change那里将它们全数换成欧元。

Change

可到了第一站罗马找到了红色的Change后(如图),却发现700欧元只能给我们590多欧元。这可真的亏的不是一丁半点儿。我对象现场查到了American Express的电话,打过去发现人家现在在意大利没有设点,不过对方建议去银行换,说是可以毫无亏损(注意这也是个坑,,,)。由于有两人已经换了,为了止损,我们决定先不换剩下两人的700欧旅行支票,留着去银行换。

到了第三天,我们去了梵蒂冈那块儿玩,顺便去了附近American Express工作人员推荐的银行,还给中国银行打电话,结果均被告知不接受旅支。这可咋整?

这时刚好发现梵蒂冈周围有一堆change,于是又去问了问报价。其中有一家本来只报590多的,听见我们说另一家给了610多的价,说他们能给我们一个student discount,然后还算了算,报了个640。这下可好,我们开始发现这里面的门道了:其实哪有什么折扣,不过想找个借口吸引你罢了。这些change都是盈利性质的,你把旅支给了他们,他们再通过自己的途径卖给别的地方的American Express,中间可能有一点税收,但只要他们以比扣掉税收低的价格从你这里买下,他就一定能赚(一般还赚不少),不过是多赚点少赚点的区别罢了。而且当地有好几家change,我们主要发现了红色change标识的一家和蓝色的一家。若这家嫌你要求高不接受,那钱就让别家赚了呗。

所以这种时候,我们要想拿到高点的报价,就要掐准人家能接受的度(真的逼太狠了断了人家财路那就没辙了呀),然后通过让他们产生危机意识而提高报价。可以先问个几家,看他们一般会给多少,然后跟他说,别家给我了一个多少的价格。接下来这人可能就会开始打电话给上面的看能给个什么更高的价,叭叭一堆后给你一个略高一点的价格哈哈,你如果不太满意,可以再去找一家问问(不过要注意,如果是同一家的不同店面,要稍微注意点,毕竟他们上面的人可能是一个,说不定就记住你了)。一般来说,大致估估,如果说税可能是百分之二或三,那你起码还是得让人赚个20或30磅(当然你想试试再砍砍也可以,但可能难度会更大)。

于是我们最后两笔分别换的是640欧和645欧(645欧换了一家用类似方法换到的)。

Tips

  • 现在意大利可用旅支消费的地方真不太多,我们去的罗马,佛罗伦萨,威尼斯中,只有威尼斯有几家;
  • 去意大利想兑换欧元旅支,只能在标有change牌子的地方换(当然有的change是不接受旅支的,但很少)。American Express的直接兑换点,至少在意大利应该是没有了,所以没法无损失地换。但意大利的change的确不少,梵蒂冈附近就尤其多;
  • 不要遇见一家,他报个很低的价你就接受了,也不要太信他的话,要知道这很可能是在坑你不清楚内情;
  • 可以先问个两家,了解一下情况。大致估估如果说税可能是百分之二或三,那你起码还是得让人赚个20或30磅,先问问他们的报价,你可以把这个价格说成别家给你的价,去问他们能不能给你高点的价格。当然如果你脸皮薄不好意思胡扯,也可以就只是在这家价格比别家低的情况下把别家价格拿出来激激他们。

总结

以上就是所有关于旅支兑换的一些个人经历和小tips啦,当然这只是结合我们的个人体会总结的一些东西,还是要结合具体情况分析了。出去游玩肯定主要还是想多走走看看感受下,所以在经济条件允许的状况下也不建议大家在这件事上浪费太多时间,只要你自己觉得差不多能接受就行了。最后,还是想说,去意大利玩能不用旅行支票就还是别用了,毕竟真的挺麻烦还处处是坑!

[scode type=”info”]Experience One: Do not use traveler’s checks if possible[/scode]
[scode type=”info”]Experience Two: The minimum handling fee for travel exchange is around 4%[/scode]

If you don’t want to see the experience, you can directly transfer to the Tips where you can redeem traveler’s cheques at the end of the article!

My experience

During the Christmas holiday, I went to Europe with my roommates and a group of four on a DIY trip to 5 cities in Italy and Austria. Since the UK bank card has not been used for three months, it is not possible to apply for a visa by printing the record, so we chose another method-buying American Express’s Euro traveler’s cheque. As everyone knows, exchanging and using traveler’s checks is really a big pit.

According to the official website of traveler’s cheques, traveler’s cheques can be used directly in shops in many European cities. In this way, it’s definitely more cost-effective to spend it when traveling than to exchange it back in British pounds after returning to the UK. The British pound process requires a loss of 8%). Ran goose, we found through reading other people’s travel notes before departure that many stores in Europe cannot directly spend traveler’s checks (according to our actual travel situation later, we only saw the traveler’s check logo in several stores in Venice), so we When I decided to go, I changed all of them to Euros at the Red Marked Change at the airport.

Change

But after I found the red Change at the first stop in Rome (pictured), I found that 700 euros could only give us more than 590 euros. This is really not the slightest loss. My subject checked the phone number of American Express on the spot. I called it and found that there is no location in Italy, but the other party suggested to change to the bank, saying that there is no loss (note that this is also a pit,,,). Since two people have already exchanged them, in order to stop the loss, we decided not to exchange the 700 Euro traveler’s cheques of the remaining two people, and kept them to the bank for exchange.

On the third day, we went to the Vatican to play. By the way, we went to the bank recommended by the staff of American Express nearby. We also called the Bank of China, but we were all told not to accept travel. How can this be neat?

At this time, I just found a bunch of changes around the Vatican, so I asked for a quote again. One of them originally only reported more than 590, but we heard that the other offered us a student discount of more than 610, and then it was a good deal and reported a 640. This is great, we are beginning to discover the doorway inside: there are actually no discounts, but I want to find an excuse to attract you. These changes are all profitable. You give them your travel, and they sell them to American Express elsewhere. There may be a little tax in the middle, but as long as they charge you at a lower price than the tax deducted If you buy it here, he will definitely make a profit (generally, he will make a lot of money), but it’s just the difference between earning more and less. And there are several changes in the local area. We mainly found the one with red change and the one with blue. If this family thinks that you are demanding and unacceptable, then the money will be made by others.

Therefore, at this time, if we want to get a higher offer, we have to pinpoint what is acceptable to others (it’s really too cruel to cut off people’s wealth, then it’s okay), and then let them have a sense of crisis. Increase the offer. You can ask a few companies first to see how much they generally give, and then tell him how much other companies give me a price. Next, this person may start to call the above to see what a higher price can be offered, and after a bunch of them, they will give you a slightly higher price. Haha, if you are not satisfied, you can ask another one. Ask (but be careful, if it is a different store in the same store, be careful, after all, there may be one person above them, maybe I will remember you). Generally speaking, if you say that the tax may be two or three percent, then you still have to earn a 20 or 30 pounds. (Of course, you can try to chop and chop again, but it may be more difficult. Big).

So our last two transactions were 640 Euros and 645 Euros respectively (645 Euros were replaced by a similar method).

Tips

  • There are not too many places in Italy for travel and consumption. Among the Rome, Florence, and Venice we go to, there are only a few in Venice;
  • If you want to exchange for Euro travel in Italy, you can only change it at the place marked with the change sign (Of course, some changes do not accept travel, but very few). There should be no direct exchange points for American Express, at least in Italy, so there is no way to exchange them without loss. But there are indeed many changes in Italy, especially near the Vatican;
  • Don’t meet a family, if he quotes a very low price, you will accept it, and don’t believe him too much. You must know that this is probably because you don’t know the inside story;
  • You can ask two families first to find out the situation. A rough estimate. If the tax may be two or three percent, then you still have to make people earn 20 or 30 pounds. First ask them for their quotation. You can say that the price is given to you by another family. Ask if they can give you a higher price. Of course, if you have a thin skin and are embarrassed to talk nonsense, you can just give them the price of this one when the price is lower than that of others.

to sum up

The above is all the personal experiences and small tips about the exchange of travel expenses. Of course, these are just some things summarized based on our personal experience, we still need to analyze the specific situation. If you want to go out and play, you still want to walk around more to see how you feel. Therefore, it is not recommended that you waste too much time on this matter when economic conditions permit, as long as you feel that it is almost acceptable. Finally, I still want to say that if you don’t need traveler’s checks to play in Italy, you should not use it. After all, it is really troublesome and there are pits everywhere!

]]>
travel traveler's cheque Europe
一键激活win10 /tech/kms.html

一键激活win10家庭版,专业版,企业版,教育版 φ( ̄∇ ̄o)

Activate win10 Home Edition, Professional Edition, Enterprise Edition, Education Edition with one click φ( ̄∇ ̄o)

方法一(自动安装)

  • 使用此方法请先关闭所有杀毒软件
  • 使用此方法请先关闭所有杀毒软件
  • 使用此方法请先关闭所有杀毒软件

p.s. 如果不放心,请使用 方法二-源码安装



  • 运行刚下载的程序。(请不要修改解压路径)
  • 运行刚下载的程序。(请不要修改解压路径)

  • 点击 更多信息->仍然运行


  • 输入数字进行选择。(可输入数字4获取汉语翻译!!)


  • 耐心等待激活完成~ ::aru:proud::

脚本已发送到桌面kms.bat,如果不需要您可以删除它~

方法二(源码安装)

  • 点击这里下载压缩文件。

  • 解压压缩文件(请务必解压,否则无法运行)
  • 解压压缩文件(请务必解压,否则无法运行)
  • 解压压缩文件(请务必解压,否则无法运行)

  • 双击运行文件夹中的kmskms.bat

压缩文件示例

  • 点击 更多信息->仍然运行


  • 输入数字进行选择。(可输入数字4获取汉语翻译!!)


  • 耐心等待激活完成~ ::aru:proud::

进阶

激活码

您的激活码将保存在C:\Windows\kms.key

运行日志

  • 激活日志 %temp%\kms.log
  • 在本机尝试过的激活码 %temp%\kms.tried_keys
  • kms服务器配置 %temp%\kms.skms
  • ato输出信息 %temp%\kms.ato

恢复未激活状态

  • 进入kms.bat选择3
  • 等待完成卸载!!!

源码

Method one (automatic installation)

  • To use this method, please close all antivirus software
  • To use this method, please close all antivirus software
  • To use this method, please close all antivirus software

p.s. If you are not assured, please use Method Two-Source Installation


  • Click here to download the exe program

  • Run the program you just downloaded. (Please do not modify the decompression path)
  • Run the program you just downloaded. (Please do not modify the decompression path)

  • Click More info -> still running


  • Enter numbers to select. (You can enter the number 4 to get a Chinese translation!!)


  • Wait patiently for the activation to complete~ ::aru:proud::

The script has been sent to the desktop kms.bat, you can delete it if you don’t need it~

Method two (source installation)

  • Click here to download the compressed file.

  • Unzip the compressed file (please unzip, otherwise it will not run)
  • Unzip the compressed file (please unzip, otherwise it will not run)
  • Unzip the compressed file (please unzip, otherwise it will not run)

  • Double-click kms or kms.bat in the run folder.

Compressed file example

  • Click More info -> still running


  • Enter numbers to select. (You can enter the number 4 to get a Chinese translation!!)


  • Wait patiently for the activation to complete~ ::aru:proud::

Advanced

Activation code

Your activation code will be saved in C:\Windows\kms.key

Run log

  • Activation log %temp%\kms.log
  • Tried activation code %temp%\kms.tried_keys on this machine
  • kms server configuration %temp%\kms.skms
  • ato output information %temp%\kms.ato

Restore inactive state

  • Enter kms.bat and select 3
  • Wait for the uninstallation to complete! ! !

Source code

]]>
tech kms win10
部署新型冠状病毒API /tech/coro.html

一分钟快速部署你自己的新型冠状病毒API ୧(๑•̀⌄•́๑)૭

Deploy your own new coronavirus API in one minute ୧(๑•̀⌄•́๑)૭

coro-api

新型冠状病毒 实时数据 api
项目Git地址: iotcat/coro-api
项目npm地址: iotcat/coro-api

API示例

获取全部

https://api.yimian.xyz/coro

根据省份

https://api.yimian.xyz/coro?province=山东

根据城市

https://api.yimian.xyz/coro?city=泰安

根据省和城(推荐)

https://api.yimian.xyz/coro?province=山东&city=泰安

快速部署

环境要求

  • nodeJS支持express任意版本
  • git任意版本

下载文件

1
$ git clone https://github.com/iotcat/coro-api.git & cd coro-api

安装依赖

1
$ npm install

启动

1
$ node index.js

访问

1
http://localhost:17676

进阶

GET参数

参数描述示例
province省份(国家)山东
city城市泰安

修改端口

index.js第9行修改默认端口。

禁止跨域

注释掉index.js第13行。

使用pm2守护进程

1
2
$ npm i -g pm2
$ pm2 start index.js --name coro-api -o /var/log/coro/api.out -e /var/log/coro/api.err --watch

Nginx配置

将以下内容加入server{}

1
2
3
location / {
proxy_pass http://127.0.0.1:17676;
}

如果你不是从根目录映射,记得去index.js中第11行app.get('/', f)修改成你的路径。

爬虫配置

爬虫使用coro-py, 请参考其文档。

开源协议

本项目使用MIT协议,允许非署名商业非商业使用。武汉加油!中国加油!!❤

coro-api

Novel coronavirus real-time data api
Project Git address: iotcat/coro-api
Project npm address: iotcat/coro-api

API example

Get all

https://api.yimian.xyz/coro

According to province

https://api.yimian.xyz/coro?province=Shandong

According to the city

https://api.yimian.xyz/coro?city=泰安

https://api.yimian.xyz/coro?province=Shandong&city=Taian

Quick deployment

Environmental requirements

  • nodeJS supports any version of express
  • Any version of git

download file

1
$ git clone https://github.com/iotcat/coro-api.git & cd coro-api

Installation dependencies

1
$ npm install

start up

1
$ node index.js

Access

1
http://localhost:17676

Advanced

GET parameters

ParametersDescriptionExample
provinceProvince (Country)Shandong
city ​​cityTai’an

Modify port

Modify the default port from line 9 of index.js.

Cross-domain prohibited

Comment out line 13 of index.js.

Use pm2 daemon

1
2
$ npm i -g pm2
$ pm2 start index.js --name coro-api -o /var/log/coro/api.out -e /var/log/coro/api.err --watch

Nginx configuration

Add the following content to server{}

1
2
3
location / {
proxy_pass http://127.0.0.1:17676;
}

If you are not mapping from the root directory, remember to go to the 11th line of index.js and change app.get('/', f) to your path.

Crawler configuration

The crawler uses coro-py, please refer to its documentation.

Open Source Agreement

This project uses the MIT protocol, allowing non-signed commercial and non-commercial use. Go Wuhan! Go China! ! ❤

]]>
tech Covid-19 API
香辣牛肉面 /cook/awesome-beef-noodle.html

自研香辣牛肉面做法~

Self-developed spicy beef noodle practice~

材料准备(两人份)

  • 面条
  • 两个鸡蛋
  • 两根英国大葱切末
  • 两片姜切末
  • 适量牛肉切丁
  • 准备小碗放一个八角,桂皮,白扣,少许白胡椒粒

预备步骤

  • 热锅植物油香油煎鸡蛋
  • 热水焯一下牛肉

核心步骤

  • 热锅植物油香油,放入葱白部分炝锅
  • 加入开水和牛肉粒,加入碗中的调料,焖3分钟
  • 加入一勺生抽,半勺老抽,一勺蚝油
  • 加入适量鸡精和盐调鲜
  • 加适量红油藤椒油调辣
  • 放入面条,煮到熟

后续

  • 面条添至碗中,盖上鸡蛋
  • 加剩下的葱绿末

配图

香辣牛肉面-2020-01-19

Material preparation (for two persons)

  • Noodles
  • Two eggs
  • Two British scallions, minced
  • Two slices of ginger minced
  • Dice beef
  • Prepare a small bowl with anise, cinnamon, white button, and a little white pepper

Preliminary steps

  • Hot pot vegetable oil fragrant fried eggs
  • Blanch the beef in hot water

Core steps

  • Hot pot vegetable oil sesame oil, put the scallion part into the pot
  • Add boiling water and beef cubes, add the seasoning in the bowl, and simmer for 3 minutes
  • Add a spoonful of light soy sauce, half a spoonful of dark soy sauce, and a spoonful of oyster sauce
  • Add appropriate amount of chicken essence and salt to adjust fresh
  • Add appropriate amount of red vine pepper oil to adjust spicy
  • Add the noodles and cook until cooked

Follow up

  • Add the noodles to the bowl and cover with eggs
  • Add the remaining green onion

With pictures

Spicy Beef Noodle-2020-01-19

]]>
cook beef noodle
英国意大利申根签攻略 /travel/ivisa-checklist.html

在英国留学,圣诞去欧洲旅游,DIY了意大利申根签证。现在游完归来,总结一份申根签攻略。

I studied in the UK, traveled to Europe on Christmas, and DIYed an Italian Schengen visa. Now come back from the tour, summarize a Schengen sign strategy.

大致流程

材料类别

常规签证材料

  • Visa申请表
  • 身份证明
  • 居住证明
  • 照片

附加签证材料

  • 工作证明
  • 财产证明
  • 旅行证明
  • 住宿证明
  • 保险证明

材料CheckList

  • visa申请表原件(在线生成后打印)
  • 护照原件+复印件(黑白)
  • BRP原件+复印件(黑白)
  • 一张证件照-与英国签证一致(要求)
  • student letter
  • 旅行支票原件+复印件或三个月银行流水
  • 往返机票(姓名,日期,to&from)
  • 火车票(姓名,日期,to&from)
  • 住宿证明(姓名,日期,地址)
  • 同行者名单
  • 旅行保险证明(姓名,地理范围,保额)
  • 面签预约证明复印件

  • 旅行行程单(方便跟签证官解释)
  • joint travel confirmation letter(如果某个车票或住宿证明上没有你的名字)
  • 买票者的护照签名页复印件(如果某个车票或住宿证明上没有你的名字)

材料说明

visa申请表

  • 在线填写完第一页记得点SAVE, 记下页面右上角的Reference Number ::aru:shy::
  • 下一次登录后点击上方RETRIEVE INCOMPLETE FILLED VAF即可继续填写
  • 填写参考这篇攻略
  • 单面黑白A4打印
  • 打印好不要填写,不要签字,不要贴照片,到现场签证官会告诉你怎么办
  • 不要装订,建议用环形针

Student Letter

  • 去学校FB开
  • 需要有人签名,电子打印的签名不行
  • 抬头需要写Italy Consulate

旅行证明

  • 需要提供付过款的机票和跨城市的火车票
  • 票的底部需要有网站链接
  • 所有票上需要有你的名字
  • 如果某张票没有你的名字,需要票上有名字的人提供签过字的joint travel confirmation letter护照复印件
  • 可参考我们的joint travel confirmation letter
    joint letter

住宿证明

  • Booking Confirmation上需要有paid字样
  • 底部需要有网站链接
  • 所有材料上需要有你的名字
  • 如果没有你的名字,需要有名字的人提供签过字的joint travel confirmation letter护照复印件
  • 建议从Booking等知名网站订购

保险证明

  • 一定要覆盖旅程
  • 保期越长,签证时间越长。。
  • 我们选择的太平保险申根应急签证,供参考

预约证明

  • 到楼下前台拿着预约信挂号
  • 之后预约信就没用了

成果

最后展示一下我拿到的签证 ::aru:cheer::
visa

General process

Material category

Regular visa materials

  • Visa application form
  • personal I.D
  • Proof of residence
  • Photos

Additional visa materials

  • Proof of employment
  • Proof of property
  • Travel certificate
  • Proof of accommodation
  • Insurance certificate

Material CheckList

  • Original visa application form (print after online generation)
  • Original passport + photocopy (black and white)
  • BRP original + copy (black and white)
  • A passport photo-consistent with the UK visa (Requirements)
  • student letter
  • Original traveler’s check + copy or three-month bank account
  • Round-trip air ticket (name, date, to&from)
  • Train ticket (name, date, to&from)
  • Proof of accommodation (name, date, address)
  • Companion list
  • Travel insurance certificate (name, geographic area, insurance amount)
  • Copy of appointment certificate

  • Travel itinerary (for easy explanation with visa officer)
  • joint travel confirmation letter (if your name is not on a certain ticket or accommodation certificate)
  • Copy of the passport signature page of the ticket purchaser (if your name is not on the ticket or accommodation certificate)

Material Description

visa application form

  • After filling out the first page online, remember to click SAVE, and write down the Reference Number ::aru:shy::
  • Click RETRIEVE INCOMPLETE FILLED VAF above to continue to fill in after logging in next time
  • Fill in the reference this guide
  • Single-sided black and white A4 printing
  • After printing, do not fill in, do not sign, do not post photos, the visa officer will tell you what to do
  • Do not staple, it is recommended to use a loop pin

Student Letter

  • Go to school FB to open
  • A signature is required, and an electronically printed signature will not work
  • Head up to write Italy Consulate

Travel Proof

  • Need to provide paid air tickets and inter-city train tickets
    • A website link is required at the bottom of the ticket
  • All tickets need to have your name
  • If a ticket does not have your name, the person named on the ticket is required to provide a signed joint travel confirmation letter and a copy of passport
  • Please refer to our joint travel confirmation letter
    joint letter

Proof of Accommodation

  • paid is required on Booking Confirmation
  • A website link is required at the bottom
  • All materials need to have your name
  • If you do not have your name, the person who has the name needs to provide a signed joint travel confirmation letter and a copy of passport
  • It is recommended to order from well-known websites such as Booking

Insurance Certificate

  • Be sure to cover the journey
  • The longer the guarantee period, the longer the visa period. .
  • We chose Taiping Insurance Schengen emergency visa for reference

Appointment Proof

  • Go to the front desk downstairs to register with the appointment letter
  • After that, the appointment letter is useless

Results

Finally, let me show the visa I got~
visa

]]>
travel uk italy visa
今天很开心,在这里留个空 /life/happy.html

先在这里留个空,以后慢慢填~

Leave a blank here first, then fill it in slowly~

φ( ̄∇ ̄o)

φ( ̄∇ ̄o)

]]>
life love
Liverpool 学生公寓条件调研 /life/liverpool-accom-inves.html

为了更清晰更直观的选择出明年居住的公寓,本文汇总了网络上对各公寓的评价信息,供决策参考。

In order to more clearly and intuitively choose the apartment to live in next year, this article summarizes the evaluation information of each apartment on the Internet for decision-making reference.

[scode type=”green”]大家积极在评论区补充哦,评论推荐使用qq邮箱[/scode]
[scode type=”yellow”]持续更新中…[/scode]
[scode type=”blue”]望大家能够补充更多房源,以便调查[/scode]

所有步行距离以Guild为中心!!

Dover Court (我们的最终选择)

  • 步行距离: 8 min (西北)
  • google地图: Dover Court
  • Official Guide: Dover Court
  • 优点: 距Lidl近,安静,管理好,安全,定期有人清洁,social place好,楼下自习室很安静
  • 缺点: 房间隔音一般,部分房间小,有的地方天花板低
  • 价格: £155.54 pw (Last Year)

Horizon Heights

St Luke’s View

Apollo Court

  • 步行距离: 11 min (西北)
  • 同学反映: 不安静(老雷)

Capital Gate

  • 步行距离: 7 min (西北)

Grand Central

  • 步行距离: 12 min (西)

Philharmonic Court

  • 步行距离: 12 min (南)

The Railyard

  • 步行距离: 9 min (东)

Myrtle Court

  • 步行距离: 9 min (东)

Larch House

  • 步行距离: 7 min (西)

IQ

  • 步行距离: 9 min (西北)
  • 人脉: 老叶,灯泡

The Arch

  • 步行距离: 18 min (西南)

Albert Court

  • 步行距离: 10 min (北)

St Andrews Place

  • 步行距离: 10 min (西南)

The Ascent

  • 步行距离: 13 min (西)

Lee Court

  • 步行距离: 10 min (北)

X1 Liverpool One

  • 步行距离: 18 min (西)

X1 The Edge

  • 步行距离: 12 min (西北)
  • 其它: 快递可以寄到Cambridge Court (梁斌)

Cambridge Court

  • 步行距离: 8 min (南)
  • google地图: Cambridge Court
  • 缺点: 隔音不好,地毯潮湿,条件差

Vita Student Liverpool

  • 步行距离: 21 min (西)

Liberty Park

  • 缺点: 一楼二楼隔音不好
  • 优点: 回字形楼中间有一个小花园(娇娇,欣怡)

[scode type=”green”] Everyone is actively adding in the comment area, comments recommend using qq mailbox[/scode]
[scode type=”yellow”]Continuously updating…[/scode]
[scode type=”blue”]I hope you can add more listings for investigation[/scode]

All walking distances are centered on Guild! !

Dover Court (Our final choice)

  • walking distance: 8 min (Northwest)
  • google map: Dover Court
  • Official Guide: Dover Court
  • Pros: Close to Lidl, quiet, well managed, safe, cleaned regularly, good social place, quiet study room downstairs
  • Disadvantages: Room soundproofing is average, some rooms are small, and some places have low ceilings
  • Price: £155.54 pw (Last Year)

Horizon Heights

St Luke’s View

Apollo Court

  • Walking distance: 11 min (Northwest)
  • Classmates' reflections: Not quiet (Lao Lei)

Capital Gate

  • walking distance: 7 min (Northwest)

Grand Central

  • walking distance: 12 min (West)

Philharmonic Court

  • Walking distance: 12 min (South)

The Railyard

  • walking distance: 9 min (East)

Myrtle Court

  • walking distance: 9 min (East)

Larch House

  • walking distance: 7 min (West)

IQ

  • walking distance: 9 min (Northwest)
  • Connection: Lao Ye, Bulb

The Arch

  • walking distance: 18 min (southwest)

Albert Court

  • walking distance: 10 min (north)

St Andrews Place

  • Walking distance: 10 min (Southwest)

The Ascent

  • walking distance: 13 min (West)

Lee Court

  • walking distance: 10 min (north)

X1 Liverpool One

  • walking distance: 18 min (West)

X1 The Edge

  • Walking distance: 12 min (Northwest)
  • Others: Express can be sent to Cambridge Court (Liang Bin)

Cambridge Court

  • walking distance: 8 min (south)
  • google map: Cambridge Court
  • Disadvantages: Poor sound insulation, damp carpets, poor conditions

Vita Student Liverpool

  • walking distance: 21 min (West)

Liberty Park

  • Disadvantages: Sound insulation is not good on the first and second floors
  • Advantages: There is a small garden in the middle of Huizi Building (Jiaojiao, Xinyi)
]]>
life uk liverpool investigation accomodation
公共开支结算系统 /tech/crown-place-erp.html

在英国留学与4个室友合租,为了更好的控制和监管公共支出,以及维持彼此之间的公共支出平衡,我利用迎新周三天时间设计并开发除了此ERP公共开支计划系统。希望此系统能够便捷接下来一年的生活,减少大家之间的矛盾,促使充满幸福感的公共支出项目持久化OωO

I studied in the UK and shared with 4 roommates. In order to better control and monitor public expenditures and maintain the balance of public expenditures between each other, I designed and developed this ERP public expenditure planning system during the welcome Wednesday. I hope that this system will make life easier for the next year, reduce conflicts between everyone, and promote the sustainability of public expenditure projects full of happiness OωO

1.功能介绍

  • 统计日均周均流水,让公共支出可视化
  • 用户申报一次公共支出,并提交发票照片留证
  • 监视各成员间支出不均衡程度,计算方差,并可视化显示
  • 对比本周与上周的开支,给出增减比例
  • 当存在一人支出超出均值阈值,并且存在至少一人支出少于均值阈值,则会邮件这两个人产生一次内部交易
  • 当上例中收款人收到款项后,需要到平台确认收到
  • 平台所有历史公共开支及发票可查

2.系统架构

2.1 前端

前端基于一个网上找到的比特币网站平台模板,深度改造实现。值得一提的是,前端使用Ushio-js项目作为安全及日志插件,并得到了Ushio系统做背后支持。

2.2 后端

后端使用php语言编写。提供5个接口,分别提供获取账户事件,获取内部流通信息,获取公共支出信息,获取周报表,操作的功能。

mail系统使用Yimian Mail API快速构建。

2.3 数据库

数据库使用yimian-db/mysql。构建了三个表,分别用于存储流水,公共支出详情,内部流通。

2.4 图片上传

直接引用呓喵酱の图床代码,少量改写。

2.5 用户系统

目前用额外网页简单实现,等待ushio-auth项目完成后统一整合。

3. 外观

没啥可说的,摆图,自己看
imgbed_ed08c497

imgbed_ea04ad82

imgbed_a8b3adb0

1. Function introduction

  • Calculate the daily average weekly flow rate to visualize public expenditure
  • The user declares a public expenditure and submits the invoice photo certificate
  • Monitor the disequilibrium of expenditure among members, calculate the variance, and display it visually
  • Compare spending this week and last week, and give the percentage increase or decrease
  • When there is one person whose expenditure exceeds the average threshold, and there is at least one person whose expenditure is less than the average threshold, the two people will be emailed to generate an internal transaction
  • When the recipient receives the money in the above example, he needs to go to the platform to confirm receipt
  • All historical public expenditures and invoices on the platform can be checked

2. System Architecture

2.1 Frontend

The front end is based on a Bitcoin website platform template found on the Internet, and a deep transformation is realized. It is worth mentioning that the front end uses Ushio-js project as a security and logging plug-in, and got Ushio The system does behind the scenes.

2.2 Backend

The backend is written in php language. Provides 5 interfaces, which respectively provide the functions of obtaining account events, obtaining internal circulation information, obtaining public expenditure information, obtaining weekly statements, and operating.

The mail system is quickly constructed using Yimian Mail API.

2.3 Database

The database uses yimian-db/mysql. Three tables are constructed, which are used to store flow, public expenditure details, and internal circulation.

2.4 Image upload

Directly quote the code of 呓喵酱の图床 with a small amount of rewriting.

2.5 User System

At present, it is simple to implement with additional web pages, waiting for the ushio-auth project to complete the unified integration.

3. Appearance

Nothing to say, show the picture, see for yourself
imgbed_ed08c497

imgbed_ea04ad82

imgbed_a8b3adb0

]]>
tech crown-place uk liverpool erp system
在家中部署智慧家庭系统 /tech/smart-home.html

基于Home Assisstant搭建综合家庭照明系统,多媒体系统,水流系统的智慧家庭。技术点:天猫精灵交互,LoRa通信,MQTT协议,frp内网穿透,NAS存储,拨动开关电路改造。

Based on Home Assisstant, build a smart home with integrated home lighting system, multimedia system and water flow system. Technical points: Tmall Genie interaction, LoRa communication, MQTT protocol, FRP intranet penetration, NAS storage, and toggle switch circuit transformation.

结合所学知识,运用前沿技术,造福生活,是我长期以来的不懈追求。为了让家人体验到更加稳定、舒适智能的生活方式,同时也为了巩固憨实先前在学校smartfarm项目和我自己的ushio系统中所积累的技术基础以及架构经验,我决定在出国前,使用20到23整天时间,重构家中老旧的物联网系统。采用分层架构和面向接口、面向测试、面向文档开发原则,以稳定性(Available)可靠性(Reliable)为最优先指标,搭建一个运行目标3年以上的高度模块化的,易于远程操控的,开源的家庭软件硬件智能传感控制系统。

0 架构综述

1 硬件设计

1.1 单片机选材

使用Arduino UNO作为计算单元。一方面,Arduino Uno拥有高可靠性,我之前的智慧窗帘系统使用Arduino Uno作为主控板,平稳运行1年半未出现硬件问题。另一方面,Arduino Uno拥有较大的RAM,无需为了争夺RAM而在单片机编程上煞费苦心。

Arduino UNO的缺陷主要是价格高,但是为保障长期稳定运行,这个成本是必要的。

1.2 WiFi通信模块选材

使用ESP-01作为WiFi的通信模块。主要原因是之前学校课程使用过ESP-01搭建遥控小车,对其工作方式和性能比较了解,降低开发成本。

1.3 LoRa通信模块选材

使用安信可 LORA RA-02 LORA作为LoRa节点和LoRa网关通信模块。原因是surf项目使用的就是这个模块,比较了解它。

1.4 智能音箱选材

智能音箱作为此物联网系统人机交互的最主要界面,发挥着举足轻重的作用。经研究,我使用天猫精灵方糖R作为家用智能音箱。一方面,天猫精灵的性价比摆在那里,非常便宜。第二,与小米开发小爱同学不同,阿里开发天猫精灵的目的是提供平台,它允许开发者以各种形式接入其网络,这一点对我至关重要。

1.5 灯拨动开关

初期设想: 单向控制+复位器。
实际实现:将原有单开改造为双开,一路与继电器串联,另一路与两个pin口相连。

2 通信设计

网络拓扑图

采用WiFi+LoRa两种通信模式。在需要高速高质量通信的场景,如天猫精灵,手机,笔记本,使用WiFi作为通信手段。在WiFi信号不稳定的地方,使用LoRa进行通信。使用MQTT为应用层协议。

3 主控系统设计

使用python3开源项目Home Assistant 为基础搭建本项目的主控系统。

4 多媒体系统设计

多媒体主要由天猫精灵提供。此外,通过小米盒子,家庭网盘中的视频,图片,音乐实现了电视与音响上的播放。

5 云端支持系统设计

dns.yimian.xyz提供dns解析服务。

6 NAS存储系统设计

通过挂载从老电脑上拆卸的闲置500G机械硬盘到老IBM服务器,实现存储系统的搭建。
对局域网内,由于家里都是win系统,使用smb作为共享协议实现文件传输,支持局域网内挂载。速度稳定,全网读写10MB/s左右。对外网访问,通过http,frp反代实现,但速度较慢。


2020.6 更新

RNN实现对灯控制

基于先前积累的人体传感器数据,通过LSTM模型,使用keras训练神经网络,实现对开灯状态的预测。

Combining the knowledge I have learned and using cutting-edge technology to benefit life has been my unremitting pursuit for a long time. In order to let my family experience a more stable, comfortable and intelligent lifestyle, and to consolidate the technical foundation and architecture experience accumulated in the school smartfarm project and my own ushio system, I decided to use 20 to 23 before going abroad. All day long, reconstruct the old IoT system at home. Adopt a layered architecture and interface-oriented, test-oriented, and document-oriented development principles, with Available and Reliable as the highest priority indicators to build an operational target 3. A highly modular, easy-to-remote control, open source home software and hardware intelligent sensor control system for more than years.

0 Architecture overview

1 Hardware Design

1.1 Single Chip Microcomputer Material Selection

Use Arduino UNO as the calculation unit. On the one hand, Arduino Uno has high reliability. My previous smart curtain system used Arduino Uno as the main control board, and it ran smoothly for one and a half years without hardware problems. On the other hand, Arduino Uno has a larger RAM, so there is no need to bother to program the microcontroller in order to compete for RAM.

The main disadvantage of Arduino UNO is its high price, but this cost is necessary to ensure long-term stable operation.

1.2 WiFi communication module selection

Use ESP-01 as the WiFi communication module. The main reason is that the ESP-01 has been used to build a remote control car in the previous school courses, and I have a better understanding of its working methods and performance to reduce development costs.

1.3 LoRa communication module selection

Use Anxinke LORA RA-02 LORA as the communication module between LoRa node and LoRa gateway. The reason is that this module is used in the surf project, so I understand it better.

1.4 Smart speaker selection

As the most important interface for human-computer interaction in this Internet of Things system, smart speakers play a pivotal role. After research, I use Tmall Elf Sugar R as a home smart speaker. On the one hand, the price/performance ratio of Tmall Genie is very cheap. Second, unlike Xiaomi’s development of Xiao Ai, the purpose of Ali’s development of Tmall Genie is to provide a platform that allows developers to access its network in various forms, which is very important to me.

1.5 Light toggle switch

Initial idea: one-way control + reset device.
Actual realization: The original single-opening is transformed into double-opening, one is connected in series with the relay, and the other is connected with two pin ports.

2 Communication Design

Network Topology Diagram

Two communication modes of WiFi+LoRa are adopted. In scenarios that require high-speed and high-quality communication, such as Tmall Genie, mobile phones, and notebooks, use WiFi as a means of communication. In places where the WiFi signal is unstable, use LoRa for communication. Use MQTT as the application layer protocol.

3 Main control system design

Use the python3 open source project Home Assistant as the basis to build the main control system of this project.

4 Multimedia system design

Multimedia is mainly provided by Tmall Genie. In addition, through the Xiaomi box, the video, pictures, and music in the home network disk can be played on the TV and stereo.

5 Cloud support system design

dns.yimian.xyz provides dns resolution service.

6 NAS storage system design

By mounting the idle 500G mechanical hard disk removed from the old computer to the old IBM server, the storage system is built.
In the local area network, since the home is a win system, smb is used as a sharing protocol to realize file transfer and supports mounting in the local area network. The speed is stable, and the whole network reads and writes about 10MB/s. Access to the external network is realized through http and frp reverse generation, but the speed is slow.


2020.6 update

RNN realizes light control

Based on the previously accumulated human sensor data, the LSTM model is used to train the neural network using keras to realize the prediction of the light state.

]]>
tech Arduino iot smart-home LoRa WiFi ESP8266 MQTT
2019 SURF SmartFarming Proj 架构说明 /tech/smartfarming-surf.html

本文详细介绍了XJTLU大学2019暑期科研SmartFarming Proj物联网架构的设计思路,实施情况以及缺陷反思。

This article introduces in detail the design ideas, implementation status and defect reflections of the SmartFarming Proj IoT architecture of XJTLU University’s 2019 summer scientific research.

1 背景

1.1 需求

为了探究农业物联网技术的可行性,Alam Mohammed导师希望我们能够提供一个稳定(Available)可靠(Reliable)的物联网系统,以实现对农田的智能监控和管理。这个系统将能够适时地探测土壤以及空气中与植物健康相关的参数,处理并存储这些数据(由Alam提出)。同时,自动化控制的灌溉功能(由Caleb提出)以及一些数据展示方法(由Alam提出的可选需求)也被期待由本系统提供。

1.2 定位

由于是针对农业物联网设计的小型科研项目,项目的目标是对农业物联网的可行性进行探究,愿景是模拟最普遍的小型农业物联网应用场景。因此本架构的定位是适用于大部分具备感知,控制和展示功能的小型农业物联网工程

2 名词解释

  • MQTT: MQTT消息队列遥测传输(Message Queuing Telemetry Transport)是ISO 标准(ISO/IEC PRF 20922)下基于发布/订阅范式的消息协议。它工作在 TCP/IP协议族上,是为硬件性能低下的远程设备以及网络状况糟糕的情况下而设计的发布/订阅型消息协议[1]。
  • LoRa: LoRa是当前市场上的一种新兴技术,其在1 GHz以下的公共频段中运行,用于远距离低功耗通信[2]。

3 设计目标

3.1 实现功能

本架构功能性需求主要包括土地数据采集,气象数据采集,灌溉系统控制,与无人机小组系统进行交互,网页控制台(可查看实时和历史传感数据,指标数据;能够控制系统)。

3.2 性能指标

  • 通信范围(测试):半径不低于1km
  • 通信范围(生产):半径不低于3km
  • 延时:平均小于1s
  • 超时率:不超过5%
  • 资源占用:节点RAM不超过2k
  • 运行周期:1分 (测试) | 15分 (生产)

4 系统环境

4.1 相关软件及硬件

!!!

节点名称 硬件设施 软件集群
土地节点
Ground Nodes
Arduino Nano Arduino.h
SX1278 LORA模块 SPI.h
LM35DZ 温度传感 LoRa.h
土壤湿度传感 LoRa-Socket.h
四分电磁阀 LoRa-mqtt.h
vector.h
气象站节点
Air Station
Arduino Nano Arduino.h
SX1278 LORA模块 SPI.h
BME280 温度,湿度,大气压强传感 LoRa.h
GY-30 光强传感 LoRa-Socket.h
MQ-135 空气质量传感 LoRa-mqtt.h
MQ-7 一氧化碳传感 vector.h
雨量传感
LoRa 网关
LoRa Gateway
SX1278 Arduino.h
SPI.h
WiFi.h
LoRa.h
LoRa-Socket.h
LoRa-mqtt.h
vector.h
PubSubClient.h
内网控制器/MQTT代理
Controler/MQTT Proxy
树莓派3B - RASPBIAN Python3.7
直流变频水泵 NodeJS
sf-mqtt-proxy@npm
sf-pump@npm
forever@npm
云服务器
Cloud Server
华为云主机 - Centos7.4 Nginx/1.12.2
NodeJS/12.4.0
Redis/3.2.12
sf-mqtt-broker@npm
sf-web-api@npm
forever@npm
数据库
Database
华为云数据库 MySQL 5.7.23
!!!

4.2 数据规模预估

按照生产场景预估,每15分钟产生一组数据集合,一组数据集合约占用253-291字节。按照291计算,每天将新增27.93KB数据。

5 设计思路

5.1 理念

  • 面向文档
  • 面向接口
  • 面向测试

5.2 关键问题

  • 土地节点RAM资源稀缺,只有2K
  • LoRa通信采用433MHz,单信道收发,干扰多
  • 服务器需要采集聚合来自多节点的散列数据
  • 预留与无人机AI小组的交互方法
  • 实时消息向前端浏览器推送

5.3 方案选择

为了优先确保通信以及服务的稳定性可拓展性,我们选取分层模型作为架构的设计模式。整个系统分成多个层级,层级之间具备必要的交互行为。每个层级都独立运行,崩溃时会迅速重启,具备高度的可靠性。

安全上,采取内外网隔离的方法。内网中考虑到部分设备计算资源稀缺,与内网服务器的交互采用不加密的通信模式。内网服务器通过SSL加密的方式与云服务器进行交互。为了确保客户端的资料安全,云服务器API只接受具备SSL加密的HTTP和WebSocket请求。

6 架构设计

6.1 基础介绍

本架构的主要目的是提供一个稳定(Available)可靠(Reliable)的物联网系统,通过采集农田中的实时数据,结合通过无人机采集的图片以及CNN判断的植物健康情况,实现对灌溉系统以及植物健康状况的智能管理。本架构理论上适用于大部分农场环境。测试环境半径2~5km(取决于天线)以内,风力3级以下。本系统通过传感器获取农田数据,通过晶体管电路,继电器等控制灌溉系统,通过网页与API与管理者进行交互。

6.2 系统层级图

Smart Farm 系统分层结构图

此图展示了此架构的抽象层级结构。正如其所指出的,此分层架构可明确为感知层网络层应用层三个横向操作层以及一个纵向错误处理层

其中,感知层又可细化为环境层以及硬件层。环境层中包含植物,土壤,空气,水流等我们要检测和控制的自然物体,硬件层通过传感器、控制器等人造电气设备为系统对自然要素的交互行为(检测,控制)提供了底层技术可行性。当感知层实现对自然信息的交互后,相应的数字信息被传往网络层进行通信。相应的,感知层也会从网络层接受相应的控制信息,并根据这些指令做出相应的控制行为。

网络层分为三层。其中最低一层为预处理层,它的主要任务是对感知层采集的数据进行打包处理,转变成网络流通所适合的形式,如套接字。因此,预处理层需要少量的计算存储资源,比如单片机,EEPROM等。经过预处理层的封装后,数据被传往物理层。基于物理层中的网关、路由器等设备,这些数据包得以被有秩序的分发和传递。通信层中的MQTT协议的应用,使得这些数据包分发的管理更加高效与便利。此外,通信层中QoS服务质量检测体系的实施也使得网络层的性能更加的容错和可靠。

应用层主要负责一些应用层面的服务于业务逻辑,比如数据分析,事件处理等。在应用层的最底端,服务层在长期的运转着。服务层是应用层中最近接网络层的部分,它的主要目的是实时处理从网络层传入的数据,并对相应的请求及错误事件进行快速响应。同时,服务层也负责将传感器采集的数据进行整理分析并传递到数据库层进行存储。为了保证服务的可靠性,服务层的实现程序被注册为系统服务并由专门的守护进程进行守护。与服务层的长期运行不同,业务层则是按需唤起。当界面层有新的请求传入或服务层发生特定的事件时,业务层将会被调用并处理它们。除了一些基础的数据分析外,业务层也有权限向AI层进行分析请求。AI层通过分析从无人机传回的图像数据后,会传回一个判断结果给业务层。根据请求的具体内容,业务层会将图像识别结果,历史传感器数据等进行整理,并传递到界面层。界面层则主要用来提供不同形式的接口,比如HTTP接口和WebSocket接口,以方便客户端调用。

6.3 系统拓扑图

Smart Farm 系统拓扑图

从拓扑结构来看,如上图所示,整个系统物理上可划分为土地节点,气象节点,LoRa网关,内网服务器,云服务器,数据库和用户终端。

从功能机制上看,整个系统包含:传感器模块,LoRa通信模块,LoRa网关模块,MQTT-Proxy代理模块,水泵控制模块,MQTT+数据处理模块,web接口模块,守护进程模块和数据库模块。

土地节点
土地节点部署于不同区域的农田中,用于探测土壤温度,湿度参数,并能够提供对相应位置水流电磁阀的控制。土地节点使用Arduino Nano作为计算单元,使用LoRa作为通信方式连接LoRa网关(和其它节点),使用电池供电。其数量较多,工作环境恶劣,无线通信不稳定,是系统中最大的不确定性来源。

气象节点
气象节点部署于农田特定位置,用于探测空气温度,湿度,大气压,降雨量,光照,NH3浓度,CO浓度等气象参数。气象节点使用Arduino Nano作为计算单元,使用LoRa作为通信方式连接LoRa网关(和土地节点),使用电池或有线供电。其工作环境较为恶劣,无线通信质量一般。

LoRa网关
LoRa网关部署于室内,为扩大有效通信半径,其天线可延伸至室外。LoRa网关通过LoRa连接各土地节点和气象节点,通过WiFi连接内网服务器。LoRa网关能够将通过LoRa传入的socket包转换为mqtt消息并传递给内网服务器,以及将内网服务器传来的mqtt消息转换为socket包通过LoRa发送至指定节点。

内网服务器
内网服务器是一个树莓派3B,它包含三个功能模块:MQTT-Proxy代理模块,水泵控制模块以及守护进程模块。

MQTT-Proxy代理模块能够接收由LoRa网关通过WiFi发送的mqtt消息,对其进行SSL加密并转发至云服务器。同时,MQTT-Proxy代理模块也将接受指定的来自云服务器的mqtt消息,将其解密并转发至LoRa网关。

水泵控制模块通过树莓派的GPIO通过继电器控制水泵的状态。与水泵控制模块直接与云服务器进行mqtt通信,不经过MQTT-Proxy代理。

守护进程模块运行在Linux上,用于监视MQTT-Proxy代理模块和水泵控制模块。当探测到模块停止运行时,守护进程模块会及时重启这些模块,以确保服务的稳定性和连续性。

云服务器
云服务器运行在位于北京的华为云上,包含MQTT+数据处理模块,web接口模块和守护进程模块。

MQTT+数据处理模块包含了层级结构中的Service层和Business层。这个模块通过mqtt与内网进行通信,通过mqtt, redis与web接口模块(和AI模块)进行交互。当收到来自内网的各种散列的数据后,本模块会自动对它们进行聚合,整理成一条一条的数据,存入数据库,并通过redis推送给web接口模块。此外,本模块会定时向各节点发送请求以获取它们的数据,这些请求将被追踪以计算延时。

web接口模块提供一系列的HTTP和WebSocket接口。这些接口可用于获取数据,发送指令,刷新数据以及获取推送消息。

守护进程模块运行在Linux上,用于监视MQTT+数据处理模块和web接口模块。当探测到模块停止运行时,守护进程模块会及时重启这些模块,以确保服务的稳定性和连续性。

7 模块说明

7.1 LoRa通信模块

LoRa通信模块用于在单信道情况下实现稳定可靠的socket通信。本模块包含LoRa-socket和LoRa-mqtt。

LoRa-socket是在LoRa-Arduino的基础上进行了数据包的封装,实现了简单的udp和tcp通信,让传统的LoRa通信更加可靠。通过在数据包的head添加收发ip地址,以及在数据包的最后添加hash校验值,LoRa-socket支持点对点通信和广播通信,并且具有强大的噪音处理能力和数据防篡改能力。
项目地址iotcat/LoRa-socket

LoRa-mqtt是在LoRa-socket基础上对mqtt协议进行的一个简单再现。基于udp和tcp,LoRa-mqtt支持qos为0和1的mqtt通信。
项目地址iotcat/LoRa-mqtt

7.2 MQTT-Proxy代理模块

本模块运行在内网服务器,实现了对内网mqtt的加密转发。
项目地址iotcat/sf-mqtt-proxy

7.3 水泵控制模块

本模块运行在内网服务器,实现了通过GPIO对继电器水泵的控制。
项目地址iotcat/sf-pump

7.4 mqtt+数据处理模块

本模块运行在云服务器,实现了对来自底层mqtt消息的数据聚合,处理和存储。
项目地址iotcat/sf-mqtt-broker

7.5 web接口模块

本模块运行在云服务器,实现了功能性接口的提供。
项目地址iotcat/sf-web-api

8 开发文档

8.1 mqtt主题

8.2 http接口

8.3 websocket接口

9 运行状态

9.1 系统延时

qos

上图展示了土地节点(左),气象节点(右),水泵(下)的延时统计折线图。由图可以看出,土地节点的平均延时在730ms左右,气象节点延时在900ms左右,水泵的延时较低,在45ms左右。

9.2 传感器数据

点击这里查看2019-7-31的气象传感器数据


Reference List:

[1] OASIS, (2015,12.10). MQTT Version 3.1.1 Plus Errata 01 [Online]. Available: https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/errata01/os/mqtt-v3.1.1-errata01-os-complete.html

[2] Sinha, R.S., Wei, Y. and Hwang, S.H., “A survey on LPWA technology: LoRa and NB-IoT”, in Ict Express, 3(1), pp.14-21, 2017.

1 Background

1.1 Requirements

In order to explore the feasibility of agricultural Internet of Things technology, instructor Alam Mohammed hopes that we can provide a Available and Reliable Internet of Things system to realize intelligent monitoring and management of farmland. This system will be able to timely detect the parameters related to plant health in the soil and the air, process and store these data (proposed by Alam). At the same time, the automatic control irrigation function (proposed by Caleb) and some data display methods (optional requirements proposed by Alam) are also expected to be provided by this system.

1.2 Positioning

As it is a small scientific research project designed for the agricultural Internet of Things, the goal of the project is to explore the feasibility of the agricultural Internet of Things, and the vision is to simulate the most common small-scale agricultural Internet of Things application scenarios. Therefore, the positioning of this architecture is ** applicable to most small agricultural IoT projects with sensing, control and display functions**.

2 Glossary

  • MQTT: MQTT Message Queuing Telemetry Transport is a message protocol based on the publish/subscribe paradigm under the ISO standard (ISO/IEC PRF 20922). It works on the TCP/IP protocol suite and is a publish/subscribe message protocol designed for remote devices with low hardware performance and poor network conditions [1].
  • LoRa: LoRa is an emerging technology in the current market, which operates in the public frequency band below 1 GHz for long-distance low-power communication [2].

3 Design goals

3.1 Implementing functions

The functional requirements of this architecture mainly include land data collection, weather data collection, irrigation system control, interaction with the drone group system, web console (can view real-time and historical sensor data, index data; be able to control the system).

3.2 Performance indicators

  • Communication range (test): the radius is not less than 1km
  • Communication range (production): the radius is not less than 3km
  • Delay: average less than 1s
  • Timeout rate: no more than 5%
  • Resource occupation: Node RAM does not exceed 2k
  • Run cycle: 1 minute (test) | 15 minutes (production)

4 System Environment

!!!

Node name Hardware facilities Software cluster
Ground Nodes
Ground Nodes
Arduino Nano Arduino.h
SX1278 LORA module SPI.h
LM35DZ temperature sensor LoRa.h
土壤湿度传感 LoRa-Socket.h
Four-point solenoid valve td> LoRa-mqtt.h
vector.h
weather station node
Air Station
Arduino Nano Arduino.h
SX1278 LORA module SPI.h
BME280 温度,湿度,大气压强传感 LoRa.h
GY-30 light intensity sensor LoRa-Socket.h
MQ-135 air quality sensor LoRa-mqtt.h
MQ-7 carbon monoxide sensor< /a> vector.h
rainfall sensor
LoRa Gateway
LoRa Gateway
SX1278 Arduino.h
SPI.h
WiFi.h
LoRa.h
LoRa-Socket.h
LoRa-mqtt.h
vector.h
PubSubClient.h
Intranet Controller/MQTT Proxy
Controler/MQTT Proxy
Raspberry Pi 3B-RASPBIAN Python3.7
DC frequency conversion water pump NodeJS
sf-mqtt-proxy@npm
sf-pump@npm
forever@npm
Cloud Server
Cloud Server
Huawei Cloud Host-Centos7.4 Nginx/1.12.2
NodeJS/12.4.0
Redis/3.2.12
sf-mqtt-broker@npm
sf-web-api@npm
forever@npm
Database
Database
Huawei Cloud Database MySQL 5.7.23
!!!

4.2 Data size estimation

According to the production scenario, a data set is generated every 15 minutes, and a data set occupies about 253-291 bytes. According to 291 calculation, 27.93KB of data will be added every day.

5 Design Ideas

5.1 Idea

  • Document-oriented
  • Interface-oriented
  • Test-oriented

5.2 Key Issues

  • Land node RAM resources are scarce, only 2K
  • LoRa communication adopts 433MHz, single-channel transceiving, much interference
  • The server needs to collect and aggregate hash data from multiple nodes
  • Reserve a method of interaction with the drone AI team
  • Push real-time messages to the front-end browser

5.3 Scheme selection

In order to prioritize to ensure the stability and scalability of communication and services, we select layered model as the design mode of the architecture. The entire system is divided into multiple levels, with necessary interactions between levels. Each level runs independently, restarts quickly when it crashes, and has a high degree of reliability.

In terms of safety, the method of internal and external network isolation is adopted. Taking into account the scarcity of computing resources of some devices in the intranet, the interaction with the intranet server adopts an unencrypted communication mode. The intranet server interacts with the cloud server through SSL encryption. To ensure the security of the client’s data, the cloud server API only accepts HTTP and WebSocket requests with SSL encryption.

6 Architecture Design

6.1 Basic introduction

The main purpose of this architecture is to provide a stable (Available) and reliable Internet of Things system, which collects real-time data in farmland, combines pictures collected by drones and judged by CNN Plant health, realize intelligent management of irrigation system and plant health. This framework is theoretically suitable for most farm environments. The test environment is within a radius of 2~5km (depending on the antenna), and the wind is below level 3. This system acquires farmland data through sensors, controls the irrigation system through transistor circuits, relays, etc., and interacts with managers through web pages and APIs.

6.2 System hierarchy diagram

Smart Farm system hierarchical structure diagram

This figure shows the abstract hierarchy of this architecture. As pointed out, this layered architecture can be clearly defined as the perception layer, network layer, application layer, three horizontal operation layers, and a vertical error handling layer.

Among them, the perception layer can be further refined into environment layer and hardware layer. The environment layer contains plants, soil, air, water and other natural objects that we want to detect and control. The hardware layer provides the underlying technology for the system’s interactive behavior (detection, control) of natural elements through artificial electrical devices such as sensors and controllers. Sex. When the perception layer realizes the interaction of natural information, the corresponding digital information is transmitted to the network layer for communication. Correspondingly, the perception layer will also receive corresponding control information from the network layer, and make corresponding control actions according to these instructions.

Network layer is divided into three layers. The lowest layer is the preprocessing layer. Its main task is to package the data collected by the perception layer and transform it into a form suitable for network circulation, such as sockets. Therefore, the pre-processing layer requires a small amount of computing storage resources, such as a single-chip microcomputer, EEPROM, etc. After encapsulation by the preprocessing layer, the data is transmitted to the physical layer. Based on devices such as gateways and routers in the physical layer, these data packets can be distributed and transmitted in an orderly manner. The application of the MQTT protocol in the communication layer makes the management of these data packet distribution more efficient and convenient. In addition, the implementation of the QoS service quality detection system in the communication layer also makes the performance of the network layer more fault-tolerant and reliable.

Application layer is mainly responsible for some application-level services for business logic, such as data analysis, event processing, etc. At the bottom of the application layer, the service layer is running for a long time. The service layer is the closest part of the application layer to the network layer. Its main purpose is to process the incoming data from the network layer in real time and respond quickly to corresponding requests and error events. At the same time, the service layer is also responsible for sorting and analyzing the data collected by the sensors and passing it to the database layer for storage. In order to ensure the reliability of the service, the implementation program of the service layer is registered as a system service and guarded by a special daemon. Unlike the long-term operation of the service layer, the business layer is invoked on demand. When a new request comes in from the interface layer or a specific event occurs in the service layer, the business layer will be called and processed. In addition to some basic data analysis, the business layer also has the authority to make analysis requests to the AI ​​layer. AI layer After analyzing the image data returned from the drone, it will send back a judgment result to the business layer. According to the specific content of the request, the business layer will organize the image recognition results, historical sensor data, etc., and pass them to the interface layer. Interface layer is mainly used to provide different forms of interfaces, such as HTTP interface and WebSocket interface, to facilitate client calls.

6.3 System Topology Diagram

Smart Farm system topology diagram

From the topological structure, as shown in the figure above, the entire system can be physically divided into land nodes, weather nodes, LoRa gateways, intranet servers, cloud servers, databases and user terminals.

From the perspective of functional mechanism, the entire system includes: sensor module, LoRa communication module, LoRa gateway module, MQTT-Proxy proxy module, water pump control module, MQTT+ data processing module, web interface module, daemon module and database module.

Land Node
Land nodes are deployed in farmland in different regions to detect soil temperature and humidity parameters, and can provide control of water flow solenoid valves at corresponding locations. The land node uses Arduino Nano as the computing unit, uses LoRa as the communication method to connect to the LoRa gateway (and other nodes), and uses battery power. Its large number, harsh working environment and unstable wireless communication are the biggest source of uncertainty in the system.

Weather Node
Meteorological nodes are deployed at specific locations in farmland to detect meteorological parameters such as air temperature, humidity, atmospheric pressure, rainfall, light, NH3 concentration, and CO concentration. The weather node uses Arduino Nano as the computing unit, uses LoRa as the communication method to connect to the LoRa gateway (and the land node), and uses battery or wired power. The working environment is harsh and the wireless communication quality is average.

LoRa Gateway
The LoRa gateway is deployed indoors. In order to expand the effective communication radius, its antenna can be extended outdoors. The LoRa gateway connects to various land nodes and weather nodes through LoRa, and connects to the intranet server through WiFi. The LoRa gateway can convert the socket packet incoming through LoRa into an mqtt message and pass it to the intranet server, and convert the mqtt message from the intranet server into a socket packet and send it to the designated node through LoRa.

Intranet server
The intranet server is a Raspberry Pi 3B, which contains three functional modules: MQTT-Proxy proxy module, water pump control module and daemon process module.

MQTT-Proxy proxy module can receive the mqtt message sent by the LoRa gateway via WiFi, encrypt it with SSL and forward it to the cloud server. At the same time, the MQTT-Proxy proxy module will also accept the specified mqtt message from the cloud server, decrypt it and forward it to the LoRa gateway.

Water pump control module The state of the water pump is controlled through a relay through the GPIO of the Raspberry Pi. The mqtt communication with the water pump control module directly communicates with the cloud server without passing through the MQTT-Proxy proxy.

Daemon module runs on Linux and is used to monitor the MQTT-Proxy proxy module and the water pump control module. When modules are detected to stop running, the daemon module will restart these modules in time to ensure the stability and continuity of services.

Cloud Server
The cloud server runs on Huawei Cloud located in Beijing and includes MQTT+ data processing module, web interface module and daemon module.

MQTT+data processing module includes the Service layer and the Business layer in the hierarchical structure. This module communicates with the intranet through mqtt, and interacts with the web interface module (and AI module) through mqtt and redis. After receiving various hashed data from the intranet, this module will automatically aggregate them, organize them into one piece of data, store it in the database, and push it to the web interface module through redis. In addition, this module will periodically send requests to each node to obtain their data, and these requests will be tracked to calculate the delay.

web interface module provides a series of HTTP and WebSocket interfaces. These interfaces can be used to get data, send instructions, refresh data, and get push messages.

Daemon module runs on Linux and is used to monitor MQTT+ data processing module and web interface module. When modules are detected to stop running, the daemon module will restart these modules in time to ensure the stability and continuity of services.

7 Module description

7.1 LoRa communication module

The LoRa communication module is used to realize stable and reliable socket communication in a single channel. This module includes LoRa-socket and LoRa-mqtt.

LoRa-socket encapsulates data packets on the basis of LoRa-Arduino, realizes simple udp and tcp communication, and makes traditional LoRa communication more reliable. By adding the sending and receiving ip address to the head of the data packet, and adding the hash check value at the end of the data packet, LoRa-socket supports point-to-point communication and broadcast communication, and has powerful noise processing capabilities and data tamper resistance.
Project address: iotcat/LoRa-socket

LoRa-mqtt is a simple reproduction of the mqtt protocol based on LoRa-socket. Based on udp and tcp, LoRa-mqtt supports mqtt communication with qos 0 and 1.
Project address: iotcat/LoRa-mqtt

7.2 MQTT-Proxy proxy module

This module runs on the intranet server and realizes the encrypted forwarding of the intranet mqtt.
Project address: iotcat/sf-mqtt-proxy

7.3 Water pump control module

This module runs on the intranet server and realizes the control of the relay water pump through GPIO.
Project address: iotcat/sf-pump

7.4 mqtt+data processing module

This module runs on the cloud server and realizes the data aggregation, processing and storage of the underlying mqtt messages.
Project address: iotcat/sf-mqtt-broker

7.5 web interface module

This module runs on the cloud server and realizes the provision of functional interfaces.
Project address: iotcat/sf-web-api

8 Development Document

8.1 mqtt theme

8.2 http interface

8.3 websocket interface

9 Running status

9.1 System delay

qos

The figure above shows the line graphs of the delay statistics of the land node (left), the weather node (right), and the water pump (bottom). It can be seen from the figure that the average delay of the land node is about 730ms, the delay of the weather node is about 900ms, and the delay of the water pump is relatively low, about 45ms.

9.2 Sensor data

Click here to view the weather sensor data of 2019-7-31


Reference List:

[1] OASIS, (2015,12.10). MQTT Version 3.1.1 Plus Errata 01 [Online]. Available: https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/errata01/os/mqtt -v3.1.1-errata01-os-complete.html

[2] Sinha, R.S., Wei, Y. and Hwang, S.H., “A survey on LPWA technology: LoRa and NB-IoT”, in Ict Express, 3(1), pp.14-21, 2017.

]]>
tech Arduino iot LoRa MQTT smart-farming
Arduino中[]=重载导致的String调用问题 /tech/arduino-operator-string-issue.html

最近在物联网开发中使用Arduino搭建LoRa网关和节点,发现在调用String时总遇到一些奇奇怪怪的现象。经过排查,发现是由于其它地方[]=运算符的重载所导致。

Recently, I have used Arduino to build LoRa gateways and nodes in the development of the Internet of Things, and I found that some strange phenomena are always encountered when calling String. After investigation, it was found that it was caused by overloading of the []= operator elsewhere.

为了方便,在开发节点时,我们使用了LoRa-SocketArduinoJSON作为依赖。我们发现这两个依赖分别使用时表现良好,但如果在同一个项目文件中使用,则会导致一些怪异的问题。

情况一

通过指针调用函数时String参数传递异常。代码如下:

1
2
3
inline static void _onReceived(const String& msg, const String& from, const String& to, const String& type){
(*_f)(msg, from, to, type);
};

在这个案例中,我们发现msg等String在此函数中的数值是一切正常的,可是却没有能够成功传递到_f中。经过一系列骚操作,我们得出如下结论:

  • 发现如果将String换成int或其它类型,则参数传递至_f一切正常。有问题的只有String和char类型。
  • 我们尝试过将String转换为其它类型,再转回,但是没有效果。
  • String或char类型全局变量的声明会使单片机崩溃。
  • 当我们将ArduinoJSON依赖删去,String参数的传递则一切正常。

我们从而可以得出,这种怪异现象是由于与ArduinoJSON包的冲突所致。

情况二

在使用ArduinoVector制作String类型Vector时,我们也发现了String类型的不稳定现象。神奇的是,这种现象只出现在String的使用中,其它如int类型运作良好。

这些不稳定现象可以总结如下:

  • 赋值时被截断
  • String值局部乱序
  • String值部分乱码
  • 作为参数传给函数时会失败,读取出来是空(与案例一类似)

综述

通过上述两个案例,我们可以初步总结出,这是由于[]=赋值运算符的重载与String有冲突。只要使用[]=重新定义String,即有可能出现String怪异的问题。

For convenience, we used LoRa-Socket and ArduinoJSON as dependencies when developing nodes. We found that these two dependencies perform well when used separately, but if used in the same project file, it will cause some weird problems.

Situation One

When calling a function through a pointer, the String parameter passing is abnormal. code show as below:

1
2
3
inline static void _onReceived(const String& msg, const String& from, const String& to, const String& type){
(*_f)(msg, from, to, type);
};

In this case, we found that the value of msg and other String in this function is all normal, but it was not successfully passed to _f. After a series of Sao operations, we come to the following conclusions:

  • Found that if you change String to int or other types, the parameters passed to _f are all normal. Only the String and char types are problematic.
  • We tried to convert String to other types, and then back, but to no avail.
  • The declaration of global variables of type String or char will crash the microcontroller.
  • When we delete the ArduinoJSON dependency, the passing of String parameters is normal.

We can conclude that this strange phenomenon is caused by the conflict with the ArduinoJSON package.

Situation Two

When using ArduinoVector to make a String type Vector, we also discovered the instability of the String type. The magic is that this phenomenon only occurs in the use of String, other types such as int work well.

These instabilities can be summarized as follows:

  • Truncated during assignment
  • String values ​​are locally out of order
  • Part of the String value is garbled
  • It will fail when passed as a parameter to the function, and it will be empty (similar to case 1)

Summary

Through the above two cases, we can preliminarily conclude that this is due to the conflict between the overload of the []= assignment operator and String. As long as you use []= to redefine String, string weird problems may occur.

]]>
tech Arduino cpp
随机图片API /tech/rand-pic-api.html

本API基于华为云对象存储,使用华为CDN云加速,全球平均下载速度达10MB/s。API中已收录1100+张二次元图片,20+张Bing壁纸(每日自动抓取),150+张二次元头像,10+张图床上传图片。

This API is based on Huawei Cloud Object Storage and uses Huawei CDN Cloud acceleration. The global average download speed is 10MB/s. The API has included 1100+ two-dimensional pictures, 20+ Bing wallpapers (automatically captured daily), 150+ two-dimensional avatars, and 10+ pictures uploaded on the bed.

本API不承诺永久维护,使用前请务必斟酌使用风险!!

1 API地址

  • https://api.yimian.xyz/img

2 快速入门

随机二次元图片

随机Bing壁纸

随机二次元头像

随机图床图片

随机1920x1080尺寸二次元图片

3 参数列表

名称描述格式示例
type图片种类moe/wallpaper/head/imgbedtype=moe
size根据图片大小筛选??x??;
*x??;
*x*;
??-??x??;
??-??x??-??;
??-??x*
display=1920x1080;
display=1920x*;
display=1920-1950x230-500;
display=1920-1950x*;
range尺寸误差范围numberrange=100
id根据图片id筛选numberid=15
path根据路径提取图片abs pathpath=wallpaper/img_··mal.jpg
display是否以网页格式展示true/false(default)display=true
R18是否显示18禁图片true/false(default)R18=true

4 参数详解

4.1 type

二次元(默认)

bing每日壁纸

二次元头像

呓喵酱图床

こいぬちゃん

EasyVer人机验证

4.2 display

如果本参数置为true,则会禁用302跳转,直接返回完整图片编码。本方法效率极低,速度很慢,请慎用。

false(默认)

true

4.3 size

使用本参数限制图片尺寸。本参数支持以下格式:

??x??

??x*

\x??*

\x**

??-??x??

??x??-??

??-??x??-??

??-??x*

\x??-??*

4.4 range

本参数规定允许的size的误差,需搭配size使用,默认为0。

对于??型size参数

对于??-??型size参数

对于*型size参数

  • GET/POST /img?size=*x*&range=100
  • 描述: range无效

4.5 id

每一个种类都有自己的id系统,同一种类下不同图片id唯一。

二次元

bing每日壁纸

二次元头像

呓喵酱图床

4.6 path

使用绝对路径直接提取图片,优先级高于type,效率最高

4.7 R18

是否显示18禁图片,默认为false。

5 报错格式

5.1 找不到指定type类型

若找不到指定的type类型,将会自动返回一个moe类型的图片。

5.2 找不到符合条件的图片

返回JSON

1
2
3
{
"err": "错误信息"
}

每台设备每天全局调用上限500次!!

This API does not promise permanent maintenance, please be sure to consider use risks before use! !

1 API address

  • https://api.yimian.xyz/img

2 Quick start

Random two-dimensional picture

Random Bing Wallpaper

Random two-dimensional avatar

Random bed pictures

Random 1920x1080 size two-dimensional picture

3 Parameter list

NameDescriptionFormatExample
typeImage typemoe/wallpaper/head/imgbedtype=moe
sizeFilter by image size??x??;
*x??;
*x*;
??-??x??;
??-??x??-??;
??-??x*
display=1920x1080;
display=1920x*;
display=1920-1950x230-500;
display=1920-1950x*;
rangeSize error rangenumberrange=100
idFilter by image idnumberid=15
pathExtract pictures based on pathabs pathpath=wallpaper/img_··mal.jpg
displayWhether to display in web page formattrue/false(default)display=true
R18Whether to display 18 prohibited picturestrue/false(default)R18=true

4 Detailed parameters

4.1 type

Two-dimensional (default)

bing daily wallpaper

Two-dimensional avatar

Miao meow sauce picture bed

こいぬちゃん

EasyVer man-machine verification

4.2 display

If this parameter is set to true, 302 jump will be disabled and the complete picture encoding will be returned directly. This method is very low and slow. Please use it carefully.

false (default)

true

4.3 size

Use this parameter to limit the image size. This parameter supports the following formats:

??x??

??x*

\x??*

\x**

??-??x??

??x??-??

??-??x??-??

??-??x*

\x??-??*

4.4 range

This parameter specifies the allowable size error, which needs to be used with size, and the default is 0.

For the?? type size parameter

For??-?? type size parameter

For *type size parameter

  • GET/POST /img?size=*x*&range=100
  • Description: Invalid range

4.5 id

Each category has its own id system, and different image ids under the same category are unique.

*Two-dimensional *

bing daily wallpaper

Two-dimensional avatar

Miao meow sauce picture bed

4.6 path

Use absolute path to directly extract pictures, priority is higher than type, highest efficiency.

4.7 R18

Whether to display 18 prohibited pictures, the default is false.

5 Error format

5.1 Cannot find the specified type

If the specified type cannot be found, a moe type picture will be automatically returned.

5.2 Can’t find matching images

Return JSON

1
2
3
{
"err": "error message"
}

The maximum number of global calls for each device is 500 per day!!

]]>
tech api img random moe
wIoT - 轻松物联 /tech/wiot.html

基于NodeJS搭建的物联网系统,配合D1 MINI单片机,帮助你灰常快速实现物联~

The Internet of Things system based on NodeJS, combined with D1 MINI microcontroller, helps you quickly realize the Internet of Things~

正式开发文档见这里

wIoT for NodeJS

适用于NodeJS的wIoT服务器控制组件,轻松物联

项目简介

立项初衷

本项目旨在帮助不熟悉固件编程的网络开发者实现出自己的物联网应用。您仅需要一台网络内部的服务器(比如树莓派),以及若干个支持可联网(通过串口,WiFi,LoRa,蓝牙,Zigbee等)的单片机,即可轻松创建并管理属于您自己的物联网集群。

支持功能

  • ota (隔空自动更新固件)
  • 自动扫描网络内单片机
  • 通过wifi连接设置
  • 使用socket/HTTP通信

todo List

  • 支持python界面
  • 开发web面板,图像化管理
  • 支持更多单片机,比如esp8266等
  • 开发nodeJS wiot-cli 命令行程序
  • 支持nodeJS自动烧写固件,并自动配置(很重要)

使用方法

先觉条件

  • 拥有烧录好wIoT固件D1 MINI单片机
  • 一台或多台无线WiFi路由器2.4G/5G
  • 局域网内拥有一台装有NodeJS的服务器或电脑 (NodeJS装法非常简单, 请自行Google或百度)
  • 配置好npm

快速开始

单片机接入

  1. 使用MicroUSB, 5V, 或3V pin脚给单片机供电
  2. 用一根导线连接D0脚与3V3脚,持续一秒以上拔出,以重置单片机
  3. 用手机或电脑搜索它的WiFi热点,名称格式wiot-xx:xx:xx:xx:xx:xx
  4. 连接上此热点,密码为1234567890
  5. 用浏览器打开网址http://192.168.0.1,记录网页中的MAC地址,这将用于识别此单片机
  6. 配置你无线路由器的ssid(即wifi名称,注意不能有非ASCII字符,比如汉字)和密码
  7. 配置完成后热点将自动断开,单片机将连接到你的无线路由器

依赖安装

在你的项目文件夹下打开命令行,输入以下指令安装wiot:

1
$ npm install wiot

使用方法

在你的项目文件夹中新建一个app.js文件,输入以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var wiot = require('wiot'); //引入wiot依赖包

// 新建一个单片机对象
// 这里使用了两个参数,MAC是单片机的MAC地址,pin中指定需要OUTPUT输出的端口
// 请自行修改MAC地址的值
var MyMCU = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx", pin: {D4: wiot.OUTPUT}});


// 以下代码将实现,板载led亮1秒,灭1秒的循环

// 等待所有单品即准备就绪
wiot.begin([MyMCU], ()=>{ // 第一个参数为要等待的单片机对象数组,第二个参数为要执行的函数
// 设置计时器,每隔2000毫秒, MyMCU的3号pin口将拉高一次电平
setInterval(()=>{
MyMCU.write(wiot.D4, wiot.HIGH);
}, 2000);

// 设置计时器,延时1000毫秒后开始执行大括号中指令
setTimeout(()=>{
// 设置计时器,每隔2000毫秒,MyMCU的3号pin口将拉低一次电平
setInterval(()=>{
MyMCU.write(wiot.D4, wiot.LOW);
}, 2000);
}, 1000);
});

开始执行

在项目文件夹中打开命令行,输入以下指令:

1
node app.js

预期结果

如果一切顺利,你现在应该会发现你的板载led在闪烁了

社区支持

也许你会觉得上述代码难以理解,这是正常的,由于delay功能在JS中难以实现。但是不用担心,这些问题将会由社区中的其它开发者帮你解决。

wIoT在实现基本的单片机控制同时,也提供了丰富的扩展功能。更神奇的是,任何人都可以在wIoT中编写自己的扩展并与全世界共享它们。在这里我们可以使用wIoT官方提供的led扩展轻松实现上例功能!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var wiot = require('wiot'); //引入wiot依赖包

// 新建一个单片机对象
var MyMCU = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx", pin: {D4: wiot.OUTPUT}});

// 新建一个led模块
var led = new wiot.led(MyMCU, wiot.D4);

// 以下代码将实现,板载led亮1秒,灭1秒的循环

// 等待所有单品即准备就绪
wiot.begin([MyMCU], ()=>{

// 调用led模块构建亮1秒灭1秒的动作
led.set([wiot.HIGH, wiot.LOW], [1000, 1000]);
});

进阶设置

wiot.client

参数说明

名称默认值描述
MAC“”单片机的MAC地址
pin{D1: 0, D2: 0, D3: 0, D4: 0, D5: 0, D6: 0, D7: 0, D8: 0}pin脚的模式, 0为INPUT, 1为OUTPUT, 2为INPUT_PULLUP
hinttrue是否显示状态提示
debugfalse是否开启debug模式
ip“default”指定单片机IP, 请在长时间搜索不到IP时尝试此选项
port8848Client的TCP Socket通信端口,默认8848
ip_range“192.168.0”IP搜索字段,请在长时间搜索不到IP时尝试此选项
localIP“127.0.0.1”本机IP
OnlyHTTPfalse是否仅使用HTTP模式连接单片机
errDelayTime2000遇到网络错误时重试间隔时间(毫秒)
okDelayTime30收到网络请求后延时等待时间(毫秒)
resetDelayTime4500向单片机发送重置指令后多久不再发送新消息(毫秒)
noTryMaxTime15000经过此时间单片机仍未响应则重新发送消息(毫秒)
IntervalTime2000监听行为心跳间隔
MaxToReScanTime180000经过此事件单片机无响应则从新扫描IP地址(毫秒)
MinResearchTime5000搜索IP经过一此轮询后间隔时间(毫秒)
IpScanTimeout1IP扫描时的Ping检测超时时间(秒)
pingTimeout2心跳Ping检测的超时时间(秒)
MaxTraceBackTimes8判断连接状态所向前追溯的历史心跳个数

例如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var MyMCU = new wiot.client({
MAC: "xx:xx:xx:xx:xx:xx",
pin: {
D1: 0,
D2: 0,
D3: 1,
D4: 1,
D5: 0,
D6: 1,
D7: 0,
D8: 0
},
hint: true,
debug: false,
ip: "192.168.0.55",
port: 6666,
ip_range: "192.168.0",
localIP: "127.0.0.1",
errDelayTime: 2000,
okDelayTime: 30,
resetDelayTime: 4500,
noTryMaxTime: 15000,
IntervalTime: 2000,
MaxToReScanTime: 180000,
MinResearchTime: 5000,
IpScanTimeOut: 1,
pingTimeout: 2,
MaxTraceBackTimes: 8
});

方法列表

  • .write(pin: wiot.pin/number, state: iot.state/number): 向指定pin口输出状态指令,状态可以是wiot.HIGH/wiot.LOW或PWM调制(0-255数字)
  • wiot.read(pin: wiot.pin/number): 读取指定pin口状态,数字pin返回wiot.HIGH/wiot.LOW,模拟pin返回0-1024数值

事件绑定

.on(event, handler)

client事件列表

  • begin 开始于单片机正常交互
  • disConnected 与单片机断开连接
  • reConnected 与单片机恢复连接
1
2
3
4
5
6
var MCU = new wiot.client({"MAC": "xx:xx:xx:xx:xx:xx"});

MCU.on('disConnected', function () {
// 当与MCU失联时会执行此处指令
console.log('Disconnected with MCU!!');
});

.pinOn(pin, event, handler)

pin事件列表

  • on pin口电位从低到高
  • off pin口电位从高到低
  • change pin口电位变化
1
2
3
4
5
6
var MCU = new wiot.client({"MAC": "xx:xx:xx:xx:xx:xx"});

MCU.pinOn(wiot.D2, 'on', function () {
// 当MCU的D2电位由低到高时会执行
console.log('D2 from LOW to HIGH!!');
});

API

  • wiot.begin(): 单片机准备完成后开始执行
1
2
3
4
5
6
7
MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx", pin: {D4: wiot.OUTPUT}});
MCU1 = new wiot.client({MAC: "xx:xx:xx:xx:xx:ww"});

wiot.begin([MCU0, MCU1], ()=>{
//这里放你要执行的指令
//这些指令将会在MCU0和MCU1准备就绪后开始执行
});
  • wiot.loop(): 循环执行的指令,适合于条件控制语句
1
2
3
4
5
6
7
8
9
10
11
12
13
MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx", pin: {D4: wiot.OUTPUT}});
MCU1 = new wiot.client({MAC: "xx:xx:xx:xx:xx:ww"});

// 以下代码将实现: 当MCU0的D5接收到HIGH,MCU1的D4将会输出HIGH
// 当MCU0的D5接收到LOW, MCU1的D4将会输出LOW
// 本函数接受两个参数: 第一个是MCU对象数组, 第二个是参数为MCU对象数组的函数
wiot.loop([MCU0, MCU1], () => {
if(MCU1.read(wiot.D5) == wiot.HIGH){
MCU0.write(wiot.D4, wiot.HIGH);
}else{
MCU0.write(wiot.D4, wiot.LOW);
}
});

注册表

  • wiot.register.set(status1, status2, function): 向注册表中添加一条规则, status可以是值或函数,当status1==status2时会触发function。
    注册表的设计是为了方便协调各扩展模块的使用,详见下文扩展模块
  • wiot.register.set(status, function): 你也可以传入两个函数,其中status的返回值是bool型,变为true时触发function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
var myLED = wiot.led(MyMCU, wiot.D4);
var pir = wiot.pir(MyMCU, wiot.D2);

//注册一条规则,当pir探测到人时,myLED亮
wiot.register.set(pir.getStatus, wiot.HIGH, ()=>{
myLED.set(wiot.HIGH);
});

//注册一条规则,当人离开时,myLED灭
wiot.register.set(()=>{
return (wiot.LOW == pir.getStatus);
}, ()=>{
myLED.clear();
});

传感器扩展模块

LED

  • wiot.led(MCU, pin): 声明一个led模块
  • wiot.led.getStatus(): 获取led状态
  • wiot.led.set(status, time = 0, isSmooth = false): 设置led状态,起始状态,中间状态,最终状态,周期
  • wiot.led.breath(period): 设置一个呼吸灯
  • wiot.led.clear(): 重置led
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx", pin: {D4: wiot.OUTPUT}});

var myLED = wiot.led(MCU0, wiot.D4); //新建一个led对象,使用MCU0上的D4口

/* 如果myLED不亮,则点亮它 */
if(!myLED.getStatus()){
myLED.set(wiot.HIGH);
}

/* 设置一个周期为2秒的呼吸灯 */
myLED.breath(2000);

/* 设置一个亮三秒,灭四秒的led */
myLED.set([wiot.HIGH, wiot.LOW], [3000, 4000]);

/* 设置一个呼1秒吸3秒的呼吸渐变灯 */
myLED.set([wiot.LOW, wiot.HIGH], [1000, 3000], true);

/* 自定义一个先半亮2秒再全亮3秒再熄灭2秒的led灯 */
myLED.set([100, wiot.HIGH, wiot.LOW], [2000, 3000, 2000]);

/* 熄灭led */
myLED.clear();

PIR 红外人体传感器

  • wiot.pir(MCU, pin): 声明一个PIR模块
  • wiot.pir.getStatus(): 获取PIR状态,返回值wiot.HIGH(有人),wiot.LOW(无人)

事件触发器

  • wiot.pir.on(event, handler)

事件列表

  • detected 探测到人
  • undetected 人体移动出探测范围
  • change 状态改变,包括有人到无人和无人到有人
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx"});

var myPIR = wiot.pir(MCU0, wiot.D2); //新建一个pir对象,使用MCU0上的D2口

/* 输出pir状态到控制台 */
console.log(myPIR.getStatus());

/* 当探测到人,打印 "Detected People!" 到控制台 */
myPIR.on("detected", ()=>{
console.log("Detected People!");
});

/* 人移动出探测范围,打印 "No People!!" 到控制台 */
myPIR.on("undetected", ()=>{
console.log("No People!!");
});

/* 当状态改变,执行指令 */
myPIR.on("change", ()=>{
/* 你的指令 */
});

IR 红外循迹/障碍传感器

  • wiot.ir(MCU, pin): 声明一个IR模块,pin可以是模拟或数字端口
  • wiot.ir.getStatus(): 获取IR状态,返回值wiot.HIGH(有障碍),wiot.LOW(无障碍),或者0-1024数值(限模拟端口)

事件触发器

  • wiot.ir.on(event, handler)

事件列表

  • detected 探测到障碍
  • undetected 障碍消失
  • change 状态改变
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx"});

var myIR = wiot.ir(MCU0, wiot.D2); //新建一个ir对象,使用MCU0上的D2口

/* 输出ir状态到控制台 */
console.log(myIR.getStatus());

/* 当探测到物体,打印 "Detected Object!" 到控制台 */
myIR.on("detected", ()=>{
console.log("Detected Object!");
});

/* 物体移动出探测范围,打印 "No Object!!" 到控制台 */
myIR.on("undetected", ()=>{
console.log("No Object!!");
});

/* 当状态改变,执行指令 */
myIR.on("change", ()=>{
/* 你的指令 */
});

lightSensor 光敏传感器

  • wiot.lightSensor(MCU, pin): 声明一个lightSensor模块, pin可以是模拟或数字端口
  • wiot.lightSensor.getStatus(): 获取lightSensor状态,返回值wiot.HIGH(有光),wiot.LOW(无光),或者0-1024数值(限模拟端口)

事件触发器

  • wiot.light.on(event, handler)

事件列表

  • light 由暗到明
  • dark 由明到暗
  • change 状态改变
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx"});

var myLightSensor = wiot.lightSensor(MCU0, wiot.D1); //新建一个pir对象,使用MCU0上的D2口

/* 输出LightSensor状态到控制台 */
console.log(mylightSensor.getStatus());

/* 当由暗到明,打印 "Light!!!" 到控制台 */
myLightSensor.on("light", ()=>{
console.log("Light!");
});

/* 由明到暗,打印 "Dark!!" 到控制台 */
myLightSensor.on("dark", ()=>{
console.log("Dark!!");
});

/* 当状态改变,执行指令 */
myLightSensor.on("change", ()=>{
/* 你的指令 */
});

网络扩展模块

mail 邮件模块

使用本模块向指定邮箱发送邮件。自豪地引用Yimian API构建!

  • wiot.mail(to, from = "wIoT"): 声明一个mail模块,参数收件地址,发件人名称
  • wiot.mail.send(subject, body): 发送邮件,需传入主题,邮件内容
1
2
3
var mail = wiot.mail("i@iotcat.me", "wIoT Test");

mail.send("Test", "Test from wiot!!");

guguji 咕咕机模块

使用本模块向指定咕咕机发送消息。咕咕机是一款便携式私人打印机,详见官网。使用本模块需要在官网提前申请好自己的开发者ak, 详见这里。自豪地引用Yimian API构建!

  • wiot.guguji(ak, userID, memobirdID): 声明一个guguji模块,参数: 开发者ak, 用户id, 咕咕机id
  • wiot.guguji.send(msg): 发送消息,需传入待发送的消息
1
2
3
var gugu = wiot.guguji("9e55121803474371bfa25d20e554b31f", "832598", "b3ee06a8bd9b49e1");

gugu.print("This is from wIoT!!");

Quick Start

Current Support devices

  • D1 MINI

Node.js Install Node.js

Node.js is a widely used programming language for web developers. To make use of wIoT, you should first install Node.js to your computer.

For windows user, you can follow the instruction in this website

Install wIoT package

After install Node.js and configure npm successfully, you should then use npm to download wIoT package by enter following command in your command window.

1
npm install wiot

Windows user can use cmd or powershell.It should be notice that this may report error for some users. The solution is to open your cmd window as administrator. You can right click on cmd and choose run as an administrator. You can also press windows+R and input cmd then press Ctrl+Shift+Enter to open it as administrator.

Burn firmware

Connect your device to D1 MINI

  • After burning the firmware, you should try to connect your device to D1 MINI
    Follow the steps below, I’m sure it would not be a problem for such a smart person like you

1. Reset your D1 MINI

  • Find pin D0 on your D1 MINI, it should be in the middle of A0 and D5.
  • Use a wire to connect 3V3 to D0. If your MINI works normally, you would see its BUILT-IN LED blink.
  • You don’t have to wait until it stops blink, just stay for 2s, then you can pull out the wire and your MINI would reset.

2.Find your D1 MINI on your device

  • After you finish step 1, your MINI would work in AP mode, which means you can search it with your smart phone or personal computer by scanning the Wi-Fi around
  • If your MINI was reset successfully, you would find a Wi-Fi with SSID in the form of wiot-xx:xx:xx:xx:xx:xx.
    Example:
    ssid
    “xx:xx:xx:xx:xx:xx” is the MAC address of this MINI, please try to remember the address for you may use it later

The default password for D1 MINI is 1234567890, enter the password and you should be able to connect to your MINI.

Connect D1 MINI to your Wi-Fi

Congratulations, you have successfully connect your device to D1 MINI
However, this is not the end, you should now try to connect D1 MINI to your Wi-Fi
Use the device which had just been connected to D1 MINI and follow the steps below

1. Visit the control page of D1 MINI

Visit http://192.168.0.1 with the browser on your device
Normally, you would see a webpage like this:
webpage
In this page, you can see the MAC Address and wIoT version of your MINI
Again, please remember the MAC Address

2.Submit SSID and password to your MINI

From the page, you can see two blanks that ask the SSID and password of your Wi-Fi
Input information of the Wi-FI which you would like to connect your MINI, click Submit
If you have input the right SSID and password, you will see a page showing the message: Set Successfully!! Rebooting!!
Then, after a minute, you will see the SSID of D1 MINI has vanished

If you submitted the wrong message, do not try to directly reconnect to D1 MINI. Restart the whole procedure from the reset part of the last section

Execute Example Code

If you have successfully connect D1 MINI to your Wi-Fi, you can execute the example code below to realize a simple function of wIoT
Before executing the code, you should first connect a LED to D1 MINI with positive pole connect to pin D4 and negative pole connect to GND

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var wiot = require('wiot'); //Import wiot package from npm

// Create an object of single chip
// Here are two parameters, MAC is the MAC adress of single chip, the output port should be defined in pin
// The MAC address should be editted by user
var MyMCU = new wiot.client({MAC: "3C:71:BF:3A:F6:CF", pin: {D4 : 1}, hint : true});


// The following code can let the BUILTIN_LED turn on for one second and off for one second periodically

// Wait for all the chips to get ready
wiot.begin([MyMCU], ()=>{
// First parameter is the name of chip, second parameter is the function that is going to be executed

// Set timer, pin 3 of MyMCU will pull up every 2 seconds
setInterval(()=>{
MyMCU.write(wiot.D4, wiot.HIGH);
}, 2000);

// Set timer, executer the command in {} after a one-second delay
setTimeout(()=>{

// Set timer, pin 3 of MyMCU will pull down every 2 seconds
setInterval(()=>{
MyMCU.write(wiot.D4, wiot.LOW);
}, 2000);
}, 1000);
});

The LED is expected to blink after you execute the code

Advanced development

Parameters

NameDefault ValueDeclaration
MAC“”MAC Address of MCU
pin{D1: 0, D2: 0, D3: 0, D4: 0, D5: 0, D6: 0, D7: 0, D8: 0}Mode of each pin, 0 is INPUT, 1 is OUTPUT, 2is INPUT_PULLUP
hinttrueWhether print the status prompt
debugfalseWhether open the debug mode
ip“default”Specify MCU IP, please try this option when you cannot find IP for a long time
port8848TCP Socket communication port for Client, default 8848
ip_range“192.168.0”IP search field, try this option if you cannot find IP for a long time
localIP“127.0.0.1”local IP
errDelayTime2000Retry interval when network error is encountered (milliseconds)
okDelayTime30Waiting time after receiving the network request (milliseconds)
resetDelayTime4500Waiting time for stop sending new messages after sending reset instructions to MCU (milliseconds)
noTryMaxTime15000If the MCU fails to respond after this time, the message will be sent again (milliseconds).
IntervalTime2000Interval between monitoring (heartbeat)
MaxToReScanTime180000After this time, if the MCU has no response, it will scan the IP address again (in milliseconds).
MinResearchTime5000Interval between each polling
IpScanTimeout1Ping detection timeout for IP scanning (seconds)
pingTimeout2Timeout of Heartbeat Ping detection (seconds)
MaxTraceBackTimes8Determine the number of historical heartbeats traced back to the connection state

Parameters Declaration Example

General Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var MyMCU = new wiot.client({
MAC: "xx:xx:xx:xx:xx:xx",
pin: {
D1: 0,
D2: 0,
D3: 1,
D4: 1,
D5: 0,
D6: 1,
D7: 0,
D8: 0
},
hint: true,
debug: false,
ip: "192.168.0.55",
port: 6666,
ip_range: "192.168.0",
localIP: "127.0.0.1",
errDelayTime: 2000,
okDelayTime: 30,
resetDelayTime: 4500,
noTryMaxTime: 15000,
IntervalTime: 2000,
MaxToReScanTime: 180000,
MinResearchTime: 5000,
IpScanTimeOut: 1,
pingTimeout: 2,
MaxTraceBackTimes: 8
});

Event Binding

Client

.on(event, handler)

Event List of client

  • begin It begins when MCU starts to interact normally
  • disConnected Disconnect from MCU
  • reConnected Connection with MCU restored
1
2
3
4
5
6
7
8
js
var MCU = new wiot.client({"MAC": "xx:xx:xx:xx:xx:xx"});

MCU.on('disConnected', function () {

// Execute the command below when lost connection with MCU
console.log('Disconnected with MCU!!');
});

Pin

.pinOn(pin, event, handler)

Event List of pin

  • on Change output of pin from LOW to HIGH
  • off Change output of pin from HIGH to LOW
  • change Change the output of pin
1
2
3
4
5
6
7

var MCU = new wiot.client({"MAC": "xx:xx:xx:xx:xx:xx"});

MCU.pinOn(wiot.D2, 'on', function () {
// Execute when the output of D2 changes from LOW to HIGH
console.log('D2 from LOW to HIGH!!');
});

API

  • wiot.begin(): Execute when MCU is ready
1
2
3
4
5
6
7
8
9

MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx", pin: {D4: wiot.OUTPUT}});
MCU1 = new wiot.client({MAC: "xx:xx:xx:xx:xx:ww"});

wiot.begin([MCU0, MCU1], ()=>{

//Write the command you want to execute here
//These command would execute once MCU0 and MCU1 are ready
});

+
wiot.loop(): A loop command,Suitable for conditional control statements

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx", pin: {D4: wiot.OUTPUT}});
MCU1 = new wiot.client({MAC: "xx:xx:xx:xx:xx:ww"});


// Following code would realize: When pin D5 of MCU0 receive HIGH,D4 of MCU1 would output HIGH
// When pin D5 of MCU0 receive LOW,D4 of MCU1 would output LOW

// This function receives two parameters: first is an array of objects for MCU, second is a function which use MCU array of objects as its parameter

wiot.loop([MCU0, MCU1], () => {
if(MCU1.read(wiot.D5) == wiot.HIGH){
MCU0.write(wiot.D4, wiot.HIGH);
}else{
MCU0.write(wiot.D4, wiot.LOW);
}
});

Register

  • wiot.register.set(status1, status2, function): Add a rule to register that status can be either value or function,
    function would trigger if status1 == status2
    The registry is designed to facilitate the use of various extension modules, See [extension module] below (# Sensor Extension Module).

  • wiot.register.set(status, function): You can also pass in two functions, where the return value of status is of type bool, it would trigger the function if it changes to true

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

var myLED = wiot.led(MyMCU, wiot.D4);
var pir = wiot.pir(MyMCU, wiot.D2);

//Sign up for a rule that says myLED lights up when pir detects a person
wiot.register.set(pir.getStatus, wiot.HIGH, ()=>{
myLED.set(wiot.HIGH);
});

//Sign up for a rule that when people leave, myLED goes off
wiot.register.set(()=>{
return (wiot.LOW == pir.getStatus);
}, ()=>{
myLED.clear();
});

Sensor extension module

LED

  • wiot.led(MCU, pin): Declare a LED module

  • wiot.led.getStatus(): Get status of LED

  • wiot.led.set(status, time = 0, isSmooth = false): Set led state, initial state, intermediate state, final state, period

  • wiot.led.breath(period): Set a breathing LED

  • wiot.led.clear(): Reset LED

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var wiot = require('wiot'); //Import wiot package from npm
MCU0 = new wiot.client({MAC: "3C:71:BF:3A:F6:CF", pin: {D4: wiot.OUTPUT}});

var myLED = wiot.led(MCU0, wiot.D4); //Create a new led object using the D4 port on MCU0

/* If myLED is not shining, light it up*/
if(!myLED.getStatus()){
myLED.set(wiot.HIGH);
}

/* Set a breathing light with cycle of 2s */
myLED.breath(2000);

/* Set a LED which light 3 seconds and off 4 seconds */
myLED.set([wiot.HIGH, wiot.LOW], [3000, 4000]);

/* Set a breathing light which use 1 second to light and 3 second to extinguish */
myLED.set([wiot.LOW, wiot.HIGH], [1000, 3000], true);

/* Set a LED which shine with half brightness for 2 seconds, shine with full brightness for 3 seconds and then dextinguish for 2 seconds */
myLED.set([100, wiot.HIGH, wiot.LOW], [2000, 3000, 2000]);

/* Turn off LED */
myLED.clear();

PIR (Passive Infrared Sensor)

  • wiot.pir(MCU, pin): Declare a PIR module
  • wiot.pir.getStatus(): Gets the PIR state, returns the value wiot.high (have people), wiot.low (no people)

Event Trigger

  • wiot.pir.on(event, handler)

Events List

  • detected Person detected
  • undetected People out of the detective field
  • change State change, includes from detected to undetected and from undetected to detected
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var wiot = require('wiot'); //Import wiot package from npm

MCU0 = new wiot.client({MAC: "3C:71:BF:3A:F6:CF"});

var myPIR = wiot.pir(MCU0, wiot.D2); //Create an object of pir, use the D2 port on MCU0

/* Output the status of pir to console */
console.log(myPIR.getStatus());

/* When human is detected,print "Detected People!" to console */
myPIR.on("detected", ()=>{
console.log("Detected People!");
});

/* When human is out of the detection zone,print "No People!!" to console */
myPIR.on("undetected", ()=>{
console.log("No People!!");
});

/* When there is a change to status, execute your command */
myPIR.on("change", ()=>{
/* Write command in here */
});

IR Infrared Sensor

  • wiot.ir(MCU, pin): Declare an IR module, pin can be analog or digital port
  • wiot.ir.getStatus(): Get IR state, return value wiot.high (with a barrier), wiot.low (with no barrier), or a value of 0-1024 (only for analog port)

Event Trigger

  • wiot.ir.on(event, handler)

Event List

  • detected Barrier detected
  • undetected Barrier vanished
  • change Change state
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx"});

var myIR = wiot.ir(MCU0, wiot.D2); //Create a new ir object using the D2 port on MCU0

/* Output ir status to console */
console.log(myIR.getStatus());

/* When an object is detected, print "Detected Object!" to the console */
myIR.on("detected", ()=>{
console.log("Detected Object!");
});

/* When the object move out of the detective area, print "No Object!!" to the console */
myIR.on("undetected", ()=>{
console.log("No Object!!");
});

/* Execute the command when state changes */
myIR.on("change", ()=>{
/* Your command */
});

lightSensor

  • wiot.lightSensor(MCU, pin): Declare a lightSensor module, pin can be analog or digital port
  • wiot.lightSensor.getStatus(): Get lightSensor state, return value wiot.HIGH(light), wiot.LOW(dark), or a value of 0-1024 (limited to analog port)

Event Trigger

  • wiot.light.on(event, handler)

Event List

  • light From dark to light
  • dark From light to dark
  • change Change state
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

MCU0 = new wiot.client({MAC: "xx:xx:xx:xx:xx:xx"});
var myLightSensor = wiot.lightSensor(MCU0, wiot.D1); //Create a new pir object using the D2 port on MCU0

/* Output the LightSensor state to the console */
console.log(mylightSensor.getStatus());

/* When going from dark to Light, print "Light!!!" to the console */
myLightSensor.on("light", ()=>{
console.log("Light!");
});

/* When going from light to Dark, print "Dark!!" to the console */
myLightSensor.on("dark", ()=>{
console.log("Dark!!");
});

/* When the state changes, execute the command */
myLightSensor.on("change", ()=>{
/* Your command */
});

Internet Extension Module

Mail module

Use this module to send messages to the specified mailbox. Proudly built with reference to Yimian API!

  • wiot.mail(to, from = "wIoT"): Declare an mail module with sender’s name and reveiver’s address
  • wiot.mail.send(subject, body): Send email with a subject and content
1
2
3
var mail = wiot.mail("i@iotcat.me", "wIoT Test");

mail.send("Test", "Test from wiot!!");

guguji

Use this module to send messages to the specified cooing machine.Goo goo is a portable private printer, see official website.
To use this module, you need to apply for your own developer ak in advance on the official website. See here. Proudly reference Yimian API!

  • wiot.guguji(ak, userID, memobirdID): Declare a goo goo chicken module, parameter: developer’s ak, user id, cooing machine id
  • wiot.guguji.send(msg): Send message, need to pass in the message to be sent
1
2
3
var gugu = wiot.guguji("9e55121803474371bfa25d20e554b31f", "832598", "b3ee06a8bd9b49e1");

gugu.print("This is from wIoT!!");
]]>
tech iot nodeJS WiFi
中美贸易战-解 /thoughts/trade-war.html

中美贸易战的解不在美国,而是在我们自己身上。

The solution to the Sino-US trade war is not in the United States, but in ourselves.

关于谈判,党内争议比较大,但最终很有可能会拒绝做出让步。
当美关税抬升,国内相关产业链将大批转移至台湾及东南亚国家,累计将造成1亿人口的就业问题。与前几次的危机不同,这一次我们不但要提防房市泡沫的激化,也没有那麽多的基建可提供就业。从另一方面看,近几年来,中国的产能过剩问题主要通过出口得以解决,拿着贸易顺差来发展国内经济,以实现不可思议的经济增长。如今特朗普政府征加关税,将使得这一策略不再行得通。

如果在谈判中妥协,中方将丧失好不容易占来的第四次工业革命先机,并经济将会想日本,韩国一样任人摆布。

我认为,在不妥协的前提下,中共有三个破局之法。

  1. 武统台湾
    这个需要看明年台湾大选,是否能找到正当的武统理由。但的确有助于缓解国内社会焦点问题。
  2. 房市改革
    可能性极大,把泡沫危机转变成创造就业机会的资本。
  3. 游戏
    将社会上的过剩劳动力转移进游戏产业空转,以缓解社会矛盾的形成。

为了缓解失业冲击的强度,央行将通过印人民币使人民币贬值来增进出口,吸引他国来补充美资撤离的空缺。

以上。。

Regarding negotiations, there are relatively large disputes within the party, but in the end it is very likely that they will refuse to make concessions.
When U.S. tariffs rise, related domestic industrial chains will be transferred to Taiwan and Southeast Asian countries in large numbers, which will cause employment problems for 100 million people. Unlike previous crises, this time we not only have to guard against the intensification of the housing market bubble, but also there is not so much infrastructure that can provide employment. On the other hand, in recent years, China’s overcapacity problem has been solved mainly through exports, and the trade surplus is used to develop the domestic economy in order to achieve incredible economic growth. Now that the Trump administration imposes tariffs, this strategy will no longer work.

If it compromises in the negotiation, China will lose the opportunity of the Fourth Industrial Revolution that it finally took over, and its economy will be at the mercy of Japan and South Korea.

I think that under the premise of no compromise, there are three ways to break the game.

  1. Wu Tong Taiwan
    This depends on whether Taiwan’s general election next year can find a legitimate reason for military reunification. But it does help alleviate domestic social focus issues.
  2. Housing market reform
    It is very possible to turn the bubble crisis into capital for job creation.
  3. Games
    Transfer the surplus labor force in the society into the game industry to ease the formation of social conflicts.

In order to alleviate the intensity of the unemployment shock, the central bank will increase imports and exports by printing the renminbi to depreciate the renminbi, attracting other countries to supplement the vacancy of the withdrawal of US capital.

the above. .

]]>
thoughts war
自动发邮件API /tech/mail-api.html

重整自己先前的mail模块,顺便封装了一个API出来,欢迎大家调用~

Reorganized my previous mail module and encapsulated an API by the way. Welcome everyone to call~

方法

参数(接受GET和POST)

  • to收信人邮箱地址
  • subject邮件主题
  • body邮件内容(建议使用html格式)
  • from发件人名称

请求地址

1
https://api.yimian.xyz/mail

示例

1
https://api.yimian.xyz/mail/?to=收信邮箱&subject=邮件主题&body=邮件内容&from=发件人名称

[scode type=”yellow”]如遇到GET传递邮件内容错误,请尝试使用POST[/scode]

返回值(json格式)

  • 参数state::true(成功)或false(失败)

[scode type=”dangerous”]每个IP每天请求上限50个[/scode]

Method

Parameters (accept GET and POST)

  • to recipient email address
  • subject mail subject
  • body email content (html format is recommended)
  • from sender name

Request address

1
https://api.yimian.xyz/mail

Example

1
https://api.yimian.xyz/mail/?to=receiving mailbox&subject=mail subject&body=mail content&from=sender name

[scode type=”yellow”] If you encounter an error in GET delivery of the mail content, please try using POST[/scode]

Return value (json format)

  • Parameter state::true (success) or false (failure)

[scode type=”dangerous”] There are 50 requests per day per IP[/scode]

]]>
tech api mail
JS中那些惊艳的操作 /tech/js-notes.html

教你如何一步步迷上JS.. ╮(╯▽╰)╭

Teach you how to fall in love with JS step by step.. ╮(╯▽╰)╭

好嘀,只是一些总结

JS中的那些萌点

  • <script>标签中,合理使用defer="defer"(延迟执行),async="async"(异步执行)
  • 外部JS可以使用其它扩展名(如.php),但必须返回正确MINE类型
  • 使用var obj = preferredObj || backupObj; 提供后备值 ::aru:surprised::
  • 函数中使用arguements[]获取参数
  • 无函数签名,再见吧重载 ::aru:meditation::
  • 函数无引用传参,只要不作死用全局变量,封装就很完美
  • 神奇的垃圾收集功能,开发时无需考虑手动释放内存
  • 函数传参使用function hh({})直接传包含参数的对象,更加灵活
  • 数组每一个位置可以存不同类型的数据 ::aru:blood2::
  • 数组支持模拟栈操作,如push()pop()
  • 数组支持模拟队列操作,如push()shift()
  • 数组支持从相反方向模拟队列,如unshift()pop()
  • sort()可自定义比较函数为参数
  • 数组splice()可太好用了吧
  • 函数是对象,函数名是指针
  • 可以像传递参数一样把一个函数传给另一个函数,也可以将一个函数作为另一个函数的结果返回
  • 函数中可通过arguments.callee获取当前函数名指针
  • 使用arguments.callee.caller获取调用当前函数的引用
  • 使用function.apply(this/*作用域*/, arguments)function.call(this, arg1, arg2...)指定作用域运行函数
  • 使用函数固有属性function.length获取其期待的参数个数
  • 通过函数继承属性toLocaleString()``toString()``valueOf()返回代码,方便调试
  • 使用indexOf()``lastIndexOf()查找元素出现位置
  • trim()删除字符串开头结尾空格
  • 支持正则RegExp
  • 神奇但可怕的eval("")可将字符串转译成代码并就地执行
  • encodeURI()/decodeURI()encodeURIComponent()/decodeURICompoent()处理uri
  • 立即调用函数function(){}();
  • 内置Math对象
  • Math中ceil()``floor()``round()向上,向下,标准舍入
  • Math.random()大于零小于一随机数
  • 对象中使用functionName: function(){}直接定义函数
  • ES6中(x)=>x+1等价于function(x){return x+1;}
  • 使用;(function(name, context, definition){moudle.exports = definition();})('funationName', this, function(){});封装模块

小心得

  • 不建议使用with语句
  • label标签少用
  • 0.1 + 0.2 != 0.3 浮点型天坑,与C类似
  • ~26 == -27 利用按位非提高效率
  • 标识符查询由内部环境向外部环境进行
  • 没有块级作用域,与C++不同
  • var obj2 = obj1;实际是引用
  • 函数传参时传对象,实际传的是指针
  • 全局变量用完及时置为null以提性能
  • 使用变量属性访问对象只能使用obj[var]
  • var sum = function sum(){};在Safari中会报错
  • 不能为基本类型值添加属性和方法
  • new Number("25")返回对象,而Number("25")返回25
  • 布尔表达式中对象均为true

Okay, just some summary

Those cute points in JS

  • In the <script> tag, reasonably use defer="defer" (delayed execution) and async="async" (asynchronous execution)
  • External JS can use other extensions (such as .php), but must return the correct MINE type
  • Use var obj = preferredObj || backupObj; to provide a backup value ::aru:surprised::
  • Use arguements[] to get parameters in the function
  • No function signature, goodbye overload ::aru:meditation::
  • The function has no reference to pass parameters, as long as the global variable is not used for deadly, the encapsulation is perfect
  • Magic garbage collection function, no need to consider manually releasing memory during development
  • Use function hh({}) to pass parameters directly to functions, which is more flexible
  • Each position of the array can store different types of data ::aru:blood2::
  • Array supports simulated stack operations, such as push() and pop()
  • Array supports simulated queue operations, such as push() and shift()
  • Array supports simulating queues from the opposite direction, such as unshift() and pop()
  • sort() can customize the comparison function as a parameter
  • The array splice() is so easy to use, right?
  • Functions are objects and function names are pointers
  • You can pass a function to another function as parameters, or you can return a function as the result of another function
  • In the function, the current function name pointer can be obtained through arguments.callee
  • Use arguments.callee.caller to get a reference to call the current function
  • Use function.apply(this/*scope*/, arguments) or function.call(this, arg1, arg2...) to specify the scope to run the function
  • Use the function intrinsic property function.length to get the number of expected parameters
  • Inherit the property toLocaleString(), toString(), and valueOf() return code through the function to facilitate debugging
  • Use indexOf() and lastIndexOf() to find the element’s appearance
  • trim() delete spaces at the beginning and end of the string
  • Support regular RegExp
  • The magical but terrible eval("") can translate the string into code and execute it in place
  • encodeURI()/decodeURI() and encodeURIComponent()/decodeURICompoent() handle uri
  • Call the function immediately function()()();
  • Built-in Math object
  • ceil(), floor(), round() in Math up, down, standard rounding
  • Math.random() is a random number greater than zero and less than one
  • Use functionName: function(){} in the object to directly define the function
  • In ES6 (x)=>x+1 is equivalent to function(x){return x+1;}
  • Use ;(function(name, context, definition){moudle.exports = definition();})('funationName', this, function()()); to encapsulate the module

Be careful

  • It is not recommended to use with statement
  • Less use of label
  • 0.1 + 0.2 != 0.3 floating point tiankeng, similar to C
  • ~26 == -27 Use bitwise not to improve efficiency
  • Identifier query is carried out from the internal environment to the external environment
  • No block-level scope, different from C++
  • var obj2 = obj1; is actually a reference
  • The object is passed when the function is passed, but the pointer is actually passed
  • Set global variables to null when used up to improve performance
  • Use variable attributes to access objects can only use obj[var]
  • var sum = function sum(){}; will report an error in Safari
  • You cannot add attributes and methods to basic type values
  • new Number("25") returns the object, and Number("25") returns 25
  • All objects in Boolean expressions are true
]]>
tech nodeJS
Centos7下 Nginx 配置ssl证书自动续期 /tech/ssl-auto-apply.html

断断续续玩web已经一年了,一些之前从腾讯云申的TrustAsia证书已经陆陆续续开始过期,很方..于是开始尝试申请Let’s Encrypt的免费证书,并实现自动续期|´・ω・)ノ

I’ve been playing on the web intermittently for a year, and some of the TrustAsia certificates from Tencent’s Yunshang have started to expire one after another. It’s very fragrant.. So I started to try to apply for Let’s Encrypt’s free certificate, and realized automatic renewal|´・ω・)ノ

前提条件

  • 必须是Centos7系统,其它未测试,不保证有效
  • 有自己的域名
  • 确认dns已将域名指向服务器
  • 防火墙放行80与443端口
  • 已配置好nginx代理,并可以通过http访问域名(一定确定能访问)

安装certbot

通过yum安装certbot

1
2
3
$ yum update #更新yum源
$ yum install -y epel-release #安装epel源
$ yum install -y certbot #安装certbot

初次申领证书

初次申领某域名证书

格式为

1
$ certbot certonly --webroot -w [Web站点目录] -d [站点域名] -m [联系人email地址] --agree-tos

例如

1
$ certbot certonly --webroot -w /opt/www/demo.yourdomain.com -d demo.yourdomain.com -m yourname@gmail.com --agree-tos

证书位置

证书存放在/etc/letsencrypt/live/demo.yourdomain.com/文件夹中。
一共有4个文件,你可能要用到的是fullchain.pemprivkey.pem

配置nginx

在相应的server{}中加入以下内容:

1
2
3
4
5
6
7
8
9
10
11
listen 443 ssl;

ssl_certificate /etc/letsencrypt/live/demo.yourdomain.com/fullchain.pem; #2
ssl_certificate_key /etc/letsencrypt/live/demo.yourdomain.com/privkey.pem; #3

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
error_page 404 = /404.php;

例如

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
server {
listen 443 ssl;
listen 80;

server_name demo.yourdomain.com; #1
root /opt/www/demo.yourdomain.com;
index index.html;
client_max_body_size 1000M;

ssl_certificate /etc/letsencrypt/live/demo.yourdomain.com/fullchain.pem; #2
ssl_certificate_key /etc/letsencrypt/live/demo.yourdomain.com/privkey.pem; #3

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
error_page 404 = /404.html;

}

配置成功后执行如下指令:

1
2
$ nginx -t #检查nginx conf语法
$ systemctl restart nginx #重启nginx

配置自动续期

编辑crontab规则:(初次配置crontab)

1
$ crontab -e

键入以下内容(每月1号5时刷新证书并重启nginx)保存并退出

1
00 05 01 * * /usr/bin/certbot renew --quiet && /bin/systemctl restart nginx

重启crontab

1
$ systemctl restart crond.service

参考链接:
https://blog.csdn.net/sheng119/article/details/72956717

Prerequisites

  • Must be Centos7 system, others have not been tested and are not guaranteed to be valid
  • Have your own domain name
  • Confirm that dns has pointed the domain name to the server
  • The firewall allows port 80 and 443
  • The nginx proxy has been configured, and domain name can be accessed via http (be sure to be able to access)

Install certbot

Install certbot via yum

1
2
3
$ yum update #Update yum source
$ yum install -y epel-release #Install epel source
$ yum install -y certbot #Install certbot

Initial application certificate

Apply for a domain name certificate for the first time

The format is

1
$ certbot certonly --webroot -w [Web site directory] -d [domain name] -m [contact email address] --agree-tos

E.g

1
$ certbot certonly --webroot -w /opt/www/demo.yourdomain.com -d demo.yourdomain.com -m yourname@gmail.com --agree-tos

Certificate location

The certificate is stored in the /etc/letsencrypt/live/demo.yourdomain.com/ folder.
There are 4 files in total, you may need to use fullchain.pem and privkey.pem.

Configure nginx

Add the following content to the corresponding server{}:

1
2
3
4
5
6
7
8
9
10
11
listen 443 ssl;

ssl_certificate /etc/letsencrypt/live/demo.yourdomain.com/fullchain.pem; #2
ssl_certificate_key /etc/letsencrypt/live/demo.yourdomain.com/privkey.pem; #3

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
error_page 404 = /404.php;

E.g

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
server {
listen 443 ssl;
listen 80;

server_name demo.yourdomain.com; #1
root /opt/www/demo.yourdomain.com;
index index.html;
client_max_body_size 1000M;

ssl_certificate /etc/letsencrypt/live/demo.yourdomain.com/fullchain.pem; #2
ssl_certificate_key /etc/letsencrypt/live/demo.yourdomain.com/privkey.pem; #3

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
error_page 404 = /404.html;

}

After the configuration is successful, execute the following instructions:

1
2
$ nginx -t #Check nginx conf syntax
$ systemctl restart nginx #Restart nginx

Configure automatic renewal

Edit crontab rules: (First configuration crontab)

1
$ crontab -e

Type the following (refresh the certificate and restart nginx on the 1st and 5th of each month) to save and exit

1
00 05 01 * * /usr/bin/certbot renew --quiet && /bin/systemctl restart nginx

Restart crontab

1
$ systemctl restart crond.service

Reference link:
https://blog.csdn.net/sheng119/article/details/72956717

]]>
tech centos7 ssl
数电期中总结 /notes/digital-circuit.html

上学期掉了魔电的坑,这学期来搞点数电小攻略掩饰一下(☆ω☆)

I lost the pit of magic electricity last semester. This semester, let’s make a small strategy to hide it (☆ω☆)

1. 数制与码制

二进制运算

补码

常用补码来表示负数,以便于计算。
正数和零补码是其自身,负数的补码方法如下:
二进制减法可以通过被减数加要减数的补码来实现。
<法一>直接法
$$(N)_{COMP}=\begin{cases}N&\text{N为正数}\2^{n}-N& \text{N为负数} \end{cases}$$

符号位为零(正数)时,补码与源码相同,符号位为1(负数)时,补码为$2^{n}-N$.
<法二>观察法
欲求补码,可以先找其反码。
$$(N)_{INV}=\begin{cases}N&\text{N为正数}\(2^{n}-1)-N& \text{N为负数} \end{cases}$$

即,除符号位外其他值0变1,1变0。
随后反码整体加1即可得到补码~

常用编码

DCB

即8421恒权码。DCB作为10进制显示时,须在每一个Invalid位(>9)上加6。

Signed Numbers

使用8位,最左边一位表示符号,其余7位表示数值。

期中总结

第一周 - 初识数电

  • 模拟量太复杂,不符合人类思维
  • 三极管MOS管等非线性器件为魔转数提供了器件基础
  • 因为模电太难,所以我们要学数电
    一些要点
  • TTL意思是指晶体管逻辑电路,由各种三极管和电阻组成,特点是速度快
  • TTL中0-0.8V为低电平,2-5V为高电平
  • 二进制与十进制相互转换(整数/小数)
  • LSB(Least Significant Bit)/MSB(Most S B)

第二周 - 数制

  • 反码 1’s Complement
  • 补码 2’s Complement
  • 有时候二进制太长不好用,这使16进制很方便
  • 16进制类似2进制的助记符,如观察1100 0101可直接写出C5
  • BCD是用一个16进制表示一个10进制数
  • BCD很符合人类的思维习惯,但造成极大的资源浪费
  • BCD四则运算,我觉得最好转成10进制算完再转回去,反正很方便
  • 计算机BCD加法采取+6进位法
  • 数字储存时最左一位是符号位
  • 负数使用补码来存储(栗子)
  • 1字节signed数字范围-128-127
  • 合理设计存储位数,小心溢出
  • 二进制乘法
  • 二进制除法 与十进制类似

第三周 - 逻辑门与电路封装类型

  • 非门 NOT
  • 与门 AND
  • 或门 OR
  • 非与门 NAND
  • 非或门 NOR
  • 异或门 XOR
  • 常见有TTL和CMOS两类
  • CMOS按照供压可分为3.3V和5V两类
  • fan-out是指有效input个数
  • propagation delay time指响应时间
  • 集成电路命名,如74LS04中74指商品级,LS指种类,04为型号
  • 按复杂程度分类:SSI(1-12门),MSI(13-99门),LSI(100-9999门),VLSI(10000-99999),ULSI(100000+)

第四周 - 布尔运算

  • 遵循交换,结合,分配律
  • 结论A+AB=AA+~AB=A+B
  • DeMorgan’s Theorems ~(AB)=(~A+~B)~(A+B)=~A~B
  • ~A~B为Negative AND, ~(AB)为NAND, OR同理
  • SOP格式为··+··+··
  • POS格式为()*()*()
  • Truth Table即为将全部可能的Input和output列表

第五周 - Karnaugh Map

  • Karnaugh Map来可视化逻辑门化简

第六周 - 逻辑门组合

  • NAND和NOR可以组合出其它任意门
  • 加法器 左位放A AND B右位放A XOR B
  • 比较器 1bitA XOR B 2bit(A0 XOR B0) NOR (A1 XOR B0)
  • 译码器 逻辑二进制转控制电平输出

课件:
Lecture03.pdf
Lecture04.pdf

1. Number system and code system

Binary operation

Complement

The complement is often used to represent negative numbers for easy calculation.
Positive numbers and zero complement are themselves, and the complement method of negative numbers is as follows:
Binary subtraction can be implemented by adding the complement of the subtracted number to the subtracted number.
Direct Method
$$(N)_{COMP}=\begin{cases}N&\text{N is a positive number}\2^{n}-N& \text{N is a negative number} \end{cases}$$

When the sign bit is zero (positive number), the complement is the same as the source code. When the sign bit is 1 (negative number), the complement is $2^{n}-N$.
Observation Method
If you want the complement, you can find the inverse first.
$$(N)_{INV}=\begin{cases}N&\text{N is a positive number}\(2^{n}-1)-N& \text{N is a negative number} \end{cases}$$

That is, except for the sign bit, 0 changes to 1, and 1 changes to 0.
Then add 1 to the whole complement to get the complement~

Common coding

DCB

That is, the 8421 constant weight code. When DCB is displayed as a decimal number, 6 must be added to each Invalid bit (>9).

Signed Numbers

8 bits are used, the leftmost bit represents the sign, and the remaining 7 bits represent the value.

Mid-term summary

First week-first acquaintance with digital telephony

  • The analog quantity is too complicated to conform to human thinking
  • Non-linear devices such as triode and MOS tube provide the device basis for the magic speed
  • Because analog electricity is too difficult, we have to learn math electricity
    Some points
  • TTL means transistor logic circuit, composed of various transistors and resistors, and is characterized by fast speed
  • 0-0.8V in TTL is low level, 2-5V is high level
  • Conversion between binary and decimal (integer/decimal)
  • LSB(Least Significant Bit)/MSB(Most S B)

Second week-Number system

  • 1’s Complement
  • 2’s Complement
  • Sometimes the binary is too long to use, which makes hexadecimal very convenient
  • Hexadecimal is similar to binary mnemonic, if you observe 1100 0101, you can write C5 directly
  • BCD uses a hexadecimal number to represent a decimal number
  • BCD is in line with human thinking habits, but it causes a great waste of resources
  • BCD four arithmetic, I think it’s best to convert to decimal and then convert it back. Anyway, it’s very convenient
  • Computer BCD addition adopts +6 carry method
  • When storing numbers, the leftmost digit is the sign bit
  • Negative numbers are stored using one’s complement (chestnut)
  • 1 byte signed number range -128-127
  • Reasonably design the number of storage bits and be careful of overflow
  • Binary Multiplication
  • Binary Division Similar to decimal

Week 3-Logic Gate and Circuit Package Type

  • NOT
  • AND gate
  • OR gate OR
  • NOT AND gate NAND
  • NOR gate
  • Exclusive OR gate XOR
  • Commonly there are TTL and CMOS two types
  • CMOS can be divided into 3.3V and 5V according to the supply voltage
  • Fan-out refers to the number of valid inputs
  • propagation delay time refers to response time
  • IC naming, for example, 74 in 74LS04 means commodity grade, LS means type, 04 is model
  • Classification by complexity: SSI (1-12 doors), MSI (13-99 doors), LSI (100-9999 doors), VLSI (10000-99999), ULSI (100000+)

Week 4-Boolean operations

  • Follow the exchange, combination, and distribution laws
  • Conclusion A+AB=A and A+~AB=A+B
  • DeMorgan’s Theorems ~(AB)=(~A+~B) and ~(A+B)=~A~B
  • ~A~B is Negative AND, ~(AB) is NAND, OR is the same
  • SOP format is ··+··+··
  • POS format is ()*()*()
  • Truth Table is a list of all possible Input and Output

Week 5-Karnaugh Map

  • Karnaugh Map to visualize logic gate simplification

Week 6-Logic Gate Combination

  • NAND and NOR can be combined into any other gate
  • Adder put A AND B on the left bit and A XOR B on the right bit
  • Comparator 1bitA XOR B 2bit(A0 XOR B0) NOR (A1 XOR B0)
  • Decoder logic binary to control level output

Courseware:
Lecture03.pdf
Lecture04.pdf

]]>
notes circuit
经济,环境可持续性 /thoughts/economy-environment-sustainability.html

经济学是一门研究选择的学问。人们活在世上总是在进行着各种选择。发展落后的国家希望尽快工业化发展经济,来改善自己的生存环境。而工业化后的国家则希望发展同时兼顾环境。于是落后国家需要50年来发展工业,搞基建,破坏环境。之后的50年则拼命治理环境,发展生态。由于地球生态是一个整体,发达国家非常不爽落后的国家搞工业化污染环境,于是各种矛盾。不过在21世纪,有望利用信息数字科技打破50-50年法则,为新一批的国家崛起提供蹊径( ๑´•ω•) “

Economics is a study of choice. People are always making various choices in the world. Countries that are underdeveloped hope to industrialize and develop their economy as soon as possible to improve their living environment. The post-industrial countries hope to develop while taking the environment into consideration. So backward countries need 50 years to develop industry, engage in infrastructure construction, and destroy the environment. For the next 50 years, he worked hard to control the environment and develop the ecology. Because the earth’s ecology is a whole, developed countries are very upset and backward countries are engaged in industrialization and polluting the environment, so various contradictions arise. However, in the 21st century, it is expected to use information and digital technology to break the 50-50 year rule and provide a path for the rise of a new group of countries (๑´•ω•) “

为什么追求发展

自然环境较为恶劣,不完全适合人类生存。于是具备主观能动性的人类开始由改造环境的冲动。这一心理行为逐步早就了名为“发展”的宏伟故事,大家都对其深信不已。就像故事中所描述的一样,人们为了实现这一目标开始减少内耗(战争),社会趋于高度分工化。

人类有一种基本心理效应叫蔡格尼克效应,讲的是人如果开始做一件事情便会难以在中途停下来。这一效应在群体行为中则会变本加厉的体现。当人们开始追求发展,并且得到了一定的激励(生活的确更舒适了,至少人们是这样认为的),于是这个势头便不会轻易停下来了,于是人类进入了千年级别的发展时期。

发展初期,太多的基础设施需要建设,太多的工业需要发展,最重要的是这个时候大家都很穷,都只是在一个信念的支撑下在向着发展的目标努力搞生产。而且一般当这个时候,往往会有其他强国对你虎视眈眈,所以这个时候,大家都会很团结,但不会像祖先以及后辈一样在乎什么环境生态的。只有一个想法便是希望发展起来。

经过大约50年的发展,生活好了,底气足了,开始关注一些更长久的事情,比如教育和环境。于是接下来的50年,开始拼命治理环境,搞教育。于是渐渐的环境好了,下一代也成长起来了。于是年轻一代们便利用他们头脑中的书本知识,开始批判祖先们破坏环境这不好那不好,开始投科研资金,股市凡是跟环保相关的板块开始居高不下,可持续发展开始成为许多人的口头禅。而这时,当时那些破坏环境的罪魁祸首们正退休在家里乐呵呵的看着这一切的发生。大概就是这么一个过程了。

Environmental Kuznet Curve

Environmental Kuznet Curve

上图的曲线非常科学地向我们展示出了一个国家在发展与环境之间摇摆的必然趋势。在这一图表的背后,反应出了以下几点:

  • 人们倾向于只考虑自己的假设
  • 不同于个体的人群特性
  • 生存资源稀缺
  • 生产资料流通低效

这意味着,如果能够改变上述的任何一个条件,Kuznet 诅咒便有希望得以改变,从而减小摆动周期和幅度,控制环境重建与修复成本,真正在宏观上实现人们所希望的高效率可持续发展。而新一代的数字信息技术正是这一可能性得以实践的关键。

概念图

graph TDA{Environment}B{Economy}C{Society}D[GDB Based]E[NNI** HDI]F[Kuznet Curve]G[Env Kuznet Curve]H((Human Nature))I[Human Behavior]J[Improve Living Environment]K[Request for Dev]A --> JJ --> KK --> BB --> |measured by| DD --> |neglect| CB --> |predicted by| FF --> CD --> |foments| ID --> |spoils| AG --> CH --> IE --> |consider| AB --> EA --> HI --> |caused by| CI --> A

参考课件:
Economic Development and The Environment.pdf

Why pursue development

The natural environment is relatively harsh and not entirely suitable for human survival. Therefore, human beings with subjective initiative begin to change the environment from the impulse. This psychological behavior gradually resulted in a magnificent story called “development”, and everyone was convinced of it. As described in the story, in order to achieve this goal, people begin to reduce internal friction (war), and society tends to be highly divided.

Human beings have a basic psychological effect called the Zeignik effect, which means that if a person starts to do something, it will be difficult to stop in the middle. This effect will be intensified in group behavior. When people start to pursue development, and get a certain amount of incentives (life is indeed more comfortable, at least people think so), then this momentum will not easily stop, so mankind has entered a millennium-level development period.

In the early stages of development, too much infrastructure needs to be built, too much industry needs to be developed, and the most important thing is that everyone is very poor at this time, and they are only working hard towards the goal of development under the support of a belief. And generally at this time, there will often be other powerful countries looking at you, so at this time, everyone will be very united, but they will not care about the environment and ecology like their ancestors and descendants. There is only one idea that I hope to develop.

After about 50 years of development, my life is better and I am more confident, and I start to pay attention to some longer-term things, such as education and the environment. So in the next 50 years, I began to work hard to improve the environment and engage in education. As a result, the environment gradually improved, and the next generation grew up. So the younger generation made use of the book knowledge in their minds and began to criticize their ancestors for destroying the environment, which is not good or not, and began to invest in scientific research funds. The stock market began to remain high in environmental protection-related sectors, and sustainable development began to become many people. Mantra. At this time, the culprits who were damaging the environment at that time were retiring at home and happily watching this happen. It’s probably such a process.

Environmental Kuznet Curve

Environmental Kuznet Curve

The curve in the figure above shows us very scientifically the inevitable trend of a country swinging between development and the environment. Behind this chart, the following points are reflected:

  • People tend to only consider their own assumptions
  • Different from individual characteristics of the population
  • Survival resources are scarce
  • Inefficient circulation of production materials

This means that if any of the above conditions can be changed, the Kuznet curse will hopefully be changed, thereby reducing the swing cycle and amplitude, controlling the cost of environmental reconstruction and restoration, and truly achieving the high-efficiency and sustainable development that people hope on the macro level. . The new generation of digital information technology is the key to this possibility.

Concept map

graph TDA{Environment}B{Economy}C{Society}D[GDB Based]E[NNI** HDI]F[Kuznet Curve]G[Env Kuznet Curve]H((Human Nature))I[Human Behavior]J[Improve Living Environment]K[Request for Dev]A --> JJ --> KK --> BB --> |measured by| DD --> |neglect| CB --> |predicted by| FF --> CD --> |foments| ID --> |spoils| AG --> CH --> IE --> |consider| AB --> EA --> HI --> |caused by| CI --> A

Reference Courseware:
Economic Development and The Environment.pdf

]]>
thoughts development environment
气候变化与全球环境 /thoughts/global-climate-change.html

全球气候变化与人类行为有着显著的相关性,人类行为又会改变气候的自然变化。通过研究Ice core等Archive,发现地球历史中温度与$CO_{2}$浓度有着显著正相关性。如今,人类行为使大气$CO_{2}$含量远超其正常水平,其可能引起全球变暖,冰川融化等,但仅为可能..

Global climate change has a significant correlation with human behavior, and human behavior will change the natural changes in climate. By studying Archives such as Ice core, it is found that there is a significant positive correlation between the temperature and the concentration of $CO_{2}$ in the history of the earth. Nowadays, human behavior makes the atmospheric content of $CO_{2}$ far exceed its normal level, which may cause global warming, melting of glaciers, etc., but it is only possible…

概念简介

天气与气候

天气是指一段较短时间段内的大气状态,而气候研究的主要使更长时间中周期行动大气状态规律。简言之,气候是周期变化的天气。气候具备地域性,随纬度与海陆分布密切相关。在更长的时间维度上,我们发现地球的气候变迁也呈现出显著的周期性。

地球历史温度变迁

上图描述了地球的历史温度,其具有明显的周期性。值得注意的是,每当全球气候变暖,便会激发物种爆炸。而现在,正处于一次小规模的温度上升期,且温度上升速度与历史数据并无太大异常,因此无法确凿证明其与人类二氧化碳排放有关。

研究方法

直接法(研究现代)

  1. 记录温度
  2. 记录降雨量 (Precipitation)
  3. 研究植被 (Vegetation)
  4. 海平面
  5. 冰川 (Glaciers) :: 主要通过研究冰盖融化与生成的Balance

间接法(研究历史)

  1. Proxy
  2. Archive e.g. “Ice Core” ::从冰层(Ice Sheet)中提取的分层的冰棍标本

Ice Core分层原因

积雪后,随着时间推移,积雪会经历以下几种状态:

  1. Snow (几小时,主要成分是空气)
  2. Firn (几天,粒雪)
  3. Glacial Ice (数年)

时间追溯方法

由于积雪时的温度不同,因此冰层中会以年为单位周期变化,通过计数层数即可获得某一冰层的所属年代。
冰层

历史温度研究方法

大气中${}^{18}O/{}^{16}O$比值与温度密切相关,因此通过测量冰层中相应位置的同位素比值即可间接推得当时的温度。
此外,还可以通过类似的方法测得各历史时期的$CO_{2}$浓度。

研究发现

二氧化碳浓度与温度密切相关

历史二氧化碳与温度

由上图可看出,地球历史上,二氧化碳浓度与温度具备密切的相关性。直到近150年,这一规律被打破,大气二氧化碳浓度极具上升。人表示慌得一批⌇●﹏●⌇

与人类

一个公式

$$Increase CO_{2} = Increasing Population + \Delta Emission per Person + Efficiency of CO_{2} Use$$
这个公式也可以转译为:
$$碳排量 = 人口 + 经济 - 科技$$

一个组织

Intergovernmental Panel on Climate Change (IPCC) 制定了一个小目标来限制各国温室气体排放,表示到2050年,全球二氧化碳排放量要卡一半。。这其实等同于将排放量和钱联系起来,给每个国家分一部分排放量,如果多排就要交钱来买。结果已经工业化完的发达国家切走了超过40%的蛋糕,国科大校长老丁表示这不能忍啊,发展中国家的人到底还有没有人权啊ヾ(´・ ・`。)ノ”

气候变暖影响

Good

  • 数据表明温度越高,世界范围战争数量越少
  • 实验表明,温度高时,粮食等植被产量更高

Bad

  • 南方动物(虫子)比植物北迁的快,北方无天敌,植物被虫子吃光
  • 海平面上升,淹没苏州
graph TDA{Climate Change}B[Economy]C[Politic]D[Tech]E[Agriculture]F[Human Health]A --> |influence| EE --> |change| BE --> |change| CB --> |change| CB --> |determine| DC --> |determine| DB --> |influence| FD --> |affect| FD --> AC --> AD --> EE --> |Green Plant| AE --> FF --> E

参考课件:
Climate change - From past to Future - Yi Zou-2019.pdf

Concept introduction

Weather and Climate

Weather refers to the state of the atmosphere in a short period of time, and climate research mainly focuses on the law of atmospheric state in a longer period of time. In short, climate is weather that changes periodically. The climate is regional and closely related to the distribution of land and sea with latitude. In a longer time dimension, we find that the Earth’s climate change also shows significant periodicity.

The temperature changes in the history of the earth

The figure above describes the historical temperature of the earth, which has obvious periodicity. It is worth noting that whenever the global climate warms, it will trigger an explosion of species. But now, it is in a small-scale temperature rise period, and the temperature rise rate is not too abnormal with historical data, so it is impossible to conclusively prove that it is related to human carbon dioxide emissions.

research method

Direct method (research modern)

  1. Record the temperature
  2. Record rainfall (Precipitation)
  3. Research vegetation (Vegetation)
  4. Sea level
  5. Glaciers :: Balance, mainly through the study of the melting and formation of ice sheets

Indirect Method (Research History)

  1. Proxy
  2. Archive e.g. “Ice Core” :: a layered ice lolly specimen extracted from the Ice Sheet

Ice Core layering reasons

After snow cover, over time, snow cover will experience the following states:

  1. Snow (a few hours, the main component is air)
  2. Firn (a few days, snow)
  3. Glacial Ice (several years)

Time tracking method

Because the temperature of snow is different, the ice layer will change periodically in units of years, and the age of a certain ice layer can be obtained by counting the number of layers.
冰层

Historical temperature research method

The ratio of ${}^{18}O/{}^{16}O$ in the atmosphere is closely related to temperature. Therefore, the current temperature can be indirectly inferred by measuring the isotope ratio of the corresponding position in the ice layer.
In addition, the concentration of $CO_{2}$ in each historical period can also be measured by a similar method.

The study found

History of carbon dioxide and temperature

As can be seen from the above figure, in the history of the earth, the concentration of carbon dioxide has a close correlation with temperature. Until the past 150 years, this rule was broken, and the concentration of atmospheric carbon dioxide increased dramatically. People expressed panic ⌇●﹏●⌇

With humans

A formula

$$Increase CO_{2} = Increasing Population + \Delta Emission per Person + Efficiency of CO_{2} Use$$
This formula can also be translated as:
$$Carbon emissions = population + economy-technology$$

An organization

The Intergovernmental Panel on Climate Change (IPCC) has set a small goal to limit greenhouse gas emissions in various countries, stating that by 2050, global carbon dioxide emissions will have to be half. . In fact, this is equivalent to linking emissions with money, giving each country a portion of the emissions, and paying for more emissions. As a result, the industrialized developed countries cut away more than 40% of the cake. The president of the National University of Science and Technology, Lao Ding, said that this is unbearable. Do people in developing countries have human rights? ヾ(´・ ・`。)ノ”

Climate warming impact

Good

  • Data shows that the higher the temperature, the fewer wars worldwide
  • Experiments show that when the temperature is high, the yield of vegetation such as grain is higher

Bad

  • Southern animals (bugs) move northward faster than plants. There are no natural enemies in the north, and plants are eaten up by bugs.
  • Sea level rises, flooding Suzhou
graph TDA{Climate Change}B[Economy]C[Politic]D[Tech]E[Agriculture]F[Human Health]A --> |influence| EE --> |change| BE --> |change| CB --> |change| CB --> |determine| DC --> |determine| DB --> |influence| FD --> |affect| FD --> AC --> AD --> EE --> |Green Plant| AE --> FF --> E

Reference courseware:
Climate change-From past to Future-Yi Zou-2019.pdf

]]>
thoughts environment climate
工程电磁学 /notes/electromagnetism.html

麦克斯韦大法好!!

Maxwell Dafa is good! !

先供上麦克斯韦方程 膜拜膜拜( o=^•ェ•)o

$$
\begin{eqnarray}
\nabla\cdot\vec{E} &=& \frac{\rho}{\varepsilon_0} \
\nabla\cdot\vec{B} &=& 0 \
\nabla\times\vec{E} &=& -\frac{\partial B}{\partial t} \
\nabla\times\vec{B} &=& \mu_0\left(\vec{J}+\varepsilon_0\frac{\partial E}{\partial t} \right)
\end{eqnarray}
$$


第一话 - 高斯生库伦

  • 假设空间中两点电荷$Q_{1}$,$Q_{2}$,相距d,欲求其相互作用的电场力。
  • 现以$Q_{1}$为圆心,$d$为半径做球。根据高斯law可知球面上的电通量只与球内电荷量有关,本例中为$\frac{Q_{1}}{\varepsilon_0}$。
  • 将上式中电通量除以求表面积可得电场强度$\frac{Q_{1}}{4\pi d^{2}\varepsilon_0}$
  • 场强乘以$Q_{2}$即可得库仑力$\frac{Q_{1}Q_{2}}{4\pi d^{2}\varepsilon_0}$
  • 令$k=\frac{1}{4\pi \varepsilon_0}$整理得
    $$F = \frac{k Q_{1}Q_{2}}{d^{2}}$$
    证毕

第二话 - 高斯金箍棒

  • 假设一均匀带电长度正无穷细杆,电荷密度为$\lambda$,求距其$d$处场强。
  • 绕杆画一个过待求点的圆柱,设高为$x$。
  • 由于杆长无限,圆柱两底面电场被抵消。
  • 圆柱侧面积为$2\pi dx$
  • 圆柱内电荷量为$\lambda x$
  • 引入高斯,得
    $$
    2\pi dxE = \frac{\lambda x}{\varepsilon_{0}}
    $$
    整理得
    $$
    E = \frac{\lambda}{2\pi d\varepsilon_{0}}
    $$
    证毕

高斯球球球

  • 首先要有一个带电小球,电量$Q$,想求其外部距其圆心$d$处场强。
  • 然后可列式
    $$
    4\pi d^2 E = \frac{Q}{\varepsilon_0}
    $$
    整理得
    $$
    E = \frac{Q}{4\pi \varepsilon_0 d^2}
    $$

高斯大面

  • 首先有一个均匀带电无穷面,带电面密度$\rho$,欲求距其$d$的点场强。
  • 以无穷面为中央横截面,做一个底面圆心为待求点的圆柱,半径为$r$。
  • 由于电场线皆平行,只有两个底面有电场线穿过。
  • 可列式
    $$
    2\pi r^2 E = \frac{\rho \pi r^2}{\varepsilon_0}
    $$
    整理得
    $$
    E = \frac{\rho}{2\varepsilon_0}
    $$
    完事

To Be Continued…

First offer to Maxwell’s equation, worship ( o=^•ェ•)o

$$
\begin{eqnarray}
\nabla\cdot\vec{E} &=& \frac{\rho}{\varepsilon_0} \
\nabla\cdot\vec{B} &=& 0 \
\nabla\times\vec{E} &=& -\frac{\partial B}{\partial t} \
\nabla\times\vec{B} &=& \mu_0\left(\vec{J}+\varepsilon_0\frac{\partial E}{\partial t} \right)
\end{eqnarray}
$$


Chapter One-Gossian Cullen

  • Suppose two electric charges $Q_{1}$ and $Q_{2}$ in space are separated by d, and the electric field force they want to interact with.
  • Now take $Q_{1}$ as the center of the circle and $d$ as the radius to make the ball. According to the Gaussian law, the electric flux on the sphere is only related to the amount of charge in the sphere, which is $\frac{Q_{1}}{\varepsilon_0}$ in this example.
  • Divide the electric flux in the above formula by the surface area to get the electric field intensity $\frac{Q_{1}}{4\pi d^{2}\varepsilon_0}$
  • Field strength is multiplied by $Q_{2}$ to get Coulomb force $\frac{Q_{1}Q_{2}}{4\pi d^{2}\varepsilon_0}$
  • Let $k=\frac{1}{4\pi \varepsilon_0}$ to get
    $$F = \frac{k Q_{1}Q_{2}}{d^{2}}$$
    Completed

Chapter 2-Gauss Golden Cudgel

  • Assuming that a uniformly charged length is positively infinitely thin and the charge density is $\lambda$, find the field strength $d$ away from it.
  • Draw a cylinder around the rod and set the height to be $x$.
  • Due to the infinite length of the rod, the electric fields on the two bottom surfaces of the cylinder are cancelled.
  • The cylindrical side area is $2\pi dx$
  • The amount of charge in the cylinder is $\lambda x$
  • Introduce Gaussian, get
    $$
    2\pi dxE = \frac{\lambda x}{\varepsilon_{0}}
    $$
    Organized
    $$
    E = \frac{\lambda}{2\pi d\varepsilon_{0}}
    $$
    Completed

Gauss Ball Ball

  • First, there must be a charged ball with electricity $Q$, and I want to find the field strength at the distance of $d$ from the center of the ball.
  • Then columnable
    $$
    4\pi d^2 E = \frac{Q}{\varepsilon_0}
    $$
    Organized
    $$
    E = \frac{Q}{4\pi \varepsilon_0 d^2}
    $$
    complete

Gaussian Noodles

  • First, there is a uniformly charged infinite surface, the charged surface density is $\rho$, and the field strength of the point $d$ is desired.
  • Using the infinite plane as the central cross section, make a cylinder with the center of the bottom surface as the point to be found, and the radius is $r$.
  • Since the electric field lines are all parallel, only two bottom surfaces have electric field lines passing through.
  • Columnable
    $$
    2\pi r^2 E = \frac{\rho \pi r^2}{\varepsilon_0}
    $$
    Organized
    $$
    E = \frac{\rho}{2\varepsilon_0}
    $$
    Finished

To Be Continued…

]]>
notes maxwell
总结一下我的代码风格 /tech/my-code-style.html

我的代码风格大致有以下几种情况:组织中追随组织领导,公司里老板说的都对,学校里大佬教的都好╮(╯▽╰)╭ 仅其它一些自己的开源小项目则遵循以下风格→_→

My coding style is roughly in the following situations: I follow the leadership of the organization, the boss in the company is right, and the big guys in the school teach well ╮(╯▽╰)╭ Only some other small open source projects of their own follow The following style→_→

关于强迫症

首先说好,

四个空格的Tab缩进大法好!!!
四个空格的Tab缩进大法好!!!
四个空格的Tab缩进大法好!!!

大括号不换行!!!
大括号不换行!!!
大括号不换行!!!

关于命名

命名以让别人一眼就能明白为佳,理想中看你的代码就像读一首英语小诗般惬意 ::aru:insidious::

常/变量命名

编译器常量全大写,字符间用单下划线连接。如:

1
#define WIFI_PASSWD 12345

变量基本采用小驼峰命名,规则是单词之间直接连接(无需下划线),第一个单词全小写,之后的单词首字母大写。如:

1
String usrName = "IoTgod";

频繁调用的变量名称不易过长,但却要表意清晰。
要实现这一点,可以尝试部分省略单词中的非首字母元音,如 user 可以简写为 usr,password 可省略为 passwd 或 psswd。但简化后的名字仍需容易辨识。

全局变量使用 g_ 加变量名称命名,如

1
global int g_isLightOn = 0;

局部静态变量使用 s_ 加变量名称,如

1
static int s_errorCounter = 0;

常量变量,命名与普通变量一致,如

1
const float pi = 3.14159265;

函数命名

函数命名技巧偷师自大名鼎鼎的Nginx,并在其基础上稍有变动。
基本法则为 小写标签名+__(双下划线)+小写动词+小写名词()
名词与名词间用单下滑线链接。
例如:

1
function db__get_usr_info();

其中db意为Database, 提示这个函数属于数据库操作标签,作用是获取用户信息。

如果你不需要标签(比如在一些面向对象的语言中),你可以肆意省略标签。如:

1
2
3
function get_usr_info();
//or
function db::get_usr_info();

与变量命名不同,函数命名不必要很短,以表达清楚函数功能为目标

关于注释

其实如果能把变量函数命名做好,便不需要什么注释了,但遗憾的是,,我们还是不得不注释。。

文件注释

文件注释主要用于声明一些文件功能,分类名,文件名,版权等信息,一个样式如下:

1
2
3
4
5
6
7
8
9
/**
* cookie支持 #文件功能
*
* @category typecho #文件所属的分类
* @package Cookie #文件名称
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org) #作者及版权信息
* @license GNU General Public License 2.0 #开源协议
* @version 2.1.1 #版本
*/

类注释

类注释用于声明类的一些基本信息,如类功能,作者姓名、所属分类、所属文件。例如:

1
2
3
4
5
6
7
/**
* 数据库支持 #功能说明
*
* @author qining #作者
* @category typecho #所属分类
* @package Cookie #所在文件名称
*/

函数注释

函数注释在函数前,主要包含函数功能,函数修饰符,其各参数的类型、名称、以及文字说明,返回值的类型及文字说明。

1
2
3
4
5
6
7
8
/**
* 获取指定的COOKIE值 #函数功能
*
* @access public #函数修饰符,即函数是否可被外界访问
* @param string key 指定的参数 #参数1,类型为string, 名称为key, 功能描述为 指定的参数
* @param string default 默认的参数 #参数2,类型string,名称default,功能描述 默认的参数
* @return int #返回整形返回值
*/

一些小细节

  • 赋值等号两边要有空格,如b = c; b = 15;

About obsessive-compulsive disorder

First of all,

The four-space Tab indentation is great! ! !
The four-space Tab indentation is great! ! !
The four-space Tab indentation is great! ! !

The braces do not wrap! ! !
The braces do not wrap! ! !
The braces do not wrap! ! !

About naming

Name it so that others can understand it at a glance. Ideally, looking at your code is as comfortable as reading a little English poem ::aru:insidious::

Often/variable naming

The compiler constants are all uppercase, and the characters are connected by a single underscore. Such as:

1
#define WIFI_PASSWD 12345

Variables are basically named with small camels. The rule is to connect words directly (without underscores), the first word is all lowercase, and the first letter of subsequent words is capitalized. Such as:

1
String usrName = "IoTgod";

Variable names that are frequently called should not be too long, but they should be clear.
To achieve this, you can try to partially omit non-initial vowels in words. For example, user can be abbreviated as usr, and password can be omitted as passwd or psswd. But the simplified name still needs to be easy to recognize.

Global variables are named using g_ plus the variable name, such as

1
global int g_isLightOn = 0;

Local static variables use s_ plus the variable name, such as

1
static int s_errorCounter = 0;

Constant variables, naming the same as ordinary variables, such as

1
const float pi = 3.14159265;

Function Naming

The function naming technique is stolen from the famous Nginx and slightly changed on its basis.
The basic rule is lowercase label name+__ (double underscore)+lowercase verb+lowercase noun()
Use a single underline link between nouns and nouns.
E.g:

1
function db__get_usr_info();

Among them, db means Database, prompting that this function belongs to the database operation label, and its function is to obtain user information.

If you don’t need tags (such as in some object-oriented languages), you can arbitrarily omit tags. Such as:

1
2
3
function get_usr_info();
//or
function db::get_usr_info();

Different from variable naming, function naming need not be short, aiming at expressing clearly the function function

About comments

In fact, if you can name the variable function well, you don’t need any comments, but unfortunately, we still have to comment. .

File Notes

File comments are mainly used to declare some file functions, category names, file names, copyright and other information. A style is as follows:

1
2
3
4
5
6
7
8
9
/**
* cookie support #file function
*
* @category typecho #The category to which the file belongs
* @package Cookie #File name
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org) #Author and copyright information
* @license GNU General Public License 2.0 #Open source agreement
* @version 2.1.1 #Version
*/

Class comments

Class annotations are used to declare some basic information of the class, such as class function, author name, classification, and file. E.g:

1
2
3
4
5
6
7
/**
* Database support #Function description
*
* @author qining #author
* @category typecho #Category
* @package Cookie #File name
*/

Function comments

The function comment before the function mainly includes the function function, the function modifier, the type, name, and text description of each parameter, and the type and text description of the return value.

1
2
3
4
5
6
7
8
/**
* Get the specified COOKIE value #Function function
*
* @access public #Function modifier, that is, whether the function can be accessed by the outside world
* @param string key specified parameter #Parameter 1, type is string, name is key, function description is specified parameter
* @param string default Default parameters #Parameter 2, type string, name default, function description Default parameters
* @return int #Return the integer return value
*/

Some small details

  • There must be spaces on both sides of the equal sign, such as ``b = c; b = 15;’’
]]>
tech cpp
Centos7脚本一键安装Typecho /tech/centos7-auto-install-typecho.html

一时兴起,帮番茄同学(@番茄树)配置了博客,在此记录一下流程

On a whim, help Pomodoro (@tomatotree) configure a blog, and record the process here

先觉条件

  • 只测试过阿里云腾讯云Centos7学生机
  • 系统很干净,最好刚重装过
  • 使用root权限

一键安装

无聊写了一个一键搭建脚本,使用如下指令运行(详见github

1
$ wget https://yimian-setup.obs.myhwclouds.com/sh/auto.sh && sh auto.sh

如果不出意外安装将自动进行,安装最后需要你手动输入如下数据库配置指令。

1
2
3
4
use mysql
UPDATE user SET Password = '你的密码' WHERE User = 'root';
create database typecho;
quit

轻松开始

安装完成后,使用你的浏览器访问以下链接

1
http://你的服务器ip

根据页面提示安装typecho
大部分内容保持默认即可,只需填写:

  • 数据库密码(你刚才设置的)
  • 管理员用户名
  • 管理员登录密码
  • 管理员邮箱地址

自定义域名配置

首先在你的域名服务商(腾讯云,阿里云)将你的域名A解析到你的服务器ip
打开服务器上nginx配置文件

1
$ vi /etc/nginx/nginx.conf

将文件中第42,47,48行的 your_domain 替换成你自己的域名即可。
重启nginx服务

1
2
$ systemctl nginx -t # nginx.conf 语法检查
$ systemctl restart nginx # 重启nginx

然后大约经过10分钟,你就可以通过https://你的域名访问typecho了

https配置

如果你任然无法访问,而是被引导到一个备案页面,那么你可能需要使用https

法一

配置自动续费ssl证书可参考我的另一篇文章(Centos7下 Nginx 配置ssl证书自动续期)

法二

  • 从腾讯云等申请并下载证书,然后上传nginx文件夹中的两个证书到服务器

  • 去掉前面提到nginx.conf中第39,47-54行注释

  • 将第47,48行后半部分分别换成你自己.crt和.key证书文件的地址

  • systemctl restart nginx重启nginx

  • 使用浏览器访问https://你的域名


参考链接:
https://www.cnblogs.com/blibli/p/7286786.html
https://blog.csdn.net/weixin_41919236/article/details/84878430
https://www.cnblogs.com/moxiaoan/p/5683743.html
https://www.cnblogs.com/lalalagq/p/9979068.html?tdsourcetag=s_pcqq_aiomsg

A priori condition

  • Only tested Alibaba Cloud Tencent Cloud Centos7 student machine
  • The system is very clean, preferably just reinstalled
  • Use root privileges

A key installation

Boring to write a one-click build script, use the following commands to run (see github for details)

1
$ wget https://yimian-setup.obs.myhwclouds.com/sh/auto.sh && sh auto.sh

If nothing happens, the installation will proceed automatically. At the end of the installation, you need to manually enter the following database configuration instructions.

1
2
3
4
use mysql
UPDATE user SET Password ='Your password' WHERE User ='root';
create database typecho;
quit

Easy start

After the installation is complete, use your browser to visit the following link

1
http://your server ip

Install typecho according to the page prompt
Leave most of the content as default, just fill in:

  • Database password (the one you just set)
  • Administrator username
  • Administrator login password
  • Administrator email address

Custom domain configuration

First, resolve your domain name A to your server ip at your domain name service provider (Tencent Cloud, Alibaba Cloud)
Open the nginx configuration file on the server

1
$ vi /etc/nginx/nginx.conf

Just replace your_domain on lines 42, 47, and 48 in the file with your own domain name.
Restart nginx service

1
2
$ systemctl nginx -t # nginx.conf syntax check
$ systemctl restart nginx # restart nginx

Then after about 10 minutes, you can access typecho via https://your domain name

https configuration

If you are still unable to access and are directed to a filing page, then you may need to use https

Method One

For configuring automatic renewal of ssl certificate, please refer to my other article (Nginx under Centos7 configure ssl certificate automatic renewal)

Method two

  • Apply for and download a certificate from Tencent Cloud, etc., and then upload the two certificates in the nginx folder to the server

  • Remove the comments on lines 39, 47-54 in nginx.conf mentioned earlier

  • Replace the second half of lines 47 and 48 with the addresses of your own .crt and .key certificate files respectively

  • systemctl restart nginx restart nginx

  • Use a browser to visit https://your domain name


Reference link:
https://www.cnblogs.com/blibli/p/7286786.html
https://blog.csdn.net/weixin_41919236/article/details/84878430
https://www.cnblogs.com/moxiaoan/p/5683743.html
https://www.cnblogs.com/lalalagq/p/9979068.html?tdsourcetag=s_pcqq_aiomsg

]]>
tech php centos7 typecho
C++建库中遇到的坑 /tech/cpp-summary.html

由于学校课程安排,作为一只电气狗第一次正经的开始搞Cpp ::aru:shy::
特记录一些建库过程遇到的坑,,→_→

Due to the school curriculum, as an electric dog, it is the first time to start doing Cpp .
Specially record some pits encountered in the process of building a database, →_→

关于.h文件

作为头文件,.h中一般放有相应类及函数的声明。
一个典型的.h文件如下:(FileName: yimian.h)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef YIMIAN_H //防止本文件被多次编译
#define YIMIAN_H //'YIMIAN_H'的值需自定义

//.h中可能用到的lib
#include<iostream>
#include<string>

using namespace std; //使用std命名空间,这样下面就可以不用写如std::cout了

//声明yimian类
class yimian{
public: //公共域(可外界直接调用)
void hi();
static string version;

private: //私有(不对外公开)
};

#endif //与文件开头防多次编译相对应

为了安全起见,函数以及变量的初始化一般不放在.h文件中进行。而是习惯于建一个新的同名.cpp文件。
下面是一个与上午相对应的.cpp文件示例:(FileName: yimian.cpp)

1
2
3
4
5
6
7
#include"yimian.h" //需要指向yimian.h

string yimian::version = "Version 0.0.1"; //为字符串变量赋值

void yimian::hi(){ //定义yimian类中hi()函数内容
cout << "Hellow Yimian~" << endl; //输出"Hellow Yimian~\n"到屏幕
}

有了以上文件,一个简单的C++库就建成了φ( ̄∇ ̄o)
于是我们新建一个test.cpp文件用来放置main()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<iostream> //要用到的lib声明
#include<stdio.h>
#include"yimian.h" //引入自定义lib

using namespace std; //使用std命名空间

int main(){
yimian $; //定义一个名字为$的新yimian类

$.hi(); //调用yimian类中hi()函数
cout << $.version<< endl; //将yimian类version变量输出到屏幕

return 0; //主函数结束
}

然后便可以愉快的使用g++编译啦,指令如下:(win如何搭建GNU环境)

1
$ g++ test.cpp yimian.cpp -o [目标文件的名称]

之后命令行启动编译好的程序 (什么是命令行⌇●﹏●⌇)

1
$ ./目标文件名称.exe

如你所料,以上程序的运行结果为:

Hellow Yimian~
Version 0.0.1


::aru:meditation::

  • 头文件中声明定义好的类貌似一定要在main()中实例化(调用)才行,不然会报错

总结一下类相关知识

类访问修饰符

  • public: 类内外皆可访问的内容
  • private: 类外不可访问,仅可自己和友元访问,子类不可访问
  • protected: 外部不可访问,自己、友元和子类可访问

特殊函数类型

  • 构造函数: 每次创建对象时会执行,即初始化

    1
    2
    3
    4
    5
    6
    7
    8
    9
    class Line{
    public:
    void setLength( double len );
    double getLength( void );
    Line(); // 这是构造函数

    private:
    double length;
    };
  • 析构函数: 删除对象时执行的函数,即善后

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    class Line{
    public:
    void setLength( double len );
    double getLength( void );
    Line(); // 这是构造函数声明
    ~Line(); // 这是析构函数声明

    private:
    double length;
    };
  • 拷贝构造函数: 实现复制对象时同一类对象间传参

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    class Line{
    public:
    int getLength( void );
    Line( int len ); // 简单的构造函数
    Line( const Line &obj); // 拷贝构造函数
    ~Line(); // 析构函数

    private:
    int *ptr;
    };
    ·········
    Line::Line(const Line &obj){
    cout << "调用拷贝构造函数并为指针 ptr 分配内存" << endl;
    ptr = new int;
    *ptr = *obj.ptr; // 拷贝值
    }
    ·········
    int main( ){
    Line line1(10);

    Line line2 = line1; // 这里也调用了拷贝构造函数

    return 0;
    }
  • 构造与拷贝构造区别:

    1
    2
    A x(2);  //直接初始化,调用构造函数
    A y = x;  //拷贝初始化,调用拷贝构造函数

友元函数/类

  • 友元:友元就像老邻居啦,家里东西随便拿
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    class INTEGER{
    friend void Print(const INTEGER& obj);//声明友元函数
    };

    void Print(const INTEGER& obj){
    //函数体
    }

    void main(){
    INTEGER obj;
    Print(obj);//直接调用
    }

内联函数

  • 总之行数很少,功能很简单,没有循环和开关语句,想提高函数效率,就用内联(╯‵□′)╯︵┴─┴
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    inline int Max(int x, int y){
    return (x > y)? x : y;
    }

    // 程序的主函数
    int main(){
    cout << "Max (20,10): " << Max(20,10) << endl;
    cout << "Max (0,200): " << Max(0,200) << endl;
    cout << "Max (100,1010): " << Max(100,1010) << endl;
    return 0;
    }

this指针

  • 类似js中this,指向参数对象本身

To Be Continued..

About .h files

As a header file, there are generally declarations of corresponding classes and functions in .h.
A typical .h file is as follows: (FileName: yimian.h)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef YIMIAN_H //Prevent this file from being compiled multiple times
#define YIMIAN_H //The value of'YIMIAN_H' needs to be customized

//Lib may be used in.h
#include<iostream>
#include<string>

using namespace std; //Use the std namespace, so you don’t need to write std::cout below

//Declare the yimian class
class yimian{
public: //Public domain (can be directly called by the outside world)
void hi();
static string version;

private: //Private (not public)
};

#endif //Correspond to the anti-multiple compilation at the beginning of the file

For safety, the initialization of functions and variables is generally not carried out in the .h file. Instead, I am used to creating a new .cpp file with the same name.
The following is an example of a .cpp file corresponding to the morning: (FileName: yimian.cpp)

1
2
3
4
5
6
7
#include"yimian.h" //Need to point to yimian.h

string yimian::version = "Version 0.0.1"; //Assign a value to a string variable

void yimian::hi(){ //Define the content of the hi() function in the yimian class
cout << "Hellow Yimian~" << endl; //Output "Hellow Yimian~\n" to the screen
}

With the above files, a simple C++ library is built φ( ̄∇ ̄o)
So we create a new test.cpp file to place main()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<iostream> //lib declaration to be used
#include<stdio.h>
#include"yimian.h" //Introduce custom lib

using namespace std; //Use std namespace

int main(){
yimian $; //Define a new yimian class named $

$.hi(); //Call the hi() function in the yimian class
cout << $.version<< endl; //Output the yimian class version variable to the screen

return 0; //End of main function
}

Then you can use g++ to compile happily, the instructions are as follows: (How to build a GNU environment in win)

1
$ g++ test.cpp yimian.cpp -o [name of target file]

Then start the compiled program from the command line (what is the command line ⌇●﹏●⌇)

1
$ ./Target file name.exe

As you might expect, the result of the above program is:

Hellow Yimian~
Version 0.0.1


Pit ::aru:meditation::

  • The defined class declared in the header file must be instantiated (called) in main(), otherwise an error will be reported

Class access modifier

  • public: Content accessible inside and outside the class
  • private: not accessible outside the class, only accessible by yourself and friends, not accessible by subclasses
  • protected: Inaccessible from outside, accessible by yourself, friends and subclasses

Special function types

  • Constructor: It will be executed every time an object is created, that is, initialization

    1
    2
    3
    4
    5
    6
    7
    8
    9
    class Line{
    public:
    void setLength( double len );
    double getLength( void );
    Line(); // This is the constructor

    private:
    double length;
    };
  • Destructor: The function executed when the object is deleted, that is, the aftermath

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    class Line{
    public:
    void setLength( double len );
    double getLength( void );
    Line(); // This is the constructor declaration
    ~Line(); // This is the destructor declaration

    private:
    double length;
    };
  • Copy constructor: Transfer parameters between objects of the same type when copying objects

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    class Line{
    public:
    int getLength( void );
    Line( int len ​​); // simple constructor
    Line( const Line &obj); // copy constructor
    ~Line(); // Destructor

    private:
    int *ptr;
    };
    ·········
    Line::Line(const Line &obj){
    cout << "Call the copy constructor and allocate memory for the pointer ptr" << endl;
    ptr = new int;
    *ptr = *obj.ptr; // copy value
    }
    ·········
    int main( ){
    Line line1(10);

    Line line2 = line1; // The copy constructor is also called here

    return 0;
    }
  • The difference between construction and copy construction:

    1
    2
    A x(2);  //Direct initialization, call the constructor
    A y = x;  //Copy initialization, call the copy constructor

Friend function/class

  • Youyuan: Youyuan is like an old neighbor, you can take whatever you want at home
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    class INTEGER{
    friend void Print(const INTEGER& obj);//Declare friend function
    };

    void Print(const INTEGER& obj) {
    //Function body
    }

    void main(){
    INTEGER obj;
    Print(obj);//Call directly
    }

Inline functions

  • In short, the number of lines is small and the function is very simple. There are no loops and switch statements. If you want to improve the efficiency of the function, use inline (╯‵□′)╯︵┴─┴
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    inline int Max(int ​​x, int y){
    return (x> y)? x: y;
    }

    // The main function of the program
    int main(){
    cout << "Max (20,10): "<< Max(20,10) << endl;
    cout << "Max (0,200): "<< Max(0,200) << endl;
    cout << "Max (100,1010): "<< Max(100,1010) << endl;
    return 0;
    }

this pointer

  • Similar to this in js, pointing to the parameter object itself

To Be Continued..

]]>
tech cpp
2018 – 年度总结 /life/2018-retrospect-and-prospect.html

白驹过隙,挥别2018,走向2019..

作为完全独立生活的第一年,失去约束,放飞自我,狠狠地狂野了一把。然后,竟然还意外地做成了不少事情..

In the blink of an eye, I bid farewell to 2018 and march towards 2019..
As the first year of a completely independent life, I lost my inhibitions and let myself go wild.Then, unexpectedly also accomplished many things unexpectedly..

代码方面:

  • 最大的收获是发现并加入了Github
  • 掌握了不少新语言,嗯数一数有C, C++, PHP, JavaScript, vbs, HTML, CSS, Python, shell, dos, Matlab (大致是按照熟练顺序吧)
  • 经营着7台服务器,一台win2012在上海(第一台),三台cent在悉尼,亚特兰大和伦敦,国内两台Cent 在深圳和北京,再加上宿舍里的ubuntu树莓派,哈哈哈,,,

上半年

  • 上半年帮爸爸搞万宗商业,通过ftp连上海服务器,勉强搞了个公司网站出来,可惜暑假被‘拉脱维亚’(至少IP是)的黑客朋友搞掉了,从此弃坑windows
  • 5,6月份尝试搞过一个Steel15高中同学平台,但因为企划模式不切实际等原因,进度一直搁置,最终也在8月份一起被黑掉了(从此养成勤备份好习惯( •̀ ω •́ )y)
  • 7月在欧朗研发部时和组员一起做了一个基于微信小程序的学生电子ID卡,我在其中算是担任后端工程师吧,并且最后还在学校和企业大佬面前做了项目答辩哦
  • 暑假在家中用wifiduino搞了两个项目,太阳能自动加水和走廊灯的自感应化,设计和采购材料时接触了一些水管和电线的知识。据说目前板子仍然运行良好哦

9,10月份

  • 9月份的话,开始进军Linux, 通过Vultr搞了不少服务器做尝试,搭建了私人的ss服务器,自此科学上网
  • 9月份,基于开源的NextCloud在伦敦docker搭建了第一个私人网盘,一直使用至今,只是国内访问速度,,( ̄▽ ̄)”,,希望去英国后能好一点
  • 9月份,重建了宿舍的IoT系统,目前虽然出过几次bug但总体而言运行良好
  • 10月份,不爽于诸多被禁番剧,着手搭建第一代Yimian Video视频平台
  • 10月份,多次尝试搞Linux Mail服务,均失败,至今沿用5月份的Windows Mail
  • 10,11月份,C语言as搞了一个数据联网同步,有背景音乐的石头剪刀小游戏
  • 10月份,开发了一个短信验证码login系统
  • 10月,基于shell以及一系列Linux软件结合Nginx搞了一个ss服务器的端口流量管理和统计系统,然后对同学朋友开放帮助他们科学上网(不过北京朋友反应上不了,大概是北京的墙比较高吧,望今年通过增添混淆解决)

11,12月份

  • 11月,跟着北大一个网课,尝试搞Python TensorFlow的图像识别,然后成功半途而废掉了。。不过终于对AI有了实践性的了解,理解到目前的神经网络本质是用一坨多项式去fit一个复杂的自然函数
  • 11月,入手了人生第一台树莓派,搭配上红外摄像头,目前呢,可以提供流媒体视频直播服务,,
  • 12月,尝试开发一个上课自动签到的微信小程序,结果被ICE强大的限制算法降伏,,失败
  • 12月,基于Wordpress搭建了一个加载慢慢的Blog平台,
  • 12月,偶然发现了frp,成功实现服务内网穿透,并将其应用到树莓派以及我的PC上
  • 12月,和C语言小组5人一起搞了一个酒店管理系统,然后我最大的contribution是从零搭建了一个底层数据库系统,处理速度,额,炒鸡慢,尽管已经引入了哈希算法..
  • 12月底,入了Github的坑,接触到了DIYgod大神
  • 12月底,基于Dplayer,改良Yimian Video至第三代,支持hls,搭建了弹幕服务器,增添了弹幕功能,通过第三方API连接B站弹幕
  • 12月底,基于Aplayer,开发出基于php控制的网页音乐播放插件,可直接播放网易云指定歌单
  • 12月底,改良以往login页面,增添原创的防robot算法,提升为全动态页面
  • 12月底,接触pjax,YimianVideo, 视频列表试点应用,并开始着手全站动态化改造
  • 12月底,入手咕咕机,利用其API每晚自动打印今日站点访问统计

学习方面:

  • 英语方面EAP课程结业,雅思互换的话大概6.5分吧,毕竟也全英授课一年半了
  • 文科方面历史法律学的很开心,考得嘛,,不置评论
  • 年初恶补了基础心理学,社会心理学,发展心理学,变态心理学,心理咨询学,心理测量学,本打算参加心理咨询师考试的,结果最终因为年龄不到要求挺遗憾的,但是学到了这么多喜欢的东西蛮开心的
  • 电路嘛,起码能做基础的直流交流分析了
  • 11月日常物理建模,然后日常最后建得解不出来..
  • 选修了城市规划的课程,虽然给均分造成的影响不忍直视但是,,现在看城市越来越有感觉了哈
  • 社团嘛参加了Infoco凭关系进了管理层,然后一直水偶尔参个会出点主意之类的

研究方面:

研究方面,主要搞了三个。上半年调查了Personality trait 对Second Language Acquisition 的影响,最终发现只有内倾型和Grammar优势有着significant 相关性。暑假在欧朗期间搞了关于物联网行业的一个调查,发现业内存在显著的客制化和去中心化发展趋势。下半年在暑期结论的基础上研究了一下Fog Computing, 基本上读遍了近两年IEEE上关于Fog 的文章,愈发坚信未来10年互联网云雾结合的趋势。一个感觉,中国会是这一场互联网架构变革中的关键

生活方面

番剧

  • 追番56部,分别是

    《 刀剑乱舞-花丸 》
    《 少年锦衣卫 》
    《 四月是你的谎言 》
    《 摇曳露营 》
    《 月色真美 》
    《 擅长捉弄的高木同学 》
    《 CLANNAD 》
    《 KANON 》
    《 AIR 》
    《 可塑性记忆 》
    《 冰菓 》
    《 Charlotte 》
    《 龙与虎 》
    《 星之梦 》
    《 Angel Beats 》
    《 斩 赤红之瞳 》
    《 罪恶王冠 》
    《 言叶之庭 》
    《 樱花庄的宠物女孩 》
    《 未闻花名 》
    《 刀剑神域 》
    《 凉宫春日的消失 》
    《 某科学的超电磁炮 》
    《 紫罗兰永恒花园 》
    《 萤火之森 》
    《 声之形 》
    《 中二病也要谈恋爱 》
    《 缘之空 》
    《 东京喰种 》
    《 实力主义至上教室 》
    《 工作细胞 》
    《 绯弹的亚里亚 》
    《 从零开始的异世界生活 》
    《 埃罗芒阿老师 》
    《 我的妹妹不可能有这么可爱 》
    《 我的青春恋爱物语果然有问题 》
    《 白色相簿2 》
    《 境界的彼方 》
    《 游戏人生 》
    《 citrus 》
    《 命运石之门 》
    《 未来时在做什么?有没有空?可以来拯救吗? 》
    《 路人女主的养成方法 》
    《 fate 》
    《 进击的巨人 》
    《 玉子市场 》
    《 小林家的龙女仆 》
    《 吹响吧,上低音号 》
    《 夏目友人帐 》
    《 妖精森林的小不点 》
    《 银魂 》
    《 干物妹小埋 》
    《 魔法禁书目录 》
    《 吹响吧,上低音号第二季 》
    《 利兹与青鸟 》
    《 轻音少女第一季 》

  • 观看电视剧:《lie to me》《硅谷》《谈判官》《翻译官》《非自然死亡》

调情易趣

  • Bilibili看视频425小时,大概刷便了Jack Ma的演讲,最痴迷up主竟然是环球时报。。
  • 云村听歌1017小时
  • 倾听了一场交响音乐会
  • 旅游五次,分别在曲阜,太湖,苏州拙政园,济南,南京
  • 去过一次酒吧
  • 三次卡拉OK
  • 回老家探望姥姥,爷爷,陪表妹外甥玩
  • 学车,科一,科二,无证驾驶从方特到山口来回
  • 看了不少电影,就不数了
  • 后期更加注重生活和头发,,日均2盒奶,渐渐跟上早点

经济方面

  • 项目开销渐长,18年花销1000+,但仍可控
  • 奖学金补助
  • 比较稳健的投资策略,平均能把七日年化搞到4+,最高的时候到过7
  • 现金流控制还可以,一年内没有发生过现金紧张情况
  • 然后发现如果只是生活的话想多花点钱真的要很努力才行

会展:

  • 参加中国开发者大会,入坑开源
  • 赴上海参加世界移动大会,一窥中国物联网未来

反思:

  • 熬夜有点小多,目测下半学期平均1点半睡觉
  • 通宵次数略多,大概有15次,其中3次通宵时间超过30小时
  • 运动少,只游过一次泳,没怎么跑过步
  • 经常起不来所以不吃早餐
  • 编起程来生活节奏就乱掉,太过急切的追求功能完善与完美
  • 高二下半学期节奏不稳,数学更是基本半学期没怎么学
  • 过多归因于学校课程设置问题,这本身就很有问题

展望2019:

  • 更惬意的生活
  • 更宜人的节奏
  • 更真诚的人际
  • 2020年Github中国区前100
  • 文体两开花

本文已完结哦(๑•̀ㅁ•́ฅ)

Code:

  • The most rewarding part was discovering and joining Github
  • Master a lot of new languages, including C, C++, PHP, JavaScript, VBS, HTML, CSS, Python, shell, DOS, Matlab (roughly in the order of proficiency)
  • Runs 7 servers, 1 Win2012 in Shanghai (the first), 3 Cent in Sydney, Atlanta, and London, 2 Cent in China in Shenzhen and Beijing, plus Ubuntu Raspberry Pie in my dorm room, hahaha,,,,

The First Half of The Year

  • In the first half of the year, I helped my father to do 10,000 businesses, connected with the Server in Shanghai via FTP, and managed to make a company website. Unfortunately, in the summer vacation, I was lost by the hacker friends in Latvia (at least IP is), so I abandoned the pit of Windows
    • 5 or 6 months trying to make a platform Steel15 high school classmate, but because the planning mode is impractical, the schedule has been put on hold, and finally in August hacked together (from a good habit to pay close attention to regular backups (, ̀ omega, ́) y)
    • in July, when I was in the r&d department of euron, I worked with my team members to make a student electronic ID card based on WeChat small program. I worked as a back-end engineer in the card, and finally I did a project defense in front of the school and enterprise bosses
  • During the summer vacation, I conducted two projects with Wifiduino at home, such as solar energy automatic water addition and self-induction of corridor lights. During the designing and purchasing of materials, I got some knowledge of water pipes and electric wires.It is said that the board is still running well

September and October

  • In September, it started to move into Linux, experimenting with servers through Vultr, setting up a private SS server that has been scientifically connected ever since
  • In September, NextCloud based on open source set up the first private network disk in London Docker. It has been used until now, except for domestic access speed, ~ ~ ~ “, hoping to get better after going to Britain
  • In September, the dormitory IoT system was rebuilt and has been working well despite a few bugs so far
  • In October, frustrated by the number of banned Yimian dramas, the first Yimian Video platform was set up
  • In October, I tried to run Linux Mail service for several times, but failed. So far, I still use The Windows Mail in May
    • In October and November, C language as made a small game of rock scissors with data network synchronization and background music
  • In October, developed an SMS verification code login system
  • In October, based on shell and a series of Linux software combined with Nginx, I built a port traffic management and statistics system for SS server, and then opened it to my classmates and friends to help them access the Internet scientifically (But my friends in Beijing didn’t respond well, maybe the wall in Beijing is relatively high, I hope this year we can solve this problem by adding confusion).

November and December

  • In November, following an online class at Peking University, I tried to engage in image recognition of Python TensorFlow, and then successfully abandoned it halfway. . But finally I have a practical understanding of AI, and understand that the essence of the current neural network is to use a tuft of polynomials to fit a complex natural function
    • In November, I started my life’s first Raspberry Pi with an infrared camera. Currently, it can provide live streaming video services.
    • In December, I tried to develop a WeChat applet for automatic sign-in in class, but failed by ICE’s powerful restriction algorithm.
    • In December, built a blog platform based on Wordpress that loads slowly,
    • In December, I stumbled upon frp, successfully achieved service intranet penetration, and applied it to the Raspberry Pi and my PC
    • In December, I worked on a hotel management system with 5 people in the C language team, and my biggest contribution was to build a bottom-level database system from scratch. The processing speed was slow, even though the hash algorithm had been introduced. .
    • At the end of December, I entered the pit of Github and came into contact with the DIYgod god
    • At the end of December, based on Dplayer, improved Yimian Video to the third generation, supported hls, built a bullet screen server, added a bullet screen function, and connected to station B bullet screen through a third-party API
    • At the end of December, based on Aplayer, a web music player plug-in based on PHP control was developed, which can directly play NetEase Cloud designated playlists
    • At the end of December, improved the previous login page, added original anti-robot algorithm, and upgraded it to a fully dynamic page
    • At the end of December, contacted pjax, YimianVideo, and video list pilot applications, and started the dynamic transformation of the whole site
    • At the end of December, started the Cuckoo machine, using its API to automatically print today’s site visit statistics every night

Learning Aspect:

  • After completing the English EAP course, IELTS exchange is about 6.5 points. After all, it has been taught in English for a year and a half.
    • In the liberal arts, I am very happy in history and law. Well, I don’t comment.
    • I supplemented basic psychology, social psychology, developmental psychology, abnormal psychology, psychological counseling, and psychometrics at the beginning of the year. I planned to take the counselor exam, but I was very sorry because I was under the age requirement. I’m so happy to learn so many things I like
    • Circuits, at least basic DC and AC analysis can be done
    • Daily physical modeling in November, and finally the daily construction can not be solved…
    • I took the course of urban planning, although I can’t bear to look directly at the impact on the equalization, but now I feel more and more feeling about the city.
    • The club joined Infoco and got into the management based on the relationship, and then it was always the occasional meeting to come up with ideas, etc.

Research:

In terms of research, there are mainly three. In the first half of the year, we investigated the impact of the Personality trait on Second Language Acquisition, and finally found that only the introverted type and the Grammar advantage have a significant correlation. During the summer vacation in Oulang, I conducted a survey on the Internet of Things industry and found that there is a significant trend of customization and decentralization in the industry. In the second half of the year, I studied Fog Computing on the basis of the conclusion of the summer vacation. I basically read the IEEE articles on Fog in the past two years, and I became more and more convinced of the trend of Internet cloud and fog combination in the next 10 years. There is a feeling that China will be the key to this Internet architecture change

Life aspect

ACG

  • Chasing Fan 56, which are

    “Touken Ranbu-Hanamaru”
    “Juvenile Jinyiwei”
    “April is your lie”
    “Swaying Camping”
    “The Moonlight Is Really Beautiful”
    “Takagi-san who is good at teasing”
    《 CLANNAD》
    《 KANON》
    《 AIR》
    《Plastic Memory》
    “Bingguo”
    “Charlotte”
    “Dragon and Tiger”
    “Star Dream”
    《Angel Beats》
    “Slash the Crimson Eye”
    “Guilty Crown”
    “The Garden of Words”
    “Sakura Village’s Pet Girl”
    “Unheard Flower Names”
    “Sword Art Online”
    “The Disappearance of Haruhi Suzumiya”
    “A certain scientific super-electromagnetic gun”
    “Violet Evergarden”
    “Firefly Forest”
    “The Shape of Sound”
    “Dating in the Second Disease”
    “Fate of Space”
    “Tokyo Ghoul”
    “Strength Doctrine Classroom”
    “Working Cells”
    “Aria the Scarlet Ammo”
    “Zero-Starting Life in Another World”
    “Teacher Eromanga”
    “My sister can’t be so cute”
    “My youth romance story really has a problem”
    《White Album 2》
    “Beyond the Realm”
    “Game of Life”
    《 citrus》
    “The Gate of Destiny Stones”
    “What are you doing in the future? Is there any time? Can you come to save? 》
    “How to raise a passerby heroine”
    《 fate》
    “Attack on Titan”
    “Jade Market”
    “The Dragon Maid of the Kobayashi Family”
    “Blow, Euphonium”
    “Natsume’s Book of Friends”
    “The Little Things of the Fairy Forest”
    “Gintama”
    “Small Buried Qianwumei”
    “A Certain Magical Index”
    “Blow, Euphonium Season 2”
    “Leeds and the Bluebird”
    “Qingyin Girl Season 1”

  • Watch TV series: “lie to me”, “Silicon Valley”, “negotiator”, “translator”, “unnatural death”

Happiness

  • Bilibili watched the video for 425 hours, and probably finished Jack Ma’s speech. The most obsessed up host turned out to be the Global Times. .
  • 1017 hours of listening to songs in Yuncun
  • Listened to a symphony concert
  • Five trips in Qufu, Taihu Lake, Suzhou Humble Administrator’s Garden, Jinan and Nanjing
  • Go to the bar once
  • Three karaoke
  • Visit grandma, grandpa, and cousin and nephew
  • Learn to drive, subject one, subject two, driving from Fangte to Yamaguchi without a license
  • I watched a lot of movies, so I won’t count them
  • Pay more attention to life and hair in the later period, and average 2 boxes of milk a day, and gradually keep up with it early

Economic Aspect

  • Project expenses are getting longer, spending 1000+ in 18 years, but still manageable
  • Scholarship subsidy
  • Relatively stable investment strategy, average 7-day annualization can reach 4+, the highest time is 7
  • Cash flow control is okay, there is no cash shortage in one year
  • Then I found that if I just want to spend more money, I really need to work hard

Exhibition:

  • Participate in the China Developers Conference, open source
  • Go to Shanghai to participate in the World Mobile Conference and get a glimpse of the future of China’s Internet

Reflection:

  • Staying up late is a bit too small, visually check the average of going to bed at 1:30 in the second half of the semester
  • The number of overnight stays is slightly higher, about 15 times, of which 3 times are more than 30 hours overnight
  • Less exercise, only one swim, not much running
  • I can’t get up often so I skip breakfast
  • The rhythm of life is chaotic when I start the process, and I am too eager to pursue functional perfection and perfection
  • Rhythm is unstable in the second half of the second semester of high school, and mathematics is basically not learned in the half semester
  • Too much attributed to the school curriculum, which is very problematic in itself

Looking forward to 2019:

  • A more comfortable life
  • More pleasant rhythm
  • More sincere interpersonal
  • Top 100 Github China in 2020
  • Stylistic two blossoms

This article is over (๑•̀ㅁ•́ฅ)

]]>
life summary
人类的两个基本需求 /thoughts/two-fundamental-demands-of-human-beings.html

人类的需求可以总结为两类,创造需求的需求,与解决需求的需求。

Human needs can be summarized into two categories, the need to create needs, and the need to solve needs.

历史缘由

在过去的几亿年中,由于生存资源的稀缺,自然界不断通过“物竞天择,适者生存”的法则筛选物种。这使得“一切为了生存”成为了几乎所有物种的“目标函数”。在众多存活下来的物种中,只有人类创造并有效利用了语言这一工具。语言使得人类能够进行更加复杂的推理思维(想象)以及更加有效的个体间信息交流。得益于语言,人类机智地通过预测潜在的自然选择要求提前准备必要的生存资源并建立了协调资源创造(分工)与资源分配的有效体制(市场,贸易)。不可避免地,基于“一切为了生存”这一习惯以及想象与预测这一种能力,人类形成了自主创造需求以及解决需求的行为模式,由此产生了两种基本行为动机,即创造需求的需求与解决需求的需求。

理论验证

观察现有人类社会架构,无论社会群体形态是政府,社会组织还是企业(公司),其本质都是一个协调不同人类创造需求的需求与解决需求的需求的闭环生态中的一环。如果一个政府,社会组织或企业无法再继续充当好一个协调人类需求中的闭环生态的一个环节,它将迅速的被其它能更高效发挥其角色的同类或非同类社会群体替代掉。

马云是一位伟大的企业家与战略家,他一手缔造的淘宝电商平台与移动快捷支付使得人们创造需求的需求与解决需求的需求的协调变得更加高效。这使阿里巴巴获得了极大的群众的信任,表现出来就是阿里具备的极高的资源支配权,也就是其极高的市值。

理论预测

当人类内部的资源因为某种原因(生产或流通环节出问题)不足以支持所有人的生存时,多余出的人类数量总会以某种形式被抹掉,也就是著名的马尔萨斯陷阱。当一个国家或民族自身遭遇马尔萨斯陷阱时,它总会选择向外发动战争来解决。因为既然要抹掉的人口数量是相对固定的,那么如果向外发动战争就会有更多的本族或本国人能够活下来,只是要将部分的死亡转移至外邦人口。古时的匈奴,二战的德国和日本都是非常典型的例子。

观察历史上的战争,有两次规模很大,我们称之为第一,二次世界大战。第一次世界大战是由于大批量机器取代人力,使得大量原有人力劳动力需要转移。但是劳动力太多没办法短时间转移,表现出来就是失业率飞涨,太多的人无所事事,没有收入,难以生存。为了防止这部分劳动力失控闹事,只得转移其注意力向外发动战争。这就是协调人创造需求的需求与满足需求的需求的市场体制出问题所导致的资源流通停滞所导致的。二战亦是如此,当电力驱动将以往的蒸汽驱动取代,大量劳动力亟需转型。1933年美国率先出现此类问题,罗斯福政府因为有多年发展积累下来的资本,因此可以通过新政建设大量民用设置强行修正资源流通生态链。但是刚因为一战被洗劫一空的德国和国土狭小资源稀缺的日本就没这么幸运了,只得将自身不可避免的马尔萨斯陷阱向犹太人和东亚转移。

如今计算技术充分发展,出现了可以通过建立多项式来fit自然复杂函数(自然规律)的人工智能算法。这就使得大多数非创造型的脑力劳动具备被取代的趋势。那么,这部分原脑力劳动力将何去何从?尤其是在中国和印度这种人口大国,一旦劳动力转型过渡不好,产生的马尔萨斯陷阱代价都将是巨大的,并最终总会由全球承担。

我的想法是,得益于数字技术的发展,如果如今的我们能够创造出一个能够协调人们创造需求的需求与解决需求的需求的闭环生态系统呢?如果当脑力劳动力被替代时这些原有劳动力能够迅速进入并适应我们创立好的闭环生态系统呢?也许我们便能够避开可怕的马尔萨斯陷阱了。

经过几千年文明的发展,当代人类已经不再满足于单单解决自然界所需要的要求,而开始尝试并创造一些非常炫酷有意思但并不怎么有利于生存的需求。也就是说,我们并不在需要所有的人类都要努力工作来确保人类能够生存,我们可以空余出好大一部分人类来探索一些新的有意思的领域。

一个可能的想法是,沉浸型网络游戏。这种网络游戏不同于现有的大部分网络游戏。现有的游戏的商业模式大都是通过程序上限制用户的部分功能体验,只用交了钱的用户才能够使用这些功能。但是我所设想的游戏更像一个平台,玩家可以从中提出自己创造的(游戏中的)需求也可以解决其他人的需求(即交易)。这就意味着一个游戏中可以出现虚拟货币,并且游戏的公众认可度会通过游戏货币与现实货币的汇率得以体现。游戏的开发者将通过开源社区而非企业进行开发,这就意味着开发者与游戏一定程度上非利益相关,从而确保了游戏的纯洁与高效,使之可能具备成为社会基础架构形式的潜能。

游戏的低门槛性并且游戏符合脑力工作者的思维习惯,使脑力劳动力能够比较轻易的从原有职业转移至相应的沉浸式游戏中。并且,由于是虚拟化技术,游戏有充分的弹性容纳大量新增的人们。不同与现在,届时社会舆论与社会思维也将会掀起一股以转入游戏为荣的热潮,以规避危害更大的战争。

有点类似于编程中的函数封装观点,现实社会类似于main函数,各个浸入式网络游戏类似于子函数。现在的社会就像是一个只有main函数的程序,所有的功能都在main函数中实现。这就使得当程序功能越复杂,越有可能发生各种bug,表现出来就是冲突甚至战争。而未来的社会更像是包含好多子函数(沉浸式游戏)的main函数。各个函数都是相互独立而又相互依赖的,每个游戏可以协调好自己的闭环生态,同时又与main函数发生部分交互。这样的社会架构将会变的去中心化并且看上去更加稳定与高效。


注:部分想法启发自知乎

Historical reasons

In the past hundreds of millions of years, due to the scarcity of survival resources, nature has constantly selected species through the law of “natural selection by nature, survival of the fittest”. This makes “all for survival” the “objective function” of almost all species. Among the many surviving species, only humans have created and effectively used language as a tool. Language enables humans to carry out more complex reasoning thinking (imagination) and more effective communication of information between individuals. Thanks to language, human beings wittily prepare necessary survival resources in advance by predicting potential natural selection requirements and establish an effective system (market, trade) that coordinates resource creation (division of labor) and resource allocation. Inevitably, based on the habit of “everything for survival” and the ability to imagine and predict, human beings have formed a behavioral pattern that independently creates needs and solves needs, which results in two basic behavior motives, namely, the need to create needs. And the need to solve the needs.

Theoretical verification

Observing the existing human social structure, whether the social group is a government, a social organization or an enterprise (company), its essence is a part of a closed-loop ecology that coordinates the needs of different human creation needs and the needs of solving needs. If a government, social organization, or enterprise can no longer serve as a link in a closed-loop ecology that coordinates human needs, it will quickly be replaced by other similar or different social groups that can perform its role more efficiently.

Jack Ma is a great entrepreneur and strategist. The Taobao e-commerce platform and mobile fast payment created by him have made the coordination of people’s demand creation and demand resolution more efficient. This has enabled Alibaba to gain the trust of the masses, which is manifested in the extremely high resource control power that Alibaba possesses, which is its extremely high market value.

Theoretical prediction

When the internal resources of human beings are insufficient to support the survival of all people for some reason (problems in production or circulation), the excess human population will always be erased in some form, which is the famous Malthus trap. When a country or nation encounters the Malthusian trap, it will always choose to launch a war to solve it. Since the number of people to be erased is relatively fixed, if a war is launched, more people of their own tribe or country will survive, but part of the death will be transferred to the Gentile population. The Huns in ancient times, Germany and Japan in World War II are all very typical examples.

Observing the wars in history, there were two large-scale wars, which we call the First and Second World Wars. The First World War was due to the replacement of manpower by a large number of machines, which necessitated the transfer of a large number of original manpower and labor. However, there is too much labor force to transfer in a short time. It shows that the unemployment rate is soaring, too many people have nothing to do, no income, and it is difficult to survive. In order to prevent this part of the labor force from getting out of control and making trouble, they had to divert their attention and start wars. This is caused by the stagnation of resource circulation caused by problems in the market system that coordinates the needs of people to create needs and meet the needs of needs. The same was true in World War II. When electric drives replaced the previous steam drives, a large number of laborers needed to be transformed. The United States took the lead in such problems in 1933. Because the Roosevelt administration had capital accumulated over the years of development, it was able to forcibly modify the ecological chain of resource circulation through the construction of a large number of civilian settings through the New Deal. However, Germany, which was looted just because of the First World War, and Japan, with its small territory and scarce resources, were not so lucky. They had to transfer their inevitable Malthusian trap to Jews and East Asia.

Now that computing technology is fully developed, artificial intelligence algorithms that can fit natural complex functions (laws of nature) by building polynomials have emerged. This makes most non-creative mental work tend to be replaced. So, where will this part of the original mental workforce go? Especially in populous countries such as China and India, once the transition of the labor force is not good, the cost of the Malthusian trap will be huge and will eventually be borne by the world.

My idea is, thanks to the development of digital technology, what if we can create a closed-loop ecosystem that can coordinate people’s needs to create needs and needs to solve them? What if these original labor forces can quickly enter and adapt to the closed-loop ecosystem that we have created when the mental labor is replaced? Maybe we can avoid the terrible Malthus trap.

After thousands of years of civilization development, contemporary mankind is no longer satisfied with simply solving the needs of nature, but has begun to try and create some very cool and interesting needs that are not very conducive to survival. In other words, we do not need all humans to work hard to ensure that they can survive. We can spare a large part of humans to explore some new and interesting fields.

One possible idea is immersive online games. This online game is different from most existing online games. The business models of existing games mostly restrict the user’s part of the functional experience through the program, and only users who have paid can use these functions. But the game I envision is more like a platform, from which players can propose their own (in-game) needs and can also solve other people’s needs (ie transactions). This means that virtual currency can appear in a game, and the public recognition of the game will be reflected in the exchange rate between the game currency and the real currency. Game developers will develop through open source communities rather than enterprises, which means that the developers are not related to the game to a certain extent, thus ensuring the purity and efficiency of the game and making it possible to become a form of social infrastructure.

The low threshold of the game and the game conforms to the thinking habits of brain workers, so that the mental labor force can be relatively easily transferred from the original occupation to the corresponding immersive game. Moreover, due to the virtualization technology, the game has sufficient flexibility to accommodate a large number of new people. Different from the present, public opinion and social thinking will also set off a wave of pride in transitioning to the game, in order to avoid more harmful wars.

A bit similar to the view of function encapsulation in programming, the real world is similar to the main function, and each immersive online game is similar to sub-functions. The current society is like a program with only the main function, all functions are implemented in the main function. This makes the more complex the program functions, the more likely it is that various bugs will occur, which manifests as conflict or even war. And the future society is more like a main function with many sub-functions (immersive games). Each function is independent and dependent on each other, each game can coordinate its own closed-loop ecology, and partly interact with the main function. Such a social structure will become decentralized and look more stable and efficient.


Note: Some of the ideas were inspired by 知 transit

]]>
thoughts society
Hello Typecho /tech/hello-typecho.html

将blog从wordpress迁移到了Typecho。

Migrated blog from wordpress to Typecho.

]]>
tech hexo
边缘计算与物联网 /thoughts/fog-architecture-and-internet-of-things.html

在过去的几十年中,互联网迅速发展,在人们的生活中起着越来越重要的作用。 在地球上几乎所有人类的参与之后[1],开发人员不可避免地期望为互联网提供更多可用的东西,然后产生了物联网(IoT)的想法。 遗憾的是,在大量事物连接到Internet的情况下,其当前体系结构似乎并不是IoT的高效解决方案。 Bonomi等。 思科的文献[2]首先注意到了这个问题,然后他们提出了革命性的Fog概念,以适应即将到来的物联网时代对越来越多的各种设备的访问。 本文将论证雾概念可以对促进物联网建设产生重大影响。

In the past few decades, Internet has been rapidly expanding and it plays an increasingly important role in people’s life. After the involvement of nearly all humans on the earth [1], developers, inevitably, expected to make more things available for the internet, which then generated the idea of the Internet of Things (IoT). Regrettably, in the case that a considerable number of things connect to the internet, its current architecture seems not to be a so efficient solution for IoT. Bonomi et al. [2] from Cisco firstly noticed this issue and they then put forward a revolutionary concept of Fog to satisfy the access of a surging number and variety of devices in the coming IoT era. This essay will argue that the Fog concept can have considerable impact on promoting IoT construction.

关于Internet的体系结构是集中式还是分布式的,引起了广泛的争议。在过去的几年中,集中化(也被称为云)已逐渐应用于现代互联网的实用结构。在此概念下,将计算,存储和控制等功能从最终用户设备迁移到云服务器已成为一种流行趋势[3]。与云不同,Fog提议将这些功能从服务器分发给用户,让用户彼此共享。

雾可以分为三个维度:雾计算,雾存储和雾控制。根据Bonomi等人的说法。 [2],雾计算意味着不仅要充分利用来自用户设备的计算资源,而且要充分利用用户与传统云服务器之间任意位置的计算资源。一个理想的例子是,视频游戏玩家的智能手机可以访问空闲计算。资源,例如玩家笔记本电脑的中央处理器(CPU),以改善他们的游戏体验。与Fog计算类似,Fog存储是第二个维度,它建议通过某种算法将用户数据从单个存储分发到多个存储设备[3]。 Google Spanner [4]是一种勇敢的做法,它是一种公共数据库,其功能是将用户的数据分发到世界各地的数据中心,以保护这些数据免遭攻击。 Shi等。 [5]指出,雾的第三个维度,雾控制,倾向于将传统的控制系统分为许多小型的独立和交互式雾系统,这些雾系统仅专注于提供单一功能。在这种情况下,如果雾灯控制系统发生故障,主机系统仍可以通过另一个类似的雾灯控制系统获得光的命令,以将服务持续保持在智能家居中。

Fog之所以为物联网的建设做出贡献的原因之一是,Fog概念下的互联网可以满足极具挑战性的物联网最小延迟要求。 Chiang&Zhang教授[3]指出,物联网应用程序(例如虚拟现实(VR)游戏,车对车通信和无人机(UAV)控制应用程序)似乎需要等待时间,即一台设备发送信号之间的时间。消息,并且目标设备接收不到10毫秒的消息,这是Cloud服务无法实现的。但是,在Yousefpour,Ishigaki和Jue [6]提出的Fog计算模型中,Fog体系结构的低级服务延迟特性已被证明是持久且稳定的。这可能意味着对延迟敏感的物联网应用可以从其延迟最小化策略中受益。

Fog促进物联网建设的另一个原因是,Fog结构化的互联网可以提供不间断的服务,而这正是物联网应用所希望的。在Fog结构中,控制行为是通过几个并行控制系统协同工作而实现的,而每个系统都有独立支持整个控制行为的潜力。这使得当设备与服务器断开连接或雾网的一部分正在更新甚至损坏时,雾服务仍然可以运行[3]。此特性对于互联车辆[2]在脱机或遇到事故时确保其运行至关重要。

除了这些原因之外,与当前的Cloud Internet相比,Fog Internet的架构似乎更加环保,尤其是在即将到来的物联网时代。在21世纪,环境保护已成为政策制定和商业活动中一个相对重要的议程。消费者期望产品中或由其制造产生的对环境有害的元素更少。但是,根据Aazam等人的说法。 [1]将来,诸如可乐瓶或树的叶子之类的所有事物都可能成为Internet的一部分,这可能需要大量的新电气设备,而其中每个电气设备都可能在一定程度上损害环境。但是,这可能意味着如果可以减少必要电气产品的数量,则将保护生态环境。研究人员评估了Fog计算的适用性,他们指出,在IoT的背景下,Fog Internet可以减少功耗并降低CO2排放[7]。显然,这些可以使互联网更接近绿色网络。

一种说法是,Fog架构的物联网在隐私和安全性方面受到质疑[3]。由于重要的Internet功能和资源都在用户附近,因此有可能遭受Fog设备的攻击。但是,这可以通过与其他技术合作来解决。例如,Zyskind和Nathan [8]设计了一种基于区块链的分散式个人数据管理算法,这是一种强大的编码方法。该算法可能是解决雾网数据安全性不足并保持系统安全的一种可行解决方案。

总而言之,尽管基于Fog概念的物联网目前可能在隐私和系统安全性方面受到质疑,但它在延迟,系统可靠性和生态友好性方面具有令人满意的性能,这是促进物联网建设的关键因素。但是,雾仍然是一个新概念,并且几乎所有相关研究都是在过去两年中进行的。要使Fog概念真正应用于物联网框架还有很长的路要走。


参考(IEEE)
[1] M. Aazam,I。Khan,AA Alsaffar和E. Huh,“物联网:整合物联网和云计算及其所涉及的问题”,2014年第11届国际巴本应用科学与技术会议论文集(IBCAST )巴基斯坦伊斯兰堡。 [线上]。 2014年1月14日至18日,伊斯兰堡,第414-419页。提供:https://uk.cloud.yimian.xyz/index.php/s/PAbkLC5bqoWFcJi

这是一篇经过同行评审的早期文章,介绍了云和物联网的概念。它为我提供了研究人员如何看待Cloud以及他们如何理解2014年(当Cloud Computing开始流行时)IoT的范围。我使用它来提供有关Cloud简介的一些背景。

[2] F. Bonomi,R。Milito,J。Zhu和S. Addepalli,“雾计算及其在物联网中的作用”,在第一版MCC移动云计算研讨会论文集中。 [线上]。 2012年8月,第13-16页。可用:https://uk.cloud.yimian.xyz/index.php/s/ZnyXdJKk84dR2QD

本文首先指出了雾的概念。它的作者全部来自思科,思科被认为是提供Internetworking解决方案的最强大的公司。我已使用此资源介绍了Fog和Fog计算以及其虚构的Fog-IoT应用程序之一的互联汽车的一些背景。

[3] M. Chiang和T. Zhang,IEEE物联网杂志中的“雾与物联网:研究机会概述”。 [线上]。卷3号6,pp.854-864,2016年12月。可用:https://uk.cloud.yimian.xyz/index.php/s/Fi7KELbjE7kR3qq

这是最有影响力的工程师组织IEEE发布的邀请论文。 Chiang来自普林斯顿,Zhang来自思科。在本文之后,更多的研究者开始注意到Fog。我使用此资源介绍,评估和查询Fog,因为这是一种罕见的高质量论文。

[4] J.C. Corbett,J.Dean,M.Epstein,A.Fikes,C.Frost,J.J。 Furman,S。Ghemawat,A。Gubarev,C。Heiser,P。Hochschild和W. Hsieh,“ Spanner:Google的全球分布式数据库”,ACM Transactions on Computer Systems(TOCS)。 [在线] .vol。 31号3页2013年8月8日。可用:https://uk.cloud.yimian.xyz/index.php/s/oxj4EAm6M78GPN8

本文详细介绍了Google Spanner。 Google Spanner是根据本文设计的。之所以包含此来源,是因为我认为Google Spanner是Fog存储的革命性尝试。当我尝试描述雾存储的概念时,我以它为例。

[5] W. Shi,J。Cao,Q。Zhang,Y。Li和L. Xu,“边缘计算:愿景与挑战”,在IEEE物联网杂志上。 [线上]。卷3号5,第637-646页,2016年10月。可用:https://uk.cloud.yimian.xyz/index.php/s/p4QGJA6AWPDKEK4

这是IEEE的期刊,已被引用8422次。它提供了有关如何将Fog应用于计算领域的一些新颖思想。我从此来源总结了Fog控制概念,并引用了他们对Fog IoT的隐私和安全性问题的质疑。

[6] A. Yousefpour,G。Ishigaki和J. P. Jue,“雾计算:努力使物联网中的延迟最小化”,2017 IEEE国际边缘计算会议(EDGE),美国檀香山,檀香山。 [线上]。 2017年,第17-24页。可用:https://uk.cloud.yimian.xyz/index.php/s/EsDjHnHHGND2SoD

作者来自德克萨斯大学,他们在雾领域并不出名。由于它是唯一一篇评估延迟(Fog IoT的最重要特征)的数学方法,并且得出了看似可靠的结果,因此我使用它来支持我的低延迟论点。

[7] S. Sarkar,S。Chatterjee和S. Misra,“在物联网环境下进行雾计算的适用性评估”,在IEEE交易云计算中。[在线]。卷6号1,第46-59页,2018年1月至3月。可用:https://uk.cloud.yimian.xyz/index.php/s/m7of3EjZ6Tji7jF

该论文是在几个月前发表的。它由两名学生和一名医生撰写,因此并不那么权威。但是,由于对Fog的研究很少,我最终决定使用其建模结果来支持Fog IoT比Cloud更环境友好。

[8] G. Zyskind,O。Nathan和A.’。 Pentland,“去中心化隐私:使用区块链保护个人数据”,2015 IEEE安全和隐私研讨会,加利福尼亚州圣何塞。 [线上]。 2015年,第180-184页。可用:https://uk.cloud.yimian.xyz/index.php/s/7FirJsrD93wzDxN

该论文由IEEE发表。 Zyskind来自麻省理工学院,这使得消息来源似乎可信。我对区块链算法感兴趣,该算法在理论上绝对是安全的,我认为这是解决Fog IoT安全问题的一种理想方法。

附件
雾和物联网PPT:https://uk.cloud.yimian.xyz/index.php/s/GbLfqxX2CBTDdRR

Internet’s architecture had been widely controverted concerning whether it should be centralized or distributed. In the past few years, centralization, which is also regarded as the Cloud, has been gradually applied to the practical structure for modern internet. Under this concept, it has become a popular trend to move functions such as computing, storage and control from end-user devices to Cloud servers [3].Different from the Cloud, the Fog proposes to distribute these functions from servers to the users and let users share them with each other.

Fog can be classified into three dimensions: Fog computing, Fog storage, and Fog control. According to Bonomi et al. [2], Fog computing means to make full use of the computing resources not only from the user devices, but from the location anywhere between users and traditional Cloud servers.An ideal example is that, video game players’ smartphone can access the idle computing resource such as the Central Processing Unit (CPU) of players’ laptop to improve their game experience. Similar to the Fog computing, Fog storage,the second dimension, proposes to distribute user’s data from single storage to many storage devices through certain algorithm [3]. One brave practice for this is Google Spanner [4], which is a public database functioning by distributing user’s data to data centers all around the world to protect these data from being attacked. Shi et al. [5] indicated that the third dimension of Fog, Fog control, tends to split a traditional control system into many small independent and interactive fog systems which only concentrate on providing single function. In this case, if a fog light control system breaks down, the host system can still get the command of the light through another similar fog control system to keep the service incessantly in a Smart Home.

One reason why the Fog contributes to the construction of IoT is that the internet under the concept of Fog can meet the challenging minimized delay requirement of IoT. Prof. Chiang & Zhang [3] indicated that, IoT applications such as Virtual Reality(VR) games, vehicle-to-vehicle communications and unmanned aerial vehicle (UAV)control applications appear to require latencies, the time spent between one device sending a message and the target device receiving the message, lower than tens of milliseconds, which the Cloud services cannot achieve. However, in a Fog computing model proposed by Yousefpour, Ishigaki & Jue [6], the low-level service delay character of Fog architecture had been proved to be persistent and stable. This may mean that latency-sensitive IoT applications can benefit from their delay-minimizing policy.

Another factor of why the Fog facilitates IoT construction is that a Fog structured internet can provide uninterrupted services, which IoT applications are desirous of. In a Fog structure a control behavior is achieved by several parallel control systems working together while each system has the potentiality to support the whole control behavior independently. This makes it possible that a Fog service can still function when devices disconnect with the server or part of the Fog net is updating or even broken [3]. This trait becomes crucial for Connected Vehicle [2] to ensure its operation when it is offline or meet with an accident.

Apart from these reasons,comparing to the current Cloud internet, the architecture of a Fog internet seems to be more eco-friendly, especially for the coming IoT era. In the 21stcentury, environmental protection has been becoming a comparatively important agenda for policy making and business activity. Consumers expect fewer environment-harmful elements in the product or generated from its manufacture. However, accordingto Aazam et al. [1], in the future, everything such as a bottle of cola or a leaf of a tree can be part of Internet, which may require a considerable number of new electrical equipment while each one of them might hurt the environment to some extent. However, this may mean that the ecological environment would be protected if the amount of necessary electrical products could be decreased. Researchers had assessed the suitability of Fog computing and they pointed that a Fog internet can result in less power consumption and lower CO2 emission in the context of IoT [7]. Apparently, these may transform the internet closer to a green net.

One argument is that the Fog architected IoT was questioned in privacy and security [3]. Since the important internet functions and resources are near the users, it becomes risky for a Fog device of being attacked. However, this might be solved by collaborating with other technics. For example, Zyskind and Nathan [8] designed a decentralized personal data management algorithm basing on blockchain, a powerful encoding method. This algorithm might be one possible solution to cover the data security shortage of Fog net and keep the system safe.

To conclude, although the IoT based on Fog concept may be currently doubted in privacy and system security, it has satisfactory performance in respect of latency, system reliability and eco-friendliness, which are crucial factors on facilitating IoT construction. However, Fog is still a new concept and nearly all of the relevant research was conducted in the past two years. It is still a long way to go before the Fog concept can be actually applied into the framework of IoT.


Reference (IEEE)
[1] M. Aazam, I. Khan, A. A. Alsaffar and E. Huh, “Cloud of Things: Integrating Internet of Things and cloud computing and the issues involved,” Proceedings of 2014 11th International Bhurban Conference on Applied Sciences & Technology (IBCAST) Islamabad,Pakistan. [Online]. 14th – 18th January, 2014, Islamabad, 2014, pp. 414-419.Available: https://uk.cloud.yimian.xyz/index.php/s/PAbkLC5bqoWFcJi

This is an early peer-reviewed article introducingthe concept of Cloud and IoT. It provides me the scope of how researcherslooked at Cloud and how they understood IoT in 2014 (when Cloud Computing beganto be popular). I have used this to provide some background about Cloud inintroduction.

[2] F. Bonomi, R. Milito, J. Zhu and S. Addepalli, “Fog computing and its role in the internet of things” In Proceedings of the first edition of the MCC workshop on Mobile cloud computing. [Online]. August, 2012, pp.13-16. Available: https://uk.cloud.yimian.xyz/index.php/s/ZnyXdJKk84dR2QD

Thispaper firstly pointed out the Fog concept. Its writers were all from Cisco, which is considered the most powerfulcompany on providing Internetworking solution. I have used this sourceto introduce some background of Fog and Fog computing and the Connected Vehicle,one of their imaginary Fog-IoT application.

[3] M. Chiang and T. Zhang, “Fog and IoT:An Overview of Research Opportunities” in IEEE Internet of Things Journal. [Online]. vol. 3, no. 6, pp.854-864, Dec. 2016. Available: https://uk.cloud.yimian.xyz/index.php/s/Fi7KELbjE7kR3qq

This is an invited paper published by IEEE, the most influential organization for Engineer. Chiang is from Princeton and Zhang is from Cisco. After this paper, more researchers began to notice Fog. I have used this source to introduce, evaluate and query Fog because this is a rare high-quality paper.

[4] J.C. Corbett, J. Dean, M. Epstein, A. Fikes, C. Frost,J.J. Furman, S. Ghemawat, A. Gubarev, C. Heiser, P. Hochschild and W. Hsieh, “Spanner:Google’s globally distributed database”, ACM Transactions on Computer Systems (TOCS). [Online].vol. 31, no. 3,pp. 8, Aug. 2013. Available: https://uk.cloud.yimian.xyz/index.php/s/oxj4EAm6M78GPN8

This paper detailly introduced Google Spanner. Google Spanner was designed based on this paper. I include this source because I think Google Spanner is are volutionary attempt of Fog storage. And I have used this as an example when I try to describe the concept of Fog storage.

[5] W. Shi, J. Cao, Q. Zhang, Y. Li and L. Xu, “Edge Computing: Vision and Challenges” in IEEE Internet of Things Journal. [Online]. vol. 3, no. 5, pp. 637-646, Oct. 2016.Available: https://uk.cloud.yimian.xyz/index.php/s/p4QGJA6AWPDKEK4

This is a journal from IEEE and have been cited 8422 times. It provides several novel ideas concerning how would the Fog be applied in computing field. I have summarized the Fog control concept from this source and cited their questioning concerning the privacy and security issue of Fog IoT.

[6] A. Yousefpour, G. Ishigaki and J. P. Jue, “Fog Computing: Towards Minimizing Delay in the Internet of Things” 2017 IEEE International Conference on Edge Computing (EDGE), Honolulu, HI. [Online]. 2017, pp. 17-24. Available: https://uk.cloud.yimian.xyz/index.php/s/EsDjHnHHGND2SoD

The authors were from Texas University and they are not famous in Fog field. As it is the only paper which evaluated latency, the most significant trait of Fog IoT, mathematically and got a seemly reliable result, I have used this to support my low latency argument. 

[7] S. Sarkar, S. Chatterjee and S. Misra, “Assessment of the Suitability of Fog Computing in the Context of Internet of Things”in IEEE Transactions on Cloud Computing.[Online]. vol. 6, no. 1, pp. 46-59, Jan.-March 2018. Available: https://uk.cloud.yimian.xyz/index.php/s/m7of3EjZ6Tji7jF

This paper was just published a few month ago. It was written by two students and one doctor, which makes it not so authoritative. However, since there are few Fog research, I finally decide to use its modeling result to support that Fog IoT is more environment friendly than Cloud.

[8] G. Zyskind, O. Nathan and A. ‘. Pentland,”Decentralizing Privacy: Using Blockchain to Protect Personal Data” 2015 IEEE Security and Privacy Workshops,San Jose, CA. [Online]. 2015, pp. 180-184. Available: https://uk.cloud.yimian.xyz/index.php/s/7FirJsrD93wzDxN

This paper was published by IEEE. Zyskind was from MIT, which makes the source seems to be credible. I am interested in the blockchain algorithm which is theoretically absolutely safe as it mentioned and I think it is one ideal method to deal with the security problem of Fog IoT.

Attachment
Fog and IoT PPT: https://uk.cloud.yimian.xyz/index.php/s/GbLfqxX2CBTDdRR

]]>
thoughts iot internet fog
在Centos 7.5上构建Nextcloud服务器 /tech/build-nextcloud-server-on-centos7.html

Nextcloud是一个用PHP编码的开源软件项目。 它提供了理想的私有云存储解决方案,该解决方案被认为是可靠且稳定的。 该博客旨在逐步介绍Nextcloud Building指导,以帮助新生和将来的复习。 Nextcloud是一个用PHP编码的开源软件项目。 它提供了理想的私有云存储解决方案,该解决方案被认为是可靠且稳定的。 该博客旨在逐步介绍Nextcloud Building指导,以帮助新生和将来的复习。 Nextcloud是一个用PHP编码的开源软件项目。 它提供了理想的私有云存储解决方案,该解决方案被认为是可靠且稳定的。 该博客旨在逐步介绍Nextcloud Building指导,以帮助新生和将来的复习。

Nextcloud is an open-source software project coded with PHP. It had provided a ideal private cloud-storage solution which was considered to be reliable and stable. This blog aims to present a Nextcloud Building instruction step by step for the purpose of helping freshman and future reviewing. Nextcloud is an open-source software project coded with PHP. It had provided a ideal private cloud-storage solution which was considered to be reliable and stable. This blog aims to present a Nextcloud Building instruction step by step for the purpose of helping freshman and future reviewing. Nextcloud is an open-source software project coded with PHP. It had provided a ideal private cloud-storage solution which was considered to be reliable and stable. This blog aims to present a Nextcloud Building instruction step by step for the purpose of helping freshman and future reviewing.

将linux核心更改为BBR愿景

如果您的服务器是新服务器,强烈建议将其更新到支持bbr模式的较高版本,这是google提供的高级centos系统核心,它可以使您的服务器更高效。

首先从github下载并安装bbr core。

1
2
3
$ wget -N --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh &&\
$ chmod +x bbr.sh && \
$ bash bbr.sh

使用代码检查核心版本。 如果大于4.9.0,则可以。

1
$ uname -r

预期显示:net.ipv4.tcp_available_congestion_control = bbr cubic reno

1
$ sysctl net.ipv4.tcp_available_congestion_control

预期显示: net.ipv4.tcp_congestion_control = bbr

1
$ sysctl net.ipv4.tcp_congestion_control

预期显示: net.core.default_qdisc = fq

1
$ sysctl net.core.default_qdisc

预期显示: xxxxxxxx tcp_bbr

1
$ lsmod | grep bbr

##安装Nginx服务

从nginx组织网站上提取nginx软件包。

1
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

安装 Nginx.

1
$ yum install -y nginx

启动 nginx .

1
2
$ systemctl start nginx.service
$ systemctl enable nginx.service

设置nginx的首选项文件。 单击此处以获取推荐的nginx.conf文件。

1
2
$ cd /etc/nginx
$ vi nginx.conf

申请ssl认证。 用your_domain.crt(key)重命名并将其下载到服务器:/ etc / nginx / ssl /

1
2
3
$ //Use scp -r (my ssl file route on my windows)/your_domain.crt \root@(your server ip): /etc/nginx/ssl
$ //Use scp -r (my ssl file route on my windows)/your_domain.crt root@(your server ip): /etc/nginx/ssl
$ //On WINDOWS BASH

检查并重新启动Nginx服务。

1
2
3
4
$ nginx -t

$ //If the return is successful it is ok, othervise there exists error in your nginx.conf file.
$ systemctl restart nginx

##安装docker

从官方网站拉并安装docker服务。

1
$ curl -sSL https://get.docker.com/ | sh

启动docker服务

1
2
$ systemctl start docker
$ systemctl enable docker.service

从github提取nextcloud和mariadb(centos上的简化mysql数据库)图像。

1
$ docker pull rootlogin/nextcloud && docker pull mariadb:10

使用Docker启动映像mariadb。

1
2
3
$ docker run -d --name nextcloud_db -v /data/mysql:/var/lib/mysql -e \
$ MYSQL_ROOT_PASSWORD=YOUR_PASSWD -e MYSQL_DATABASE=nextcloud \
$ -e MYSQL_USER=nextcloud -e MYSQL_PASSWORD=YOURPASSWD mariadb:10

使用docker启动映像nextcloud。

1
$ docker run -d --name nextcloud --link nextcloud_db:nextcloud_db -p 127.0.0.1:9001:80 -v /data/nextcloud:/data rootlogin/nextcloud

那是服务器上的最后一步。 现在,从浏览器开始http:// YOUR_DOMAIN /。

建议将“ localhost”替换为“ nextcloud_db”。


参考文献列表:
https://www.moerats.com/archives/420/
https://my.oschina.net/yule526751/blog/799004
https://www.moerats.com/archives/420/

Change linux core to BBR vision

If your server is a new one, it is strongly recommended to update it to an upper version supporting bbr mode, which is a senior centos system core provide by google and it could make your server more efficient.

Firstly download and install bbr core from github.

1
2
3
$ wget -N --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh &&\
$ chmod +x bbr.sh && \
$ bash bbr.sh

Use the code to check the core version. If it’s large than 4.9.0 it’s OK.

1
$ uname -r

Expected return:net.ipv4.tcp_available_congestion_control = bbr cubic reno

1
$ sysctl net.ipv4.tcp_available_congestion_control

Expected return: net.ipv4.tcp_congestion_control = bbr

1
$ sysctl net.ipv4.tcp_congestion_control

Expected return: net.core.default_qdisc = fq

1
$ sysctl net.core.default_qdisc

Expected return: xxxxxxxx tcp_bbr

1
$ lsmod | grep bbr

Install Nginx Service

Pull nginx package from nginx orginzation website.

1
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Install Nginx.

1
$ yum install -y nginx

Start nginx service.

1
2
$ systemctl start nginx.service
$ systemctl enable nginx.service

Set preference file of nginx. Click here to get recommended nginx.conf file.

1
2
$ cd /etc/nginx
$ vi nginx.conf

Apply ssl certification. Rename it with your_domain.crt(key) and download it to your server: /etc/nginx/ssl/

1
2
3
$ //Use scp -r (my ssl file route on my windows)/your_domain.crt \root@(your server ip): /etc/nginx/ssl
$ //Use scp -r (my ssl file route on my windows)/your_domain.crt root@(your server ip): /etc/nginx/ssl
$ //On WINDOWS BASH

Check and restart nginx service.

1
2
3
4
$ nginx -t

$ //If the return is successful it is ok, othervise there exists error in your nginx.conf file.
$ systemctl restart nginx

Install docker

Pull and install docker service from official website.

1
$ curl -sSL https://get.docker.com/ | sh

Start docker service.

1
2
$ systemctl start docker
$ systemctl enable docker.service

Pull nextcloud and mariadb(simplified mysql database on centos ) images from github.

1
$ docker pull rootlogin/nextcloud && docker pull mariadb:10

Start image mariadb with docker.

1
2
3
$ docker run -d --name nextcloud_db -v /data/mysql:/var/lib/mysql -e \
$ MYSQL_ROOT_PASSWORD=YOUR_PASSWD -e MYSQL_DATABASE=nextcloud \
$ -e MYSQL_USER=nextcloud -e MYSQL_PASSWORD=YOURPASSWD mariadb:10

Start image nextcloud with docker.

1
$ docker run -d --name nextcloud --link nextcloud_db:nextcloud_db -p 127.0.0.1:9001:80 -v /data/nextcloud:/data rootlogin/nextcloud

That is the last step on server. Now let’s start http://YOUR_DOMAIN/ with your explorer.

Recommend to substitute the “localhost” to “nextcloud_db”.


Reference List:
https://www.moerats.com/archives/420/
https://my.oschina.net/yule526751/blog/799004
https://www.moerats.com/archives/420/

]]>
tech docker php nginx
wifiduino搭建236宿舍物联网平台 /tech/build-236-iot-platform-on-wifiduino.html

重新搭建236的IoT底层平台,并通过Blinker手机控制,实现操控监视。平台拥有很强的扩展性及可移植性,目前实现了夜间自动灯光,火灾烟雾报警,床帘内:上床小夜灯开,自动通风,LED自动感应阅读状态等设计。

Re-build the 236 IoT underlying platform and control it through Blinker mobile phone to realize control and monitoring. The platform has strong scalability and portability. At present, it has realized the design of automatic lighting at night, fire and smoke alarm, and bed curtain: the night light on the bed, automatic ventilation, and LED automatic sensing reading status.

搭建缘由

早在大一上学期,意外接触Arduino,开始了解单片机。17年11到12月份,曾利用Arduino uno 3搭建了一台功能简易的自动控制平台,主要实现了由红外遥控器控制床帘Light以及小夜灯的功能。在运行一个半月后,由于一次上传代码时意外短路,导致单片机烧毁,自此系统报废,但线路依旧保留。

考虑到第一次搭建完全新手,代码缺少必要注释,更有通向床帘的数十根线路完全缠绕在一起,无法分清具体那几根控制什么传感器或设备,故设重建计划暂时搁置。

半年后的暑假,参加欧朗中国的IETE项目,课程中与公司研发组的软件和硬件工程师愉快得体验了一些单片机的应用研发,了解了单片机及物联网的基础组成及发展现状,在工作闲余,对原有线路进行了测试,分类,贴标签,使其得以正常使用。

8月份,项目结束,回到家中。考虑到家中原有太阳能需加水后需手动关闭,时常发生晚上洗澡后加水忘关情况,造成大量水资源浪费。于是结合欧朗所学,以及自己的实践经验,搭建了一套基于wifiduino和电磁阀的太阳能自动加水系统。为了照顾年老的姥姥方便夜间上厕所,在走廊过道利用原有废弃有线网络线路,搭建了与手动开关密切集合的自动感应开灯系统。由此收获了许多关于家用线路的架设经验。

回到苏州,考虑到一年来的相关经验,认为是时候尝试搭建一套可长期使用的商品级的强扩展性的IoT系统,于是…start搞事情

搭建经历

搭建初期,一切还算顺利。但是随着系统逐渐趋于完善,代码逐渐复杂,经典的Arduino式软硬件兼容问题又逐渐开始捣乱啦~

首先遇到的问题是(大概是由于esp8266与wifiduino的一些神奇的勾当)当把代码通过usb传给wifiduino的时候,代码运行是正常的,但是在断电重启或者Reset后,它就死掉了。。。而且,这个问题只在上传占用了大约十个左右Digital通信口的程序之后才出现,如果只是上传简单的示例程序则运行正常,,最后从淘宝钓了一只路由器用的USB-DC9V升压线,用其持续供电,才确保了板子的正常运行。

遇见的第二个问题也是很神奇。就是,wifiduino在连接tx与rx后竟然无法上传代码!!!当时我一直以为是板子坏掉了

本来是只有一块板子的,但是当他装载了太多控制端之后,大概是死掉了,wifi无法正常连接Blinker..于是我只用它作为控制器,然后将另一块板子连接wifi,将接受信息通过串口传递给主板子执行。于是,运行终于正常了,,,莫名想到了欧朗当时考试的译码器

主要功能

功能的话目前看来也不是很多,4只传感:2只超神波测距,1只光敏,1只烟雾,4个控制端:1只床外探照灯ledB, 1只小夜灯,1只床头灯,1个小风扇。实现的话,无非就是其相互配合,目前可以准确识别我的存在位置4个,室友的存在位置1个。然后配合行为习惯编程调整灯与风扇。

未来的话,还打算逐步实现–传感层:对室内是否有人的识别 智能层:对室友在宿舍时间规律的学习(神经网络) 控制层:空调红外控制,基于esp8266的微型继电器对宿舍大灯的控制,以及,快乐的话考虑自动养一株辣椒什么的…

最后

最后附上两个板子的代码,,还会更新的哦//祝生活愉快啦~
代码:https://uk.cloud.yimian.xyz/index.php/s/YbPwdkt2mANYoiS


2019.2.19更新:

板子运行超过150天,一切运行正常。
出现过几次分钟级别的控制失效事件,怀疑宿舍电网供压不稳导致,事后均自动修复。


2019.2.28更新

上文代码链接已弃用,如有兴趣,可查看由其代码开发的wIoT项目


2019.6.12更新

稳定运行611天18小时32分钟,正式退役!
236-iot


已完结

Build reason

As early as the first semester of my freshman year, I accidentally came into contact with Arduino and started to understand microcontrollers. From November to December 2017, I used Arduino uno 3 to build a simple automatic control platform, which mainly realized the function of controlling the bed curtain Light and night light by the infrared remote control. After running for a month and a half, due to an accidental short circuit when uploading the code once, the single-chip microcomputer was burned out. Since then, the system has been scrapped, but the circuit remains.

Considering that the code is completely new to the first time, the code lacks necessary comments, and dozens of lines leading to the bed curtain are completely entangled, and it is impossible to distinguish which sensors or devices are controlled by the specific ones. Therefore, the reconstruction plan is temporarily shelved.

In the summer vacation half a year later, I participated in the IETE project of Oulang China. During the course, I had a pleasant experience with the software and hardware engineers of the company’s R&D team in the application and development of some single-chip microcomputers, and learned about the basic composition and development status of single-chip microcomputers and the Internet of Things. In addition, the original circuit was tested, classified, and labeled to enable it to be used normally.

In August, the project ended and I returned home. Considering that the original solar energy in the home needs to be turned off manually after adding water, it often happens that the water is forgotten to turn off after taking a bath at night, resulting in a lot of water waste. So combined with what Oulang has learned and his own practical experience, he built a solar automatic water filling system based on wifiduino and solenoid valve. In order to take care of the elderly grandma and facilitate the use of the toilet at night, the original abandoned wired network lines were used in the corridors to build an automatic induction light-on system closely integrated with the manual switch. This has gained a lot of experience in the installation of home wiring.

Back in Suzhou, considering the relevant experience in the past year, I thought it was time to try to build a long-term commodity-level and highly scalable IoT system, so…start doing things

Build experience

At the beginning of the construction, everything went smoothly. However, as the system gradually improves and the code becomes more complex, the classic Arduino-style software and hardware compatibility problems are gradually starting to mess up~

The first problem encountered is (probably due to some magical activities between esp8266 and wifiduino) when the code is transferred to wifiduino via usb, the code runs normally, but after a power failure or reset, it will die . . . Moreover, this problem only appeared after uploading a program that occupies about ten Digital communication ports. If you only upload a simple sample program, it runs normally. Finally, I fished a USB-DC9V boost cable for routers from Taobao. , Use its continuous power supply to ensure the normal operation of the board.

The second problem encountered is also very magical. That is, wifiduino can’t upload code after connecting tx and rx! ! ! I always thought the board was broken

Originally there was only one board, but when he loaded too many consoles, it probably died and the wifi could not connect to Blinker.. So I only used it as a controller, and then connected another board to wifi, and it would accept The information is passed to the motherboard for execution through the serial port. As a result, the operation was finally normal,,, inexplicably thought of the decoder of Oulang at that time.

The main function

In terms of functions, it seems that there are not many at present. 4 sensors: 2 Ultra Sure Wave Ranging, 1 photosensitive, 1 smoke, 4 control terminals: 1 outdoor searchlight ledB, 1 night light, 1 bed Headlight, 1 small fan. If it is realized, it is nothing more than their mutual cooperation. Currently, 4 locations of my existence and 1 location of my roommate can be accurately identified. Then program and adjust the lights and fans in accordance with behavior habits.

In the future, it is planned to be implemented gradually-Sensing layer: Recognition of whether there are people in the room. Intelligent layer: Learning the time rules of roommates in the dormitory (neural network). Control layer: Air-conditioning infrared control, based on esp8266 miniature relay for dormitory headlights Control, and, if you are happy, consider automatically raising a pepper plant…

At last

Finally, the codes of the two boards are attached, and they will be updated.//Happy life~
Code: https://uk.cloud.yimian.xyz/index.php/s/YbPwdkt2mANYoiS


2019.2.19 update:

The board has been running for more than 150 days and everything is running normally.
There have been several minute-level control failure events. It is suspected that the dormitory’s power grid is not stable, and they are automatically repaired afterwards.


2019.2.28 update

The above code link has been deprecated, if you are interested, you can check the wIoT project developed by its code!


2019.6.12 update

Stable operation for 611 days, 18 hours and 32 minutes, officially retired!
236-iot


The END.

]]>
tech Arduino iot
你好,世界! /tech/hello-world.html

你好,世界!

Hello World!

在我19周岁生日这一天,我的第一个通过wordpress自建的Blog网站正式上线啦~

On my 19th birthday, my first blog site built by WordPress was officially launched~

]]>
tech php wordpress