Relative Content

Author Archive for Ubiquitous Sensing

WeMos D1 Connect to Firebase

ネットで検索すると、大抵はArduinoからFirebaseのAPIを叩くためのFirebaseArduinoというライブラリを利用する例が公開されている。しかしそのライブラリは、もう数年前からメンテナンス停止した。 試しにサンプルなど動かしてみたが、Firebaseに繋がらない。 色々と調べて、MobizTのライブラリを利用することで成功した。 https://github.com/mobizt/Firebase-ESP8266 いきなり参考リンクから本番プログラムを作ると動かないので、サンプルの Beginner_start_here をまずお試し。 https://github.com/mobizt/Firebase-ESP8266/tree/master/examples/Beginner_start_here (誤り)API KEYを使う (正しい)スークレドを使う Firebaseから、LEDの色と明るさの制御はできた。 #include “FirebaseESP8266.h” #include <ESP8266WiFi.h> #include <Adafruit_NeoPixel.h> #define PIN D1 #define NUM_LEDS 8 const char* ssid = “ssid003”; const char* password = “12345”; FirebaseData firebaseData; Adafruit_NeoPixel leds(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800); // Current color values int redValue = 0; int greenValue = 0; int blueValue […]

WeMos (e3) リレー制御

制御の試し 参考資料1そのまま。 /* * Relay Shield – Blink * Turns on the relay for two seconds, then off for two seconds, repeatedly. * * Relay Shield transistor closes relay when D1 is HIGH */ const int relayPin = D1; const long interval = 2000; // pause for two seconds void setup() { pinMode(relayPin, OUTPUT); } […]

App Inventorで管理App

App InventorでFirebase管理Appは参考1に完成した物を参考にした。 App 画面デザイン ブロック 参考 https://www.instructables.com/Iot-Weather-Station-Using-Firebase-and-MIT-App-Inv/  

Thunkableで管理App

画面デザイン Speechのお試しプログラムに、Realtime_DBモジュールを追加した。 プログラム Thunkableには、Cloud変数は、Realtime_DBに対応するので、Cloud変数の読み書きで、簡単にRealtime_DBのデータの読み書きができる。  

WordPressとの連携(1)

WordPressにFirebaseデータの公開 Integrate Firebaseプラグイン The Integrate Firebase Plugin will help a Firebase user to login to your WordPress interface – not to WordPress dashboard – from Firebase authentication. You can show user info display data that is only available to your Firebase users. You also can view Real Time Database and Firestore from your Dashboard in […]

Raspberry Piとの連携

Raspberry Piからデータの送信 PCのPythonからFirebase Realtime Database成功、Raspberry Piからも同じ方法で可能 1. Python インストール MacBook : homebrewから Windows : Python 公式サイトから Raspberry Pi: do nothing 2. Frebase-adminをインストール $ sudo apt-get -y install python3-pip $ sudo pip3 install firebase-admin 3. service accountの認証ファイルをダウンロード service account の認証ファイル .json をダウンロード 4. Firebase Realtime Databaseにアクセス プログラムは、参考1からコピー chen@Hongs-MacBook-Pro firebase % python3 firebase.py  {‘user001’: {‘date_of_birth’: ‘June 23, […]

M5StickCからデータ送信

M5StickCからFirebaseへデータ送信。 M5StickC (4) Firebase Arduinoを利用する https://iot.edu2web.com/esp32/ 1. Setup Arduino IDE Arduino IDEがまたインストールしてないの場合、つかうPCにより、下記の何れを参考にArduino IDEのインストールする。 Setup Arduino IDE for Raspberry Pi Setup Arduino IDE for Ubuntu Setup Arduino IDE for Macbook Setup Arduino IDE for Windows 2. USB-UARTドライバのインストール Silicon Labsの以下のURLからドライバをダウンロード USB – UART ブリッジ VCP ドライバ|Silicon Labs 3. Board ManagerにESP32追加 つい最近(20180728), ESP32 用 Arduino 開発環境 Arduino core […]

WeMos (e2) LED表示

IoT Study Kit 2のLEDは、FirebaseのLEDデータに従って表示。 プログラム1 単純に文字、パタンの表示。 3連ベースで、ESP8266, LED Matrix, SHT30を装着する。     Features 8×8 dot matrix LED 8 step adjustable intensity Pins D1 mini GPIO Shield D5 14 CLK D7 13 DIN   ライブラリから、WEMOS_Matrix_Adafruit_GFXを追加してください。 つぎは、ライブラリ付属のLED Matrix表示サンプルの修正版。 # コンパイルエラー発生した。 MLED matrix(7);  から MLED matrix(7, D7, D5); に変更した。   #include <Adafruit_GFX.h> #include <WEMOS_Matrix_GFX.h> MLED matrix(7, D7, D5); //set intensity=7 […]

WeMos (e1) 温度の送信

IoT Study Kit 2からFirebaseへ温度データの送信。   IoT Sensor UbiSense Ver2を利用。 結線 プログラム1 3連ベースで、ESP8266, LED Matrix, SHT30を装着。温度と湿度を計測。 WEMOS_SHT3x_Arduino_Libraryを使用。 https://github.com/wemos/WEMOS_SHT3x_Arduino_Library ただの温度と湿度の表示サンプル。 #include <WEMOS_SHT3X.h> SHT3X sht30(0x45); void setup() { Serial.begin(115200); } void loop() { if(sht30.get()==0){ Serial.print(“Temperature in Celsius : “); Serial.println(sht30.cTemp); Serial.print(“Temperature in Fahrenheit : “); Serial.println(sht30.fTemp); Serial.print(“Relative Humidity : “); Serial.println(sht30.humidity); Serial.println(); } else { Serial.println(“Error!”); } delay(1000); } […]

Firebaseアカウント作成

Firebaseアカウント 「Firebase」は、2011年にシリコンバレー発のスタートアップ・Firebase社がサービスを開始したMobile Backend as a Service(MBaas)です。その後、2014年にGoogleが買収し、Googleの持つクラウドプラットフォームに統合されました。 MBaasはBaaS(Backend as a Service)とも呼ばれており、クラウドデータベースでけではなく、Webアプリケーションやモバイルアプリケーションのバックエンドで行う機能を提供するクラウドサービスです。「Firebase」はアプリ開発者向けのサービスで、バックエンドの処理を代行することで開発にかかる時間・手間の省略が可能で、コスト節約にもつながります。 1)使ってみるをクリック Create your free Firebase project and account 無料 Firebase アカウント作成 2)プロジェクト追加をクリック     3)プロジェクト名と国を選択 4)データベース作成中 5)作成するアプリ種類の選択   「ウェブアプリに Firebase を追加」を選択すると。 apiKey: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,     authDomain: “chen420.firebaseapp.com”,     databaseURL: “https://chen420.firebaseio.com”, 上記のapiKeyが表示される。