Relative Content

Monthly Archives: September 2017

WeMos (b5) I2C (BMP180+OLED)

先日OLEDの文字表示できたが、今度 I2Cに (BMP180+OLED)両方を繋いで、センサーデータの表示を試み。 たまたま、この種類のBMP180とOLEDの結線順番は同じだから、4本線だけで済む。 プログラム /* * */ #include <Wire.h> #include <Adafruit_BMP085.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define OLED_RESET 0 // GPIO0 Adafruit_SSD1306 OLED(OLED_RESET); Adafruit_BMP085 bmp; void setup() { OLED.begin(); OLED.clearDisplay(); //Add stuff into the ‘display buffer’ OLED.setTextWrap(false); OLED.setTextSize(1); OLED.setTextColor(WHITE); OLED.setCursor(0,0); OLED.println(“automatedhome.party”); OLED.display(); //output ‘display buffer’ to screen // OLED.startscrollleft(0x00, 0x0F); //make display scroll if (!bmp.begin()) […]

WeMos (b4) DHT22 温度湿度表示

BMP280気圧センサーとNikia 5110同時に使うため、SPIで通信する環境を作って試したが、相性が悪いようだ。 どちらでも単独では動くが、一緒になると、表示がうあくいかない。 そこで、DHT22という温度湿度を試して見ることに。I2C,SPIどちらでもないので、相性が問題ならないと思う。 これは成功 /* Hello World * Display a simple message on the first line of the screen * * Connections: * WeMos D1 Mini Nokia 5110 Description * (ESP8266) PCD8544 LCD * * D2 (GPIO4) 0 RST Output from ESP to reset display * D1 (GPIO5) 1 CE Output from ESP to […]

WeMos (7) I2C OLED SSD1306 (Adafruit)

仕様 [0.96 インチ 4Pin IIC I2C ブルー OLED ディスプレイ モジュール Arduino対応]を使ってみる。 主な仕様は次のようになっています。 I2C通信 ディスプレイコントローラ: SSD1306 解像度: 128×64 電圧: 3.3V-5V ライブラリ 次の2つライブラリが必要 Adafruit_GFX Adafruit_SSD1306 こちらを参考にして、すんなりできた。下記の2つライブラリもSSD1306対応だ。 ThingPulseのライブラリ(SSD1306, SH1106対応) U8g2ライブラリ(多数OLED対応) 結線 I2Cの場合、デフォルトはSDA、SCLはD1、D2。 サンプルコード デフォルトはSDA、SCLはD1、D2。変更する場合、 Wire.begin(4,5); // OLED:SDA,SCL 行を変更して対応できるらしい。 #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define OLED_RESET 0 // GPIO0 Adafruit_SSD1306 OLED(OLED_RESET); void setup() { // Wire.begin(4,5); // OLED:SDA,SCL OLED.begin(); OLED.clearDisplay(); //Add stuff […]

WeMos (b3) BMP280 I2C

BMP280センサーの利用し、 I2Cで気圧温度を測って見る。 ライブラリの追加 “Adafruit Unified Sensor”ライブラリの追加 センサーをライブラリ追加 BMP280センサーを利用する ライブラリからBMP280を検索して、追加してください 測定プログラム   /*************************************************************************** This is a library for the BMP280 humidity, temperature & pressure sensor Designed specifically to work with the Adafruit BMEP280 Breakout —-> http://www.adafruit.com/products/2651 These sensors use I2C or SPI to communicate, 2 or 4 pins are required to interface. Adafruit invests time and […]

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 […]