#author("2025-06-13T07:42:22+09:00","","") #author("2025-07-22T21:31:30+09:00","","") [[MenuBar]] * Arduinoの firmware と Android のアプリ [#ba2a5d6c] - https://github.com/takashiyamanoue/Twitter2NeoMatrixEx41 - このfirmwareとアプリで、以下のソフトウェアを利用させていただいています。感謝します。 -- Arduino IDE -- Software for NeoPixel and NeoMatrix --- https://learn.adafruit.com/adafruit-neopixel-uberguide/overview -- Android OS -- ADK -- Apache http client -- Twitter4j * Android + Arduino Mega ADK から Raspberry Pi Zero + Raspberry Pi Pico へ移行中 [#ife76aef] *** Raspberry Pi Zero [#v2c7949a] - systemd, start sh -- /etc/systemd/system/wiki_bot.service #code(systemd){{ [Unit] Description=wiki_bot After=network.target [Service] User=pi Type=simple WorkingDirectory=/home/pi/python ExecStart=/home/pi/python/start_wiki_bot.sh [Install] WantedBy=multi-user.target }} -- /home/pi/python/start_wiki_bot.sh #code(sh){{ #!/usr/bin/bash sleep 120 xhost + export DISPLAY=:0.0 cd /home/pi/python source testpip/bin/activate python3 wiki_bot_07.py -s }} - bot --- [[wiki_bot_ex07.py]] - external -- [[wearable_sign_01.py]] -- [[wearable_sign_02.py]] -- [[wearable_sign_03.py]] -- [[wearable_sign_05.py]] -- [[wearable_sign_06.py]] -- [[tcp_server_ex1.py]] *** Raspberry Pi Pico (Arduiono IDE) [#x04edf7c] - [[pi_i2c_pico_neomatrix_ex01.ino]] - [[pi_i2c_pico_neomatrix_ex02.ino]] * Raspberry Pi Zero + Raspberry Pi Pico + GPS ... 場所依存表示可能バージョン [#k4b233ba] ** Hardware [#ta69334c] Raspberry Pi Zero 2 <-> GPIO i2c 400khz-> Raspberry Pi Pico (arduino) <-> GPIO UART <-> Adafruit Ultimate GPS *** i2c 400khz[#da641f52] - Razpebeery Pi Zero side -- https://qiita.com/GeekMasahiro/items/23d1ebe926835524ca41 -- https://www.raspberrypi-spy.co.uk/2018/02/change-raspberry-pi-i2c-bus-speed/ - Raspberry Pi Pico side -- in the setup() #code(c){{ // initialize i2c as slave Wire.setSDA(4); Wire.setSCL(5); Wire.begin(SLAVE_ADDRESS+x); Wire.setClock( 400000UL); //Wire.setClock(400000); //400Khz i2c clock //Serial.print("Wire.begin(...)"); // define callbacks for i2c communication Wire.onReceive(receiveEvent); Wire.onRequest(requestEvent); }} --- [[pi_i2c_pico_neomatrix_ex02.ino]] *** gps [#p5ec2dd4] - https://learn.adafruit.com/adafruit-ultimate-gps-on-the-raspberry-pi/using-uart-instead-of-usb - https://www.itmedia.co.jp/news/articles/2205/03/news019.html - /etc/default/gpsd #code(c){{ # Devices gpsd should collect to at boot time. # They need to be read/writeable, either by user gpsd or the group dialout. #DEVICES="" DEVICES="/dev/serial0" # Other options you want to pass to gpsd #GPSD_OPTIONS="" GPSD_OPTIONS="-F /var/run/gpsd.sock" # Automatically hot add/remove USB GPS devices via gpsdctl #USBAUTO="true" }} ** Software [#ec593f17] - systemd, start sh -- /etc/systemd/system/wiki_bot.service #code(systemd){{ [Unit] Description=wiki_bot After=network.target [Service] User=pi Type=simple WorkingDirectory=/home/pi/python ExecStart=/home/pi/python/start_wiki_bot.sh [Install] WantedBy=multi-user.target }} -- /home/pi/python/start_wiki_bot.sh #code(sh){{ #!/usr/bin/bash sleep 120 xhost + export DISPLAY=:0.0 cd /home/pi/python source testpip/bin/activate python3 wiki_bot_08.py -s }} -- /home/pi/python/start_wiki_bot.sh ... LINE Bot 接続版 #code(sh){{ #!/usr/bin/bash sleep 120 xhost + export DISPLAY=:0.0 cd /home/pi/python/line-bot ngrok http --domain=<ngrok static domain> 3000 & cd /home/pi/python source testpip/bin/activate python3 wiki_bot_09.py -s }} - bot --- [[wiki_bot_ex08.py]] --- gps関連追加部分 #code(python){{ from gps3 import gps3 import math class pico_wiki_bot: gps_time="n/a_" gps_lat="n/a_" gps_lon="n/a_" gps_alt="n/a_" gps_speed="n/a_" def __init__(self): # # gps thread # self.gps_thread=threading.Thread(target=self.start_gps) print('new thread, start gps_thread') #self.start_script() print('self.gps_thread.start()') self.gps_thread.start() print('script_started.') # def start_gps(self): print('start_gps') try: gps_socket = gps3.GPSDSocket() data_stream = gps3.DataStream() gps_socket.connect() gps_socket.watch() for new_data in gps_socket: if new_data: data_stream.unpack(new_data) self.gps_time=data_stream.TPV['time'] self.gps_lat=data_stream.TPV['lat'] self.gps_lon=data_stream.TPV['lon'] self.gps_alt=data_stream.TPV['alt'] self.gps_speed=data_stream.TPV['speed'] #print('time : ', self.gps_time) #print('lat : ', self.gps_lat) #print('lon : ', self.gps_lon) #print('alt : ', self.gps_alt) #print('speed : ', self.gps_speed) except Exception as e: import traceback traceback.print_exc() print(e) print('error') return def geo_distance(self,lat_1,lon_1, lat_2, lon_2): #degree if type(lat_1) is str: return "n/a" if type(lon_1) is str: return "n/a" if type(lat_2) is str: return "n/a" if type(lon_2) is str: return "n/a" pole_radius = 6356752.314245 # 極半径 equator_radius = 6378137.0 # 赤道半径 da1r=lat_1*3.1415926535/180.0 do1r=lon_1*3.1415926535/180.0 da2r=lat_2*3.1415926535/180.0 do2r=lon_2*3.1415926535/180.0 lat_difference = da1r - da2r # 緯度差 lon_difference = do1r - do2r # 経度差 lat_average = (da1r + da2r) / 2.0 # 平均緯度 e2 = (pow(equator_radius, 2) - pow(pole_radius, 2)) / pow(equator_radius, 2) # 第一離心率^2 w = math.sqrt(1- e2 * pow(math.sin(lat_average), 2)) m = equator_radius * (1 - e2) / pow(w, 3) # 子午線曲率半径 n = equator_radius / w # 卯酉線曲半径 distance = math.sqrt(pow(m * lat_difference, 2) + pow(n * lon_difference * math.cos(lat_average), 2)) # 距離計測 print('distance={:f}'.format(distance)) return distance }} - external -- [[wearable_sign_01.py]] -- [[wearable_sign_02.py]] -- [[wearable_sign_03.py]] -- [[wearable_sign_05.py]] -- [[wearable_sign_06.py]] -- [[tcp_server_ex1.py]] *** Raspberry Pi Pico (Arduiono IDE) [#x04edf7c] - [[pi_i2c_pico_neomatrix_ex01.ino]] - [[pi_i2c_pico_neomatrix_ex02.ino]] *** wiki page [#ga0da709] - https://www2.yama-lab.org/twitter2NeoMatrix/?wiki_page_gps_ex01 * BDF東雲明朝16x16 フォント [#b542b46a] - 作成、公開、保守された皆様に感謝します。 - http://openlab.ring.gr.jp/efont/shinonome/ -- &ref(Required-Software-and-Data/ShinonomeMin_16.pdb); ---- #counter