Monday, August 20, 2018

Swift Getting Started

1. Variable

var (mutable)
var age = 10
let (immutable)
let name = "Capung"
or with data type:
var age: Int = 10
let name: String = "Capung"
var isCool: Bool = true
let gender: Character = "M"

2. Print log

print()
contoh:
print("Name: ")
print(name) 
print("My Name is \(name)")

3.  If condition

if age > 10 {
    print("older than 10 years old")
} else {
    print("child boy")
}

4. Function

Void/ without return data
func calculate() {
    let a = 2
    let b = 2
    print(a + b)
}

with return data type
func calculate() -> Int {
    let a = 2
    let b = 2
    let c = 1
    return a + b - c
}

with parameter
func calculate(a: Int, b: Int) {
    print(a + b)
}
calculate(a: 1, b: 2)
 or
func calculate(_ a: Int, _ b: Int) {
    print(a + b)
}
calculate(1, 2)

5. Class

class Animal {
    let name: String = "Doggy"
    var age: String = "12 Month"

    func call() {
        print("bark bark bark")
    }

}
let Dog = Animal()
print(Animal.name)
Dog.call()

2018

Saturday, October 14, 2017

[LIBRARY] flipnow

13 October 2017

Intro

Membuat library berbasis npm nodejs.

Goal

Jika dipanggil return "head" atau "tails"

Installation

  npm install git://github.com/fariswd/flipnow.git
OR
  npm install flipnow

Usage

  var flip = require('flipnow');
  console.log(flip.flipNow());

[PROJECT] Bitcoin Watcher

12 October 2017

Intro

Alat pemantau kurs bitcoin dengan bantuan ESP8266 dan lcd16x2. Memanfaatkan API yang disediakan oleh https://www.bitcoin.co.id/.

Goal

Menampilkan harga bitcoin dalam lcd 16x2 (kurs https://www.bitcoin.co.id/)

Gear

- ESP8266 pada "COM6"

Menggunakan library
>LiquidCrystalI2C
Wire Map:
ESP => LCDI2C
D1 => SCL
D2 => SDA
Vin => 5V
Gnd => Gnd

>ArduinoJson untuk parsing json

Catatan

- untuk mengakses https melalui http client diperlukan fingerprint yang dapat digenerate pada: https://www.grc.com/fingerprints.htm
- dokumentasi API bitcoin.co.id: https://vip.bitcoin.co.id/downloads/BITCOINCOID-API-DOCUMENTATION.pdf

[PROJECT] Monitoring CPU & GPU (Temperature & %Usage)

8 October 2017

Intro

Adalah sebuah hardware monitoring yang memonitor suhu dan %usage pada komputer. Dalam hal ini HWInfo Plugin telah menyediakan RESTful API yang dapat diakses dalam bentuk JSON. Dengan bantuan NodeJs untuk mengirimkan value yang diinginkan (dalam hal ini Temperatur & Usage) ke Arduino yang dilengkapi dengan Lcd16x2.

Goal

Menampilkan Temperature dan %Usage dari CPU dan GPU pada PC.

Gear

- HWInfo Plugin

download here https://www.hwinfo.com/forum/Thread-Introducing-Remote-Sensor-Monitor-A-RESTful-Web-Server

- Arduino/esp8266 pada "COM6"

Menggunakan library LiquidCrystalI2C
Wire Map:
ESP => LCDI2C
D1 => SCL
D2 => SDA
Vin => 5V
Gnd => Gnd

- NodeJs

Metode Foreverloop sampai ctrl+c
Menggunakan library:
request = mengambil body dari sebuah halaman website(dalam hal ini ambil json yang digenerate oleh HWInfo Plugin di localhost:55555)
serialport = write serial ke arduino
system-sleep = membuat delay sekian milli second

Catatan

send serial pada COM6 baud rate 9600
send "cl" untuk clear screen
send dengan awalan "1" untuk menulis pada baris 1
send dengan awalan "2" untuk menulis pada baris 2
jalankan "Remote Sensor Monitor.exe" dahulu kemudian server.js
repo: https://github.com/fariswd/cpugpumon

Saturday, January 7, 2017

[PYTHON] KerangAjaib Twitter Bot

7 January 2017

Intro

Bot twitter dengan ide kerang ajaib spongebob.

Goal

Mendapatkan jawaban pertanyaan (YA/TIDAK/BISAJADI) saat user memention bot.

Gear

-Server/VPS/PC
-Python 3 (saya menggunakan 3.4.3)
-Twitter Streaming API

Flowchart

Gambar1. Flowchart


Code

- Twitter API Library https://github.com/geduldig/TwitterAPI

Note

- Buat Token di apps.twitter.com
- Program ini never ending loop

Refference

- Twitter API library -> https://github.com/geduldig/TwitterAPI
- Twitter Streaming Api -> https://dev.twitter.com/streaming/overview/request-parameters
- Documentation Tweet User Api -> https://dev.twitter.com/overview/api/tweets

Friday, January 6, 2017

[PROJECT] Bolt 4G Quota Watcher

6 January 2017

Intro

Membuat alat pemantau quota 4G berbasis IoT.

Goal

Menampilkan sisa quota internet pada paket modem bolt realtime berbasis IoT

Gear

-PC dengan PHP server (saya menggunakan wamp)
-ESP8266 (saya menggunakan versi esp-01)
-LCD 16x2 (dengan i2c backpack)
-FTDI loader
-Jumper Wire
-Breadboard/Prototypeboard
-Wifi Network

Flowchart

Gambar 1. Flow Chart


Gambar 2 FTDI + ESP-01 + LCD 16x2


Code

Pada Server
-Menggunakan Library DOM Simple Parser http://simplehtmldom.sourceforge.net/

Pada ESP8266
-Wiring Flash
Gambar3. Wire Map Flash

ESP8266 - FTDI
VCC     - 3.3V
GND     - GND
RX      - TX
TX      - RX
CH_PD   - 3.3V
RST     - PUSH BTN - GND
GPIO0   - GND (FOR FLASH, 3.3V FOR RUNNING)



Gambar4. Wiring ESP-01 to LCD

ESP8266 - i2c 16x2 LCD BACKPACK
GPIO2   - SCL
GPIO0   - SDA
GND     - GND

LCD 16x2 = 5V
ESP8266-01 = 3.3V

-Menggunakan Library LiquidCrystal i2C https://github.com/agnunez/ESP8266-I2C-LCD1602

Note

- ESP-01 menggunakan tegangan 3.3V, dan LCD 16x2 menggunakan 5V
- ESP-01 i2c SDA=GPIO0, SCL=GPIO2
- LiquidCrystal i2C library https://github.com/agnunez/ESP8266-I2C-LCD1602
- buat file cookies.txt pada direktori server
- pada server CURL telah terinstall & enable
- DOM Simple Parser Library http://simplehtmldom.sourceforge.net/
- DOM Simple Parser install pada ./lib/dom/

Refference

- Get Value Function -> http://arduino.stackexchange.com/questions/1013/how-do-i-split-an-incoming-string
- Wiring Flash Program -> https://importhack.wordpress.com/2014/11/22/how-to-use-ep8266-esp-01-as-a-sensor-web-client/
- Wiring LCD 16x2 -> http://domoticx.com/esp8266-wifi-lcd-1602-2004-via-i2c-nodemcu/

Sunday, January 1, 2017

[PHP, PYTHON] Login Page Simple Parser

1 January 2017

Intro::

Simple HTML parser login page, use
- PHP-> Simple DOM HTML Parser + curl. shows nickname.
- Python -> Beautiful Soup

Simple Login + Parsing html

PHP:
PYTHON:

Catatan::

Simple html dom parser manual : http://simplehtmldom.sourceforge.net/manual.htm
Refference : http://stackoverflow.com/questions/3008817/login-to-remote-site-with-php-curl

Saturday, December 31, 2016

[ESP8266-01] i2c 16x2 LCD Test

31 December 2016

ESP8266-01 i2c Test


1. LiquidCrystal_I2C library
https://github.com/agnunez/ESP8266-I2C-LCD1602

Download+extract arduino - libraries folder - restart arduino ide

2. Set Dev Board
-Pick Board Generic ESP8266 Module

3. Try burn/flash/upload

Files - Example - LiquidCrystal i2C - Hello World
Verify - Upload

4. Wire MAP
Cheat Sheet ESP8266-01
ESP8266 - FTDI
VCC - 3.3V
GND - GND
RX - TX
TX - RX
CH_PD - 3.3V
RST - PUSH BTN - GND
GPIO0 - GND (FOR FLASH, 3.3V FOR RUNNING)

ESP8266 - i2c 16x2 LCD BACKPACK
GPIO2 - SCL
GPIO0 - SDA
GND - GND

LCD 16x2 = 5V
ESP8266-01 = 3.3V

Catatan:
3.3v ≠ 5v
- selesai upload  GPIO0 dicabut + reset (agar supaya mode flash off)

Referensi
-reference i2c lcd16x2 = http://sankios.imediabank.com/esp-01-1602-led
-wiremap = http://domoticx.com/esp8266-wifi-lcd-1602-2004-via-i2c-nodemcu/
-setup = https://kendrick-tabi.blogspot.co.id/2015/06/how-to-program-esp8266-using-arduino-ide.html

Friday, December 30, 2016

[ESP8266-01] Blink Test 2

30 December 2016

ESP8266-01 Test


1. FTDI Driver

2. Set Dev Board
-Pick Board Generic ESP8266 Module

3. Try burn/flash/upload

Files - Example - ESP8266 - blink
Verify - Upload

4. Wire MAP
Cheat Sheet ESP8266-01
Cheat Sheet FTDI

ESP8266 - FTDI
VCC - 3.3V
GND - GND
RX - TX
TX - RX
CH_PD - 3.3V
RST - PUSH BTN - GND
GPIO0 - GND (FOR FLASH, 3.3V FOR RUNNING)


Catatan:
3.3v ≠ 5v
- selesai upload  GPIO0 dicabut buat + reset (agar supaya mode flash off)

Referensi
-wire map = http://iot-playground.com/blog/2-uncategorised/35-esp8266-firmware-update
-setup = https://kendrick-tabi.blogspot.co.id/2015/06/how-to-program-esp8266-using-arduino-ide.html
- ftdi usb ttl = http://www.arduinesp.com/getting-started
-arduino = http://arduino.cc

Saturday, September 17, 2016

[ESP8266] DHT11 Simple Test

17 September 2016

ESP8266 DHT11 Test

Pic1. Output
0. Install DHT library
Sketch - Include Library - Library Manager - DHT Sensor Library by Adafruit - Install
https://github.com/adafruit/DHT-sensor-library
1. Code
2. Pinout
Pic2 ESP8266 NODEMCU Pinout
Pic3. DTH11 Pinout

3. Wire MAP
D1 -> INPUT KE DHT11 -> DHT11 PIN2
D1 -> PULL UP RESISTOR -> VCC


Referensi
-pinout nodemcu = https://github.com/nodemcu/nodemcu-devkit
-datasheet DTH11 = http://www.micropik.com/PDF/dht11.pdf

[ESP8266] Simple WiFi Client

17 September 2016

Simple WiFi Client


1. Code


2. Serial Port Arduino IDE
Tools - Serial Monitor


Note:
-Change SSID & PASSWORD section
-Set baud rate speed 9600

[ESP8266] Running LED

17 September 2016

Running LED


1. Code


2. Pinout
ESP8266 NODEMCU Pinout
3. Wire MAP
PIN1 = D0 -> (+)LED(-) -> GND
PIN2 = D1 -> (+)LED(-) -> GND
PIN3 = D2 -> (+)LED(-) -> GND
PIN4 = D5 -> (+)LED(-) -> GND
PIN5 = D6 -> (+)LED(-) -> GND


Referensi
-pinout = https://github.com/nodemcu/nodemcu-devkit

[ESP8266] Preparation Blink Led

17 September 2016

ESP8266 Test


1. Install Arduino IDE
https://www.arduino.cc/en/Main/Software

2. Install Board Developer
Add ESP8266 board database
File - Preferences - Additional boards manager

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Restart Arduino IDE

Tools - Board - Board Manager
Search: ESP8266 - Install

Restart Arduino IDE

3. Setup Board
-Pick Board NodeMCU 1.0 (ESP-12E Module)
-Choose COM port use

4. Try burn/flash/upload

Files - Example - ESP8266 - blink
Verify - Upload

5. Wire MAP
ESP8266 NODEMCU Pinout

D0 -> (+)LED(-) -> GND


Referensi
-nodemcu = https://github.com/nodemcu/nodemcu-devkit
-setup = http://www.instructables.com/id/Programming-ESP8266-ESP-12E-NodeMCU-Using-Arduino-/
-arduino = http://arduino.cc

Tuesday, September 13, 2016

[RPI GPIO] Mini Servo Test on Raspberry Pi 2

12 September 2016

Mini Servo Test on Raspberry Pi 2 (Python GPIO)

1. Using PWM
Pinout Raspberry Pi 2
Mini Servo -> RPI
orange PWM -> pin11
red vcc -> vcc 5v / pin2 / pin4
brown ground -> gnd / pin6, pin9, pin14...

2. Send python script or write script to RPI


3. Test Run
sudo python servotest.py


Referensi
-pinout = https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/
-PWM = https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/
-datasheet mini servo = http://www.micropik.com/PDF/SG90Servo.pdf

Thursday, June 30, 2016

[RPI GPIO] LCD 16x2 Test

30 June 2016

LCD 16x2 Test on Raspberry Pi 2 (Python GPIO)

1. Enable I2C
- sudo raspi-config
- select 8 Advanced Options
- select A7 I2C
enable?
- yes

by default?
- yes

reboot for saving all changes
sudo reboot

2. Edit loaded modules
sudo nano /etc/modules

add lines:
i2c-bcm2708
i2c-dev

3. Install utilities/software
sudo apt-get update
sudo apt-get install -y python-smbus i2c-tools

reboot for saving all changes
sudo reboot


4. Connect RPI - I2C - LCD 16x2
RPI pin 1 - VCC
RPI pin 3 - SDA
RPI pin 4 - GND
RPI pin 5 - SCL

5. Send python script to RPI


6. Test Run
sudo python lcd.py


Note:
- cek if running i2c module or not?
lsmod | grep i2c_


Referensi
-http://www.raspberrypi-spy.co.uk/2014/11/enabling-the-i2c-interface-on-the-raspberry-pi/
-http://www.raspberrypi-spy.co.uk/2015/05/using-an-i2c-enabled-lcd-screen-with-the-raspberry-pi/

Thursday, October 1, 2015

Saturday, July 18, 2015

[RPI] Bluethooth Pairs

18 July 2015

sudo apt-get install bluetooth bluez-utils blueman
sudo apt-get install bluez-compat
sudo bluez-simple-agent hci0 48:86:E8:B5:2B:7A
sudo pand --connect 48:86:E8:B5:2B:7A -n
dhclient bnep0

Referensi
http://www.modmypi.com/blog/installing-the-raspberry-pi-nano-bluetooth-dongle
http://www.ctheroux.com/a-step-by-step-guide-to-setup-a-bluetooth-keyboard-and-mouse-on-the-raspberry-pi/
http://m-jorgensen.dk/how-to-enable-pan-on-raspberry/

Thursday, July 16, 2015

[RPI] Yicam - Resize - Tweet via Raspberry Pi

16 July 2015

RPI Config for live image Yicam - Rpi - Resize - Tweet

sudo apt-get install python-setuptools
sudo easy_install pip
sudo apt-get install libjpeg-dev
sudo pip-3.2 install pillow
sudo pip-3.2 install TwitterApi

Gunakan pyton3 command

python3 yirestwet.py

Referensi
- http://stackoverflow.com/questions/8915296/python-image-library-fails-with-message-decoder-jpeg-not-available-pil
- http://pi-camera.blogspot.com/p/raspberry-pi-setup.html
- https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=97326
- https://github.com/deltaflyer4747/Xiaomi_Yi/blob/master/Standalone_scripts/Camera_photo.py
- http://copter.sovgvd.info/a/Xiaomi-Yi-protocol-remote-control
- https://www.youtube.com/watch?v=WrtebUkUssc
- https://gist.github.com/capung48/0f2f73d599f2de8100eb

Friday, July 3, 2015

[PYTHON] Twitter API POST Test

3 July 2015

Installation TwitterAPI by geduldig

1. python -m pip install TwitterAPI


Referensi
-https://github.com/geduldig/TwitterAPI
-http://stackoverflow.com/questions/13111222/windows-7-python-3-2-file-not-found-on-open

Thursday, July 2, 2015

[PYTHON] Beautiful Soup pada Windows CMD

2 July 2015

Installasi beautifulsoup windows via command prompt

1. python -m pip install -U pip (upgrade pip)
2. python -m pip install beautifulsoup4

Refferensi
-http://www.crummy.com/software/BeautifulSoup/