Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Install SmingHub and Netbeans as IDE at Linux Environment

Hi, this time i'd like to share how to install Sming Framework for ESP8266 and NetBeans as IDE. Before continue, i just to remind you my laptop use Linux Distro Elementary OS, which is Ubuntu base. So for Ubuntu user should be not problem.

Actually  there's no difference with installation from github page. But it's ok right if i rewrite here? I will explain more details if you're noobs at linux.


  • sudo apt-get update && sudo apt-get install make unrar autoconf automake libtool libtool-bin gcc g++ gperf flex bison texinfo gawk ncurses-dev libexpat1-dev python sed python-serial python-dev srecord bc git help2man unzip
  • Check /opt directory using command ls /opt if opt directory doesn't exist then create by command sudo mkdir /opt
  • cd /opt
  • git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
  • git clone https://github.com/SmingHub/Sming.git
  • cd /opt/esp-open-sdk
  • wget https://github.com/themadinventor/esptool/archive/master.zip
  • unzip master.zip
  • mkdir esptool
  • mv esptool-master /opt/esp-open-sdk/esptool 
  • git clone https://github.com/raburton/esptool2
  • cd esptool2
  • make
  • cd ..
  • Type: sudo chown -R YOUR_USERNAME ./
  • make
  • cd /opt/sming/Sming
  • make
  • sudo nano /etc/environment type at 2nd row ESP_HOME=/opt/esp-open-sdk and 3rd row SMING_HOME=/opt/sming/Sming and then push ctrl+x and enter twice
Here now we have framework sming, now we will setup Netbeans IDE
  • sudo apt-get install -y netbeans
  • if package not found then follow this instruction
    • sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
    • sudo apt-get update
    • sudo apt-get install netbeans
  • Open netbeans, go to tool menu then click plugins, at tab available plugins choose c/c++ then install
  • go to tool then click options, click c/c++ then follow instruction at picture below 
  • then click tab code assistance and follow picture below 
  • After all environment setup then now we import project by click file menu, choose c/c++ with existing sources, next choose sample at /opt/sming/sample/Basic_Blink
  • At trees left side find Makefile and right click there and choose make
  • Happy coding!

Cara Install MQTT di linux OS Freya 0.3.2 Elementary OS x86 (Ubuntu based)

MQTT adalah protocol messaging yang sangat ringan. Menggunakan port 1883 dan 8883 untuk TLS security. Karena keunggulannya yang sangat ringan itu, sehingga MQTT protocol menjadi standard protocl untuk IOT dikarenakan bisa menghemat pemakaian power.

Dalam blog ini saya akan coba terangkan bagaimana langkah-langkah instalasi MQTT di linux dan beberapa istilah yang mungkin agak membingungkan, karena di awal saya belajar pun istilahnya masih agak asing.

Disini broker yang akan kita pakai untuk MQTT adalah Mosquitto.


Installation:

  • Karena ada beberapa library yang dibutuhkan untuk instalasi, baiknya kita install dahulu dependency nya. 
  • $ sudo apt-get update && install build-essential libwrap0-dev libssl-dev libc-ares-dev uuid-dev xsltproc
  • Download link $ wget http://mosquitto.org/files/source/mosquitto-1.4.8.tar.gz
  • $ tar -xvzf mosquitto-1.4.8.tar.gz
  • $ cd mosquitto-1.4.8
  • $ sudo make && make install

Setelah instalasi berhasil, maka berikutnya adalah cara mengkonfigurasi agar bisa digunakan.
Menambah user untuk mosquitto
adduser mosquitto

Membuat user/password:
mosquitto_passwd -c /etc/mosquitto/pwfile nama_user
Disini akan diminta membuatkan password
Membuat direkktori untuk penyimpanan db, kemudian change owner diganti
mkdir /var/lib/mosquitto
chown mosquitto:mosquitto /var/lib/mosquitto/ -R
Membuat file konfigurasi
sudo cp /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf
sudo editor /etc/mosquitto/mosquitto.conf
Tambahkan konfigurasi dibawah ke akhir file konfigurasi
listener 8883 IP_ADDRESS_KAMU
persistence true
persistence_location /var/lib/mosquitto/
persistence_file mosquitto.db
log_dest syslog
log_dest stdout
log_dest topic
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
allow_anonymous false
password_file /etc/mosquitto/pwfile

Kemudian run
/sbin/ldconfig



Run/Test mosquitto broker
Jalankan mosquitto broker
mosquitto -c /etc/mosquitto/mosquitto.conf

Agar setiap reboot akan dijalankan otomatis oleh system maka buat script di /etc/init/mosquitto.conf dengan isi sebagai berikut
description "Mosquitto MQTT broker"
start on net-device-up
respawn
exec /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf 

Disini server broker MQTT sudah running, dan bisa digunakan. Ada beberapa istilah yang harus diketahui tentang MQTT diantaranya:
PUBLISH adalah action dari client untuk mengirimkan pesan dengan topik tertentu ke broker untuk diterima oleh client lain
SUBSCRIBE adalah action dari client untuk bersiaga menerima pesan dari suatu client dengan topik tertentu 

Ok. Disini dulu penjelasan untuk instalasi MQTT broker dari mosquitto, di blog berikutnya kita akan mencoba cara publish dan subscribe message.