Program Resource

Resource libraries for programmers and developers

Using Infrared-Temperature sensor GY-906 MLX90614

Using Infrared-Temperature sensor GY-906 MLX90614

Recently, I bought cheap infrared temperature sensor, GY-906 from aliexpress, only about $5 including shipping fee. Adafruit MLX90614 library can be used for this module. https://github.com/adafruit/Adafruit-MLX90614-Library Communication via I2C and address is 0x5A. I thought using device is simple as other sensor device; but didn’t work as expected, returning fixed value, 1037.55. After searching through forum, found out that changing I2C frequency to 50000 makes this thing work. I can set frequency at Wire.begin if this is only device I’m using, but once I try to use OLED to show readout, OLED works but sensor stops working again. Finally, I was able to make both OLED and sensor to work …

M5Stack and MPU9250 as Bluetooth gyro mouse

M5Stack and MPU9250 as Bluetooth gyro mouse

Thanks to author of library, Bluetooth mouse library is available for ESP32 devices. I’ll be making Bluetooth mouse with M5Stack this time. https://github.com/T-vK/ESP32-BLE-Mouse Download and install library from above site. There are many ideas, such us using joystick, to control mouse. This time, I’ll use MPU9250 gyro sensor. Connect sensor with I2C wiring. There are M5Stack models which has gyro sensor inside. For those M5Stack models, only thing you need is M5Stack itself only. Tweet from M5Stack official below shows good table of difference between models. Check MEMS row. Sketch is as follows. M5Stack is used upside down. Button C for left click, A for right click, hold down B …

Use M5Stack as Bluetooth keyboard and control presentation

Use M5Stack as Bluetooth keyboard and control presentation

ESP32 devices can be used as Bluetooth device, such as mouse or keyboard. It was hard to write sketch while ago, but now, there’s handy library which you can easily make ESP32 to Bluetooth hid device. This time, I’ll be using M5Stack to work as simple PowerPoint controller. Download and install library from URL below for Bluetooth Keyboard. https://github.com/T-vK/ESP32-BLE-Keyboard After installing library is simple. Call begin, then press/release function to send key. Since M5Stack have 3 buttons, I’ve assigned Home, Page Up, and Page Down key to them. You can also do some more complicated control using long hold button, etc. After writing sketch to M5Stack and booting, you will …

Font Editor for Paroala Dot Matrix display library

Font Editor for Paroala Dot Matrix display library

Parola is nice library with various animation function to show texts to dot matrix display with MAX7219 controller. There are excel macro and exe based tool to create your own customized fonts included in library. I’ve also created simple font editor which reads font header file and writes out to header file format. For Windows, use at your own risk. Create new from scratch, or start with font file such as included in sample sketch of Parola library. One font data per font file is supported. Name is font name. Comment is saved as comment in header file. Fixed width will create fixed pitch font. Set Auto for width to …

Declaration of SoftwareSerial causes build error

Declaration of SoftwareSerial causes build error

With board package ESP8266 newer than 2.5.0, declaration of SoftwareSerial like below causes build error. Above type declaration can be found in sample sketch for Adafruit VC0706 serial jpeg camera. https://github.com/adafruit/Adafruit-VC0706-Serial-Camera-Library/blob/master/examples/Snapshot/Snapshot.ino Resulting error message. To fix this issue, change declaration to below. Latest ESP8266 SoftwareSerial library uses EspSoftwareSerial from Peter Lerup; you can also code like below.

Reset Aruduino once after power up

Reset Aruduino once after power up

There are some case that arduino and/or connected devices doesn’t work right after powering up. Putting some delay does not work, and everything starts working after pressing reset button on Arduino. So, below is simple trick to restart Arduino once after powering up. Simply write 1 or 0 to EEPROM after each boot.

Show QR code on OLED display with Arduino

Show QR code on OLED display with Arduino

There’s QR code library for Arduino released 3 years ago. https://github.com/ricmoo/qrcode/ Well made library, works with less memory of Arduino while supporting QR code versions and error correction levels. You can easily create QR code data with above library and show code to OLED display with u8glib library. Below is sample sketch for showing QR code with “https://programresource.net” text data to OLED display, with inverted B/W on left / right half of screen. Very short and simple sketch which does amazing work.

Show only board / settings you want in Arduino IDE menu

Show only board / settings you want in Arduino IDE menu

Arduino IDE supports huge amount of devices for developing. However, when you install ESP32 and ESP8266 board package, menu list will be horrible. It is annoying when you reselect ESP8266 board and see all Upload Speed, memory size, etc falls back to default. Board information are stored in boards.txt file. You can edit this file to hide items you don’t want to see. Default boards.txt for Arduino is stored under ESP type files are or something similar. File is in text format, and you see line like below. To hide specific board, comment out all line with #, or add line with board id + “.hide = true” option. For …

Easy access web page when using ESP8266/ESP32 as Web Server and Access Point

Easy access web page when using ESP8266/ESP32 as Web Server and Access Point

ESP8266 / ESP32 can be easily used as Web server. Also, ESP device can connect to internet via Wi-Fi, or itself can be used as Access Point. Some usage are, connect to ESP device from Smartphone, open web page, configure setting or control peripheral device. E.g. ESP as smart plug controller, configure on/off scheduling time, or ESP as remote-controlled robot with servo and motor, and control using browser interface. One annoying thing when using ESP as access point / web server is, after connecting to ESP device from Smartphone, I have to open browser and type in IP address in URL and open page. Well, this can be automated using …

Show bitmap image on OLED display with Arduino/ESP board (Tool provided)

Show bitmap image on OLED display with Arduino/ESP board (Tool provided)

I2C connection Monochrome OLED display is very handy to use. Easy wiring and various libraries provided, such as Adafruit GFX, u8glib, u8g2lib. Monochrome bitmap can also be displayed. You need to prepare bitmap image and convert to hex data. There are tools you can download, but I couldn’t find one that is easy to use. So, I’ve created easy-to-use tool to convert bmp file to hex data (for Windows). Built with Visual Studio / C++. Use freely, no support, use at your own risk. Simply create bitmap file with MS paintbrush for example, save as 24bit bmp file. Launch tool, drag and drop bmp file to tool. You get hex …