--------------------------------------------------------
for /l %i in (0,1,255) do ping -w 1 -n 1 192.168.3.%i
--------------------------------------------------------
for /l %i in (0,1,255) do ping -w 1 -n 1 192.168.3.%i
WiFi Web Server on BBC micro:bit and ESP-01 (ESP8266) - Hackster.io でけた!
192.168.4.1でLEDオンオフできそうだ ATバシバシコード
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
-------------microbit and raspi uart com -----------------------------------------------
Rapberry PiとBBC Micro:bitでUARTを試す - saitodev.co あっさり成功
ーーーーーーthingspeakーーーーーーーーーーーーーーーーーーーーーーーーーーー
データを簡単に保存&グラフ化できるThingSpeakが便利! - iwathiの/var/log (hatenablog.com) これはブラウザのget機能をもちいた方法であった
ThingSpeakに登録してcurlでデータを送ってグラフを表示するまで #curl - Qiita このcurlはウィンドウズのではだめでリナックスでのでOKだった
センサーの計測値をクラウドにためて見てみる | SG Labs これのcurlはpost仕様だった
例題として以下を試行。。。。宿題
ESP32 Publish Sensor Readings to ThingSpeak (easiest way) | Random Nerd Tutorials
ちなみにmicrobitではgroveという拡張機能のUartWiFiをもちいて成功!
ーーーーesp01 2kindーーーーーーーuno,pico ok ーーーーーーーーーーーーーーーー
amazonから購入した4pinアダプタ方式esp01は通常とちがい、Unoにブランクコードをいれ
rx->rx,tx->txでつなぐとATがうごいた AC電源から電圧変換して5vでうごいた!
もうひとつのesp01sは3vでうごく!
---------------------for arduinoUNO -------------------------------------------
以下のコードはEsp01のRxをUnoの3pin,TxをUnoの2pinにして動いた!
ifttt line連携もばっちりだった
#include "ArduinoESPAT.h" // rx 2 tx 3であったので辻褄はあう
ESPAT espat("184F32CF8BF3-2G","2215085363556");
void setup(){
Serial.begin(115200);
if(espat.begin()){
Serial.println("Initialize Ok");
}else{
Serial.println("Initialize Fail");
}
if(espat.changeMode(1)){
Serial.println("Mode OK");
}else{
Serial.println("Mode not OK");
}
if(espat.tryConnectAP()){
Serial.println("Connected");
}else{
Serial.println("Connect Failed");
}
Serial.println(espat.clientIP());
Serial.println(espat.get("www.yahoo.co.jp", "/", 80));
//ここはエラーになるのでhttpなサイトをさがそう
Serial.println("Finished");
}
void loop(){
}
------------------for pico ----------------------------------------------
https://microcontrollerslab.com/esp8266-wifi-module-raspberry-pi-pico-web-server/
上記のパチモンつかうので5VとGNDをACアダプタからとり、あとはGNDを共通化して
picoの1番がTX、2番がRXなのでesp01のRx、esp01のTxとつなぐ Unoと一緒でクロス
SSID,PWDを自分のネットにする! コレハバッチリ!
https://randomnerdtutorials.com/esp32-cam-take-photo-save-microsd-card/
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
LINE各機種で
-------obniz --------------------------------------------------------
https://toyoshi.hatenablog.com/entry/2020/01/18/123904 成功(node.js)
Node.js経由でRaspberryPiやObnizからLINEへの通知を行ってみる - uepon日々の備忘録 (hatenadiary.com) これは参考
---------esp32 and jpg---------------------------------------------------------
ESP32とOV2640でJPEG画像をLINE通知【④プログラム】 | IT太郎の趣味ルーム (it-taro.com) これ宿題
-------------esp32-----------------------------------
https://www.ekit-tech.com/?p=3434 あっさり成功
ーーーーーーーーーーーーーーーーーー
まずラズパイで写真から
# 通知をLINEに挿入 --- (*2)
TOKEN='qmapg2FRrm4gt1V9Qfupz6eIAa05jDTNAw7xoGIU31Q'
API = 'https://notify-api.line.me/api/notify'
import requests
fname='./image.jpg'
post_data = {'message': '侵入者アリ'}
headers = {'Authorization': 'Bearer ' + TOKEN}
files={'imageFile': open(fname,'rb')}
requests.post(API, data=post_data,headers=headers,files=files)
import requests
url = "https://notify-api.line.me/api/notify"
token = "トークン"
headers = {"Authorization" : "Bearer "+ token}
message = "そぞら@プログラミングに夢中すぎる会社員より"
payload = {"message" : message}
r = requests.post(url, headers = headers, params=payload)
ーーーーーーつぎはラズピコwでーーーーーーーーーーーーーーーーーーーーーーーー
https://zenn.dev/iot101/articles/d8e26ac7be133b を参考にlinenotify.pyをいれてから
import machine
from time import sleep
import network, urequests
ssid = '184F32CF8BF3-2G'
password = 'パスワード'
def connect():
#Connect to WLAN
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while wlan.isconnected() == False:
print('Waiting for connection...')
sleep(1)
print(wlan.ifconfig())
connect()
from linenotify import LineNotify
# Line token
TOKEN = "qmapg2FRrm4gt1V9Qfupz6eIAa05jDTNAw7xoGIU31Q"
# Make instance
line = LineNotify(TOKEN)
# Send text message
print("テキスト送信中")
result = line.notify('こんにちは。Line Botです。')
print("result:", result)
# Show sticker/stamp
print("スタンプ送信中")
result2 = line.notifySticker(3,230,'これはスタンプです。')
print("result2:", result)
## raspberry pi pico w wifi code :: # is softap, hard code is station mode
from machine import Pin,PWM
import network
import socket
import utime
# LED = machine.Pin("LED",machine.Pin.OUT) #builtin led
IN1 = PWM(Pin(14))
IN2 = PWM(Pin(15))
IN1.freq(100)
IN2.freq(100)
IN3 = PWM(Pin(16))
IN4 = PWM(Pin(17))
IN3.freq(100)
IN4.freq(100)
#IN1 = Pin(14,Pin.OUT)
#IN2 = Pin(15,Pin.OUT)
#IN3 = Pin(16,Pin.OUT)
#IN4 = Pin(17,Pin.OUT)
max_duty = 65025
# from metaele labo site
def stop():
IN1.duty_u16(0)
IN2.duty_u16(0)
IN3.duty_u16(0)
IN4.duty_u16(0)
utime.sleep(0.5)
#IN1.value(0)
#IN2.value(0)
#IN3.value(0)
#IN4.value(0)
#utime.sleep(0.5)
def front():
IN1.duty_u16(int(max_duty*0.5))
IN2.duty_u16(0)
IN3.duty_u16(int(max_duty*0.5))
IN4.duty_u16(0)
#IN1.value(1)
#IN2.value(0)
#IN3.value(1)
#IN4.value(0)
utime.sleep(0.5)
stop()
def back():
IN1.duty_u16(0)
IN2.duty_u16(int(max_duty*0.5))
IN3.duty_u16(0)
IN4.duty_u16(int(max_duty*0.5))
#IN1.value(0)
#IN2.value(1)
#IN3.value(0)
#IN4.value(1)
utime.sleep(0.5)
stop()
def left():
IN1.duty_u16(int(max_duty*0.5))
IN2.duty_u16(0)
IN3.duty_u16(0)
IN4.duty_u16(int(max_duty*0.5))
#IN1.value(1)
#IN2.value(0)
#IN3.value(0)
#IN4.value(1)
utime.sleep(0.5)
stop()
def right():
IN1.duty_u16(0)
IN2.duty_u16(int(max_duty*0.5))
IN3.duty_u16(int(max_duty*0.5))
IN4.duty_u16(0)
#IN1.value(0)
#IN2.value(1)
#IN3.value(1)
#IN4.value(0)
utime.sleep(0.5)
stop()
#ssid = 'RPI_PICO_AP'
#password = '12345678'
ssid = '184F32CF8BF3-2G'
password = '2215085363556'
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while wlan.isconnected() == False:
print('Connecting to Wi-Fi router')
utime.sleep(1)
wlan_status = wlan.ifconfig()
print('Connected!')
print(f'IP Address: {wlan_status[0]}')
print(f'Netmask: {wlan_status[1]}')
print(f'Default Gateway: {wlan_status[2]}')
print(f'Name Server: {wlan_status[3]}')
#ap = network.WLAN(network.AP_IF)
#ap.config(essid=ssid, password=password)
#ap.active(True) #activating
#while ap.active() == False:
# pass
#print('Connection is successful')
#print(ap.ifconfig())
# print('listening on', ap.ifconfig()[0]) # wlan change to ap fof softap mode
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)
#html
def home_page():
html = """<html>
<title>Tank Control</title>
<center>
<h>Tank Control</h1>
<p>
<a href="/front"><input type="button" value="front"></a>
<a href="/back"><input type="button" value="back"></a>
</p>
<p>
<a href="/right"><input type="button" value="right"></a>
<a href="/left"><input type="button" value="left"></a>
</p>
</center>
<html>"""
return html
while True:
cl,addr = s.accept()
print("req from = ")
print(addr)
request = cl.recv(1024)
request = str(request)
if request.find("/front") ==6:
front()
if request.find("/back") ==6:
back()
if request.find("/right") ==6:
right()
if request.find("/left") ==6:
left()
response = home_page()
cl.send(response)
cl.close()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Arduinoを使いBluetooth通信をやってみる!HC-05/HC-06 Bluetoothモジュールの使い方! | ぶらり@web走り書き (burariweb.info) 総論
micro:bitとつなぐにはswitch scienceのi2cロジック変換を用いてTX,RXをクロス接続
5Vと3Vの接続は不要だった HC05のGNDはmicrobitのGNDに直付けする
ーーーーーーーーーーーーーー templates/main.html ------------------------------
<html><head><title>Current Status</title></head>
<body>
<h1>Device Listing and Status</h1>
{% for pin in pins %}
{% if pins[pin].name == "for-back": %}
<p>The {{ pins[pin].name }}</br></br>
(<a href="/{{pin}}/for">forward</a>)
(<a href="/{{pin}}/back">backward</a>)</br>
</p>
{% elif pins[pin].name == "left-right": %}
<p>The {{ pins[pin].name }}</br></br>
(<a href="/{{pin}}/left">left</a>)
(<a href="/{{pin}}/right">right</a>)</br>
</p>
{% endif %}
{% endfor %}
{% if message %}
<h2>{{message}}</h2>
{% endif %}
</body></html>
------------------------- weblamp-radicon.py --------------------------------
だいぶ論理が冗長なので将来変更しようと思う
from gpiozero import LED, Motor
from time import sleep
from flask import Flask, render_template, request
app = Flask(__name__)
motor = Motor(forward=19, backward=26,pwm=True)
motor2 = Motor(forward=12, backward=16,pwm=True)
pins = {
23 : {'name' : 'for-back'},
25 : {'name' : 'left-right'}
}
led23 = LED(23)
led23.off()
led25 = LED(25)
led25.off()
@app.route("/")
def main():
templateData = {
'pins' : pins
}
return render_template('main.html', **templateData)
@app.route("/<changePin>/<action>")
def action(changePin, action):
changePin = int(changePin)
deviceName = pins[changePin]['name']
if action == "for":
if changePin == 23:
led23.on()
motor.forward(0.3)
motor2.forward(0.3)
sleep(2)
motor.stop()
motor2.stop()
message = "Turned " + deviceName + " to for."
if action == "back":
if changePin == 23:
led23.off()
motor.backward(0.3)
motor.backward(0.3)
sleep(2)
motor.stop()
motor2.stop()
message = "Turned " + deviceName + " to back."
if action == "left":
if changePin == 25:
led25.on()
motor.forward(0.3)
motor2.backward(0.3)
sleep(2)
motor.stop()
motor2.stop()
message = "Turned " + deviceName + " to left."
if action == "right":
if changePin == 25:
led25.off()
motor.backward(0.3)
motor2.forward(0.3)
sleep(2)
motor.stop()
motor2.stop()
message = "Turned " + deviceName + " to left."
templateData = {
'message' : message,
'pins' : pins
}
return render_template('main.html', **templateData)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80, debug=True)
https://vefortec.hatenablog.com/entry/raspberrypi-webiopi 64bitOSでも成功
ただしBBKSのそれは難解だ。。。
----------------------------------------------------
https://gpiozero.readthedocs.io/en/stable/api_output.html :: drv8833 OK
from gpiozero import Motor
from time import sleep
motor = Motor(forward=19, backward=26,pwm=True) #PWM 0~1が可能に!
while True:
motor.forward(0.2)
sleep(2)
motor.forward(0.9)
sleep(0.5)
print("f")
motor.stop()
sleep(1)
motor.backward()
sleep(0.5)
print("b")
motor.stop()
sleep(1)
Raspberry PiのハードウェアPWMをpigpioで出力する #RaspberryPi - Qiita
【 第33回 】pigpioにはハードウェアPWM発生関数”hardware_PWM”もあった! | FABSHOP.JP -デジタルでものづくり! ファブショップ ! この2個のサイトでbbks理解!
------------picozero----------------------------------------------
https://picozero.readthedocs.io/en/latest/recipes.html :: gpiozero相当品
----------------------------------------------------------------------------------
https://tech-and-investment.com/raspberrypi-pico-14-gpio-interrupt/ ::
通常のやつだがスイッチをpull-downでつかうので制限抵抗必須!
MicroPython的午睡(25) ラズパイPico、Timer周波数設定の上限? | デバイスビジネス開拓団 (jhalfmoon.com) これがタイマー割り込みのようだ たぶんesp32でも一緒
------------------------------------------------------------
https://iot.keicode.com/arduino/arduino-tm1637.php :: 7seg-i2c at arduinoだがラズパイでするには