3月 09

读《特斯拉回忆录》

一位被世界遗忘的天才,世界上最接近神的人。
如果没有特斯拉,今天的电气化会来得很迟。不是特斯拉的专利免费让全人类使用,也没有我们今天的高速发展。
特斯拉的惊世之举,1897年,举世知名的「尼加拉瓜」水电站,其电力输出量实是惊人。而这项足足超过100年以上的电力建设至今仍然运作如常,从未间断地生产出无穷无尽的天然能源,这实是人类近百年科学上的一大标记。

3月 03

raspberry pi apt失败

重装raspberry pi系统,将apt-get的源换成阿里云的。执行报错如下:

W: Duplicate sources.list entry http://mirrors.aliyun.com/raspbian/raspbian/ jessie/main armhf Packages (/var/lib/apt/lists/mirrors.aliyun.com_raspbian_raspbian_dists_jessie_main_binary-armhf_Packages)
W: Duplicate sources.list entry http://mirrors.aliyun.com/raspbian/raspbian/ jessie/non-free armhf Packages (/var/lib/apt/lists/mirrors.aliyun.com_raspbian_raspbian_dists_jessie_non-free_binary-armhf_Packages)
W: Duplicate sources.list entry http://mirrors.aliyun.com/raspbian/raspbian/ jessie/contrib armhf Packages (/var/lib/apt/lists/mirrors.aliyun.com_raspbian_raspbian_dists_jessie_contrib_binary-armhf_Packages)
W: You may want to run apt-get update to correct these problems

解决
直接删除/etc/apt/sources.list.d/下面的文件,再次更新。

2月 24

esp8266做AP启动WEB服务器控制led

配置ap。

import network
ap_if = network.WLAN(network.AP_IF)
ap_if.config(essid="simonzhang.net", authmode=network.AUTH_WPA_WPA2_PSK, password="simon")

代码部分,保存为main.py上传到板子上,重启。

import machine
pins = [machine.Pin(i, machine.Pin.IN) for i in (0, 4, 5)]

html = """
HTTP/1.0 200 OK



    
    
    www.simonzhang.net test
    

    %s
    

GPIO0  

GPIO4  

GPIO5  

""" def indexHandle(rtype, argv): if rtype == 'GET': try: num = argv.split('=')[1] except: num = 9999 if num == 9999: pass else: num1 = num[:-1] num2 = num[-1] if num1 == "OFF": machine.Pin(int(num2), machine.Pin.OUT, value=0) elif num1 == "ON": machine.Pin(int(num2), machine.Pin.OUT, value=1) rows = ['%s%d' % (str(p), p.value()) for p in pins] return html%'\n'.join(rows) def pinHandle(rtype, argv): print(rtype) print(argv) def route(getData): rtype = getData[0].split()[0] path = getData[0].split()[1] if path.find('?') > -1: urlPath = path.split('?')[0] argv = path.split('?')[1] else: urlPath = path argv = '' rou = {'/' : indexHandle(rtype, argv)} try: htmlContext = rou[urlPath] except: htmlContext = html%'error' return htmlContext import socket addr = socket.getaddrinfo('0.0.0.0', 8888)[0][-1] s = socket.socket() s.bind(addr) s.listen(1) while True: cl, addr = s.accept() cl_file = cl.makefile('rwb', 0) tmp = '' line = '' while True: line = cl_file.readline() tmp = '%s%s' % (tmp, line.decode('utf-8')) if not line or line == b'\r\n': break cl.send(route(tmp.split('\r\n'))) cl.close()

esp8266we控制led源码

连接ap,用浏览器登录192.168.4.1:8888端口


控制led成功。

2月 18

安装ta-lib问题记录

直接使用pip install Ta-LIB,报错如下:
talib/common.c:242:28: fatal error: ta-lib/ta_defs.h: No such file or directory
解决方案先下载0.4版进行编译
ta-lib-0.4.0-src.tar.gz
然后解压
./configure & make & make install

安装0.4版本完成在用pip安装最新版本就成拱了。但是运行程序有又报错:
ImportError: libta_lib.so.0: cannot open shared object file: No such file or directory
在整个系统中搜索,发现在系统中有这个库。
find / -name libta_lib.so.0
/usr/local/lib/libta_lib.so.0
所以加载一下应该就可以了,在/etc/profile增加一行
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
然后执行
source /etc/proflie
生效后再次运行py脚本既可成功。