Relative Content

Author Archive for chen

WeMos (b2) BMP280 SPI気圧温度表示

  気圧センサーとNikia 5110と同時に使いたい。 まず前回BMP180センサーの利用を考える。こちらはI2Cで通信する。WemosのPinoutを見ると、SPIとI2Cは共有するなく、同時に使えそうだが、しかしいくら試してもうまくいかない。 そこでBMP280センサーの利用を考える。こちらは、SPIとI2C両方利用可能。 The chip select (CSB) and serial data output (SDO) pins of the BMP 280 are necessary only when SPI-based (four-wire) communication is applied. For SPI, keep an eye on the pin assignments: VCC-VCC/GND-GND/SCL-SCK/SDA-MOSI/CSB-SS/SDO-MISO. Now to the official schematic of the GY-BM E/P 280 module: ライブラリの追加 センサーをライブラリ追加 BMP280センサーを利用する ライブラリからBMP280を検索して、追加してください  測定値 まずSPIで気圧を測って見る。 […]

WeMos (6) Nikia 5110表示

こちらを参考して、苦労してなんとか表示できた。 下記のライブラリを追加してください Adafruit GFX Library Adafruit PCD8544 Nokia 5110 LCD library 問題は、2番目のライブラリは、そのままWeMosに対応できない、エラーがたくさん発生する! 下記のプルリクエストが無視された見たい、手動で手元のライブラリに応用してください adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library#27   配線: WeMos D1 Mini Nokia 5110 PCD8544 LCD Description D2 (GPIO4) 0 RST Output from ESP to reset display D1 (GPIO5) 1 CE Output from ESP to chip select/enable display D6 (GPIO12) 2 DC Output from display data/command to ESP […]

Arduino UNO (7) L298N

Arduino UNO でCarのモーターを動かす。 接続方法 Library追加 L298N Dual H-Bridge library for controlling via PWN 2 motors https://github.com/yohendry/arduino_L298N テストプログラム #include <L298N.h> const int ENA = 6; const int IN1 = 9; const int IN2 = 7; const int IN3 = 2; const int IN4 = 4; const int ENB = 3; L298N driver(ENA,IN1,IN2,IN3,IN4,ENB); int time_delay = 500; […]

WeMos (b1) BMP180 I2C気圧温度表示

Specification Pressure sensing range: 300-1100 hPa (9000m to -500m above sea level) Up to 0.03hPa / 0.25m resolution -40 to +85°C operational range, +-2°C temperature accuracy Wiring Make the following connections GND <-> GND 3V3 <-> VIN (or 3Vo) D1 <-> SCL D2 <-> SDA ライブラリの追加 “Adafruit Unified Sensor”ライブラリの追加 センサーをライブラリ追加 BMP180センサーを利用する ライブラリからBMP085を検索して、追加してください 単体プログラム ただシリアルモニタに表示するだけのプログラム #include […]

Arduino UNO (6) i2c scanner

i2c のアドレスを確かめるため、下記のプログラムを動かせばいい。 // ————————————– // i2c_scanner // // Version 1 // This program (or code that looks like it) // can be found in many places. // For example on the Arduino.cc forum. // The original author is not know. // Version 2, Juni 2012, Using Arduino 1.0.1 // Adapted to be as simple as […]

WeMos (5) TM1637 7段4桁LED表示

7段4桁LED を表示してみる 参考のURLの通り、試しただけ。 TM1637 用ライブラリをインストール ライブラリをダウンロード https://github.com/avishorp/TM1637 ライブラリを Arduino IDE にインストール Arduino IDE の [スケッチ] → [ライブラリを使用] → [ライブラリをインストール…] からダウンロードしたライブラリ ZIP を選択しインストールする。 繋がる const int CLK = D6; //Set the CLK pin connection to the display const int DIO = D5; //Set the DIO pin connection to the display スケッチを作成する #include <TM1637Display.h> const int CLK […]

WeMos (4) 1602 LCD i2c 表示

1602 LCD直接繋ぐと、6つのデジタルポートを占有(4つデータワイヤ+2の制御ワイヤが必要)し、GPIOはたくさん消耗するので、i2cを利用すると2つのアナログポートが足りる。 下記のURLから、ライブラリを利用 https://github.com/agnunez/ESP8266-I2C-LCD1602 しかし、表示がない! 持っている他のUno, Nanaに試したら、ちゃんと表示した。 LCD address to 0x27も間違いない。 どうして? /* * 1602 LCD Sample with LiquidCrystal_I2 * https://github.com/agnunez/ESP8266-I2C-LCD1602 * * PCF8574—–1602LCD—–WeMos * A0 —–GND * A1 —–GND * A2 —–GND * VSS —–GND * P0 —– RS * P1 —– RW * P2 —– EN * P3 —– B/L * P4 —– […]

Arduino UNO (5) BLE + 1602 LCD

BLE受信したデータは、1602 LCD表示するようにプログラムを改造。 受信があると、LCDに起動時間と受信文字が表示される。 ただ、複数の文字を送ると、最後の文字しか残らない。 #include <SoftwareSerial.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); SoftwareSerial mySerial(7, 8); // RX, TX // Connect HM10 Arduino Uno // Pin 1/TXD Pin 7 // Pin 2/RXD Pin 8 void setup() { lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print(“BLE Test:”); Serial.begin(9600); // If the baudrate of the HM-10 module has been updated, // you may […]

Arduino UNO (4) BLE

いよいよBLEの実験を開始。Bluetooth 4.0 モジュールを使って、Android AppとArduinoを通信する。 まず持っているBluetooth 4.0 モジュールは、HM10 互換というから、参考になるものを探す。 なぜか、接続表のように、RX0/TX0からBluetoothモジュールとUNOボードを接続すると、プログラムを書き込みできない。 一旦切り離して、プログラムを書き込みおわったら、また接続すればうまくいく。 #もしかしてこれは常識??? Bluetooth 4.0 Arduino UNO R3ボード VCC 5V GND GND TXD RX0(pin0) RXD TX0(pin1) そのため接続表のように、D7/D8からBluetoothモジュールとUNOボードを接続する。 Bluetooth 4.0 Arduino UNOボード VCC 5V GND GND TXD pin 7 RXD pin 8 プログラム: #include <SoftwareSerial.h> SoftwareSerial mySerial(7, 8); // RX, TX // Connect HM10 Arduino Uno // Pin […]

Arduino UNO (3) 1602 LCD i2c 表示

1602 LCD直接繋ぐと、6つのデジタルポートを占有(4つデータワイヤ+2の制御ワイヤが必要)し、GPIOはたくさん消耗するので、i2cを利用すると2つのアナログポートが足りる。 WeMosで試すと、うまくいかないので、より汎用のこのNANOで試す。すんなりうまくいく。行きよいでUnoにも試す。これを成功することて、次に、BLT通信を実験するさい、受信文字をモニタリングできる。 I2C インターフェイス SDA、SCL は Arduino Uno ではそれぞれ A4、A5 です。 Arduino Uno R3 SDA A4 SCL A5   Arduino UnoのバージョンR3では、SDA、SCLピンが存在する。 以前のバージョンではSDAがA4ピン、SCLがA5ピンにそれぞれ割り当てられているが、R3についてもこのピンをI2C通信時に兼用しているため、A4、A5ピンは使用できない。 サンプルプログラム。 #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); void setup() { lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print(“Hello, world!”); } void loop(){ // set the cursor to column 0, line 1 // (note: line 1 is the second […]