flutter包在内地安装不了怎么办?

一般我们在flutter pub get安装包的时候,经常会遇到如下错误。

Got socket error trying to find package coverage at http://pub.dartlang.org.

或者

Got socket error trying to find package flame at https://pub.dev.

你打开浏览器访问pub.dev的时候,又可以正常访问。

这个咋解决呢?

如果你是Windows用户,你可以在Powershell的界面下运行:

setx PUB_HOSTED_URL “https://mirrors.cloud.tencent.com/dart-pub”
setx FLUTTER_STORAGE_BASE_URL “https://mirrors.cloud.tencent.com/flutter”

这两条命令。

如果你是Mac用户,你可以在命令行下运行:

$ export PUB_HOSTED_URL=https://mirrors.cloud.tencent.com/dart-pub
$ export FLUTTER_STORAGE_BASE_URL=https://mirrors.cloud.tencent.com/flutter

之前有教程说改成这样:

setx PUB_HOSTED_URL “https://pub.flutter-io.cn”
setx FLUTTER_STORAGE_BASE_URL “https://storage.flutter-io.cn”

但实际操作是无效的,现在还不知道怎么回事。

用Pi-Timolo和树莓派做一个夜视摄像头

安德鲁·格雷戈里 (Andrew Gregory) 发现,后花园的狗经常深夜叫唤。

于是他用树莓派做了一个夜间摄像头,来拍下那个不断引发狗叫的神秘访客。

要放在室外,少不了一个防雨且有一定强度的容器,这里他用到了几块厚木板。

市场上有一系列适用于 Raspberry Pi 的摄像头,比如:Pi Camera Module 3、Raspberry Pi Global Shutter Camera、Raspberry Pi High Quality Camera 和各种热敏模块。

但当访客在夜间到来,最好用的是 Pimoroni 等厂商提供的夜视摄像头。

关于树莓派的选择,作者用到了Raspberry Pi Zero W,比较轻便,兼容性也很好。

这个摄像头设在后花园,距离足够近,可以通过家庭 Wi-Fi 网络即可获取视频流。

但作者不想拉电源线,所以需要电池供电。

事后看来,最好是选择 USB 电池组——这种电池组可以即插即用到任何设备,并具有一定程度的保护作用。

作者选择了 1200mAh,3.7 V LiPo 电池,它裸露且易碎,无法直接连接到 Raspberry Pi Zero W。所以需要给 Raspberry Pi Zero 添加一个 LiPo SHIM(这需要一些焊接)。

本文提到的树莓派电池连接板,相关地址:

把供电模块、摄像头、树莓派都接好后的状态,差不多是这样。

装好系统,通电联网,登录系统执行如下命令进行测试:

raspistill -v -o test.jpg

如果一切顺利,你会看到一个图像在屏幕上闪了一两秒钟,然后颜色会变暗。那是因为夜视摄像头模块使用红外线(大多数摄像头模块会过滤掉这层光谱)。

作者在这里使用的软件包为 Pi-Timolo(Raspberry Pi Time、Motion 和 Low light),由 Claude Pageau 开发。 

可以执行如下命令安装(最好是update系统以后):

curl -L https://raw.github.com/pageauc/pi-timolo/master/source/pi-timolo-install.sh | bash

然后到一个设置界面,自行操作即可。

不过与 Raspberry Pi Camera Module 3 的 12MP 相比,夜视摄像头上的 5MP 传感器还是有些很小,因此作者很想找到一些红外 LED 并制作自己的摄像头模块。

来自:HackSpace 第 66 期

谷歌Sheets和ESP8266构建的考勤系统

用户刷卡后,系统会与包含用户列表的谷歌表单进行核对。

如果用户获得授权,LCD上会显示用户的姓名、接入类型和自定义留言,并发出“嘟”的一声。系统还将考勤数据记录在谷歌Sheet中,供以后查看和分析。

开始之前,你得有一个Google账户,且所在网络可以顺利登录Google。

https://mp.weixin.qq.com/cgi-bin/readtemplate?t=tmpl/video_tmpl&vid=wxv_2903425061842321412

主要材料:

RFID RC522

https://www.aliexpress.us/item/2251832760608169.html

esp8266

https://www.aliexpress.us/item/2251832470086446.html

lcd1602

https://www.aliexpress.us/item/2251832499297742.html

breadboard

https://www.aliexpress.us/item/2251832028089611.html

相关源码:

https://github.com/unreeeal/ESP/tree/master/ESP-RFID-GOOGLE

注:这里ESP32和ESP8266的使用场景是差不多的,两者都可以实现类似功能。

谁进我屋了之“无线门户报警器”

前面我们讲到了简易门户报警器的实现。

相关链接:

这次来做一个升级,实现网络报警。

项目需求:

当有人打开门或没关上门时,Micro:bit马上通过无线网络向你报警。

实现原理:

Micro:bit上面有个磁力计,这里可以设定每2秒测量一次磁场强度。当磁场低于某个特定水平(阈值)时,它会发送一个无线信号“door open”。如果磁性读数超过阈值,则会发送“door closed”。

当警报器Micro:bit收到“door closed”信息时,其 LED显示屏上会显示一个勾号。 当收到“door open”无线电讯息时,它会显示一个大叉并发出警报声。

所需材料:

Micro:bit 2个
电池包 2个
磁铁 1个
万能胶或类似工具,用以将磁铁固定在门上,并将Micro:bit固定在门框上。
可选的蜂鸣器或扬声器
鳄鱼夹引线

门户端代码:

from microbit import *
import radio
radio.config(group=17)
compass.calibrate()
radio.on()

while True:
    if button_a.was_pressed():
        display.scroll(compass.get_field_strength())
    if compass.get_field_strength() < 100000:
        display.show(Image.DIAMOND_SMALL)
        radio.send('door open')
    else:
        display.clear()
        radio.send('door closed')
    sleep(2000)

报警端代码:

from microbit import *
import music
import radio
radio.config(group=17)
radio.on()

while True:
    message = radio.receive()
    if message:
        if message == 'door open':
            display.show(Image.NO)
            music.play(["C4:4"])
        if message == 'door closed':
            display.show(Image.YES)

离线编辑器:

在线编辑器:

https://makecode.microbit.org/#editor

https://python.microbit.org/v/3?l=zh-CN

进阶:

1、按下Micro:bit上的按键A,以帮助校准磁力的最佳阈值。在MakeCode中将其设置为100 microteslas,与在Python中的10000 nanoteslas相同。
2、使用多个Micro:bit来发送不同的无线电消息(例如“back door open”)以追踪多门的状态。
3、使用变量来计算门保持打开状态的时间。

谁进我屋了之“简易门户警报器”

这是写给物联网新手的教程,熟手如果好奇也可以看一下。

有人来过你的房间吗?使用Micro:bit,电池组和磁铁,你可以让门发出警报,以提醒有人闯入。

关于Micro:bit:

Micro:bit是一个卡片大小的计算机,它有一个LED显示屏、按键、传感器和一些输入/输出引脚,可以在Scratch和Python程序的控制下,与你的世界交互。

原理:

Micro:bit上面内建了一个compass sensor,称为磁力计。 你可以使用它来测量地球的磁场,以作为指南针-或感应到附近的磁场强度!

代码:

当磁力强度感应低于200,就显示愤怒的表情。

当按钮A按下时,显示当前磁力强度。

如果用Python的话,这样写:

# Python uses nanoteslas to measure magnetism.
# Experiment with different numbers depending on the
# strength of your magnet, which you can read by 
# pressing button A.

from microbit import *

while True:
    if button_a.was_pressed():
        display.scroll(compass.get_field_strength())
    if compass.get_field_strength() < 200000:
        display.show(Image.ANGRY)

做法:

将磁铁固定在门上,然后将写入开门警报器程序的Micro:bit靠近它,固定在墙上。

接好电源。这样一个简单的报警装置就做好啦。

进阶:

1、添加声音警报。

2、使用一个变量来计算门被打开的次数,这里需要添加一个程序来感应门是否被打开或关闭。

3、创建一个定时器计算门被打开多长时间

好了,拿去玩吧。

本文主要内容来自:

microbit.org

相关视频:

谁进我屋了之“简易门户警报器” (qq.com)

树莓派+电子墨水屏+Spotify = 实时播歌

Spotify是一个流行的流媒体服务,允许用户收听音乐、播客和有声读物。作为一个开发者,你可以使用Spotify Web API来访问Spotify的音乐目录和用户数据,并将Spotify的功能整合到你自己的应用程序中。

如何用树莓派和5.7英寸的电子墨水屏创建一个电子相框,来实时显示你在Spotify上听的歌曲封面?说实话,这个让我想起了以前实时显示歌曲封面的CD机。

操作步骤:

首先你要有一个Spotify的开发者账号,注册地址:

https://developer.spotify.com/

在仪表盘中编辑应用程序的设置。比如:

http://localhost/redirect

设置完成后,登录树莓派。

运行“raspi-config”命令,找到“Interface Options”,把SPI和I2C设置为可用。 

下载以下文件,并在树莓派上执行。最后根据提示,填写你的Spotify账号和API信息即可。

wget https://raw.githubusercontent.com/ryanwa18/spotipi-eink/main/setup.sh
chmod +x setup.sh
bash setup.sh

相关配件:

Raspberry Pi Zero 2
Inky Impression 5.7

关于外壳的3D打印文件:

https://cults3d.com/en/3d-model/gadget/spotipi-e-ink-inky-impression-5-7-case

相关视频地址:

https://mp.weixin.qq.com/s/tMx-RSDyAZZMUo04oYRRqw

为年轻人做的在线代码编辑器

树莓派官方最近出了一款免费的在线编辑器,以帮助 7 岁以上的年轻人学习程序开发。比较有意思的是,这个在线编辑器支持emoji表情。

在线编辑界面

不管你是参加 Code Clubs 和 CoderDojos 的选手,还是普通的在校学生,树莓派用户……都可以用它在线调试自己的程序。

目前该编辑器还在公测阶段,主要目标是让使学习者能够:

  • 直接在浏览器中编写和运行 Python 代码,无需任何设置。界面简单直观,这使得基于文本的编码更加容易。
  • 让那些拥有Raspberry Pi Foundation 帐户的人可以在线保存他们的代码。树莓派基金会希望代码学习者不管是在家里,还是在课堂上,都可以更方便的构建自己的项目。

目前,树莓派基金会选择了Python 作为代码编辑器支持的第一个语言,因为它在学校、CoderDojos 和代码俱乐部中很流行,很多专业开发人员也在用它。

将来会向编辑器添加对 Web 开发语言 (HTML/CSS/JavaScript) 的支持,以及项目共享和协作等功能。树莓派基金会希望这个编辑器是安全、易于访问且适龄的。

关于ICO 的适龄设计规范:

https://ico.org.uk/for-organisations/guide-to-data-protection/ico-codes-of-practice/age-appropriate-design-a-code-of-practice-for-online-services/

经过笔者的测试,目前该编辑器主要支持turtle在内的Python标准库,以及P5高级绘图库,大家可别在里面跑PyGame咯。

官方推荐的入门项目:

https://projects.raspberrypi.org/en/pathways/python-intro-code-editor

Windows 10查看Wi-Fi密码

确保wlansvc服务启动中,没有无线网络的台式机,该服务未启动
$ sc query wlansvc | findstr STATE
STATE : 4 RUNNING

查看曾经连接过的无线网络
$ netsh wlan show profiles

User profiles
All User Profile : any All User Profile : some All User Profile : meeting_5GHz All User Profile : meeting_2.4GHz

若wlansvc服务未启动,上述命令报错
$ netsh wlan show profiles
The Wireless AutoConfig Service (wlansvc) is not running.

假设一切顺利,如下命令可查看指定无线网络的明文密码
$ netsh wlan show profiles name=”some” key=clear | findstr /C:”Key Content”
Key Content : XXXXXXXXXXXXXXXX

来自:沈沉舟

基于ESP8266的智能配电板

This is the final curcuit: 

This is components you need for the project:

PZEM-004T: https://s.click.aliexpress.com/e/_9hYStD

ESP8266: https://s.click.aliexpress.com/e/_97j7kp

Resistors: https://s.click.aliexpress.com/e/_9AslPB

Electrolytic Capacitor: https://s.click.aliexpress.com/e/_A2atvx

PCB 6X8: https://s.click.aliexpress.com/e/_d7XpQnS

Pin Header: https://s.click.aliexpress.com/e/_AUvLzT

Female PCB Header: https://s.click.aliexpress.com/e/_AClQip

5V relay module: https://s.click.aliexpress.com/e/_AAXY9i

1602 I2C Display: https://s.click.aliexpress.com/e/_AF3L2o

Compilation

Use core 2.7.4 for this project (Tested with this version)  upd: 08/12/2021 made some changes, tested with 3.0.2 (works)

please download the necessary libraries: https://github.com/electrical-pro/SmartBoard/blob/main/libraries.zip copy them from the archive to: C:\Users\Documents\Arduino\libraries

P.S. I modified the LiquidCrystal_I2C library, I removed Wire.begin(5, 14);

Uploading files from data folder

The project uses SPIFFS to store files on ESP8266, upload them to the ESP8266 (read about SPIFFS if you dont know what that is.) 

 If you don’t see this option install the plugin from here: https://github.com/esp8266/arduino-esp8266fs-plugin

Connecting to router

After flashing connect to “PowerControlESP | Offline” pass is “PowerControlPass” then go to 192.168.4.1 (WI-Fi manager) and connect to your Wi-Fi router. 

Power server is at 192.168.x.x:8089 (port is 8089)

Very unusual authorization that I implemented

If it says “The file exists, but you are not authorized!” – is a simple safety feature that I implemented, so in order to access files you need to go to a secret URL first http://192.168.x.x:8089/me (you can program another one) When you go to http://192.168.x.x:8089/me it puts a cookie in your browser and you become an authorized user

to make it work right set it to false in the sketch

// set it to false, and then get auth cookie by going to 192.168.x.x:8089/me
bool PublicAccess = true;  // authorization 

If it is true it only allows you to go to http://192.168.x.x:8089

if it is false nothing is allowed unless you go to http://192.168.x.x:8089/me first

Serial

Note that I use Serial for PZEM004Tv30 module

PZEM004Tv30 pzem(&Serial);

Other information goes to Serial1 not Serial (so you will not see things in serial monitor)

Serial1.begin(115200);

远程连接AVH的主机

这里的AVH是指Arm Virtual Hardware,可以在线访问的虚拟开发板。

AVH支持两种模式远程登录内网的主机。

一是OpenVPN,下载配置文件导入即可。

二是SSH,添加密钥后即可。

OpenVPN的比较傻瓜,这里就不赘述了。

SSH的话,可以用以下命令:
ssh -J c9922a0f-edcb-486d-b84f-9508262abeb1@proxy.app.avh.arm.com pi@10.11.0.1

你也可以使用~/.ssh/config提前配置好跳转主机。