Posts

Node-Red and MQTT on Raspberry Pi

Image
Node-Red MQTT on Raspberry Pi Node Red A visual tool for wiring the IoT. Gateway to The IoT. Rapidly developing popular platform device data information. To install Node-Red > bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered) > node-red-start After this you can access the node-red dashboard from url http://<raspberrypi ip addr>:1880 Auto Start on Reboot > sudo systemctl enable nodered.service Install MQTT Broker > npm install node-red-contrib-mqtt-broker Reference [1] Install Node-Red  [2] Install node-red-contrb-mqtt-broker [3] First time mqtt-broker MQTT Publish Getting started install MQTT client > sudo pip install paho-mqtt Note: GPIO. Stands for " General Purpose Input/Output ."  MQTT stands for "Message Queue Telemetry Transport"

M5Stack ESP32

Image
1. use uPyCraft https://randomnerdtutorials.com/install-upycraft-ide-windows-pc-instructions/ 2. Tools > Burn Firmware -  m5stack-20180516-v0.4.0.bin Connect to Putty 1. Open Putty 2. Select 'Serial' Connection 3. Port: COM7, Speed 115200 4. exec(open('./main.py').read(),globals()) M5Cloud How to make it connect to wifi 1. Burn with M5Cloud firmware https://github.com/m5stack/M5Cloud/tree/master/firmwares 2. Connect to wifi using  http://192.168.4.1/ 3. Add device via  http://io.m5stack.com M5 UI-Flow 1 Instruction https://medium.com/mmp-li/m5stack-with-ui-flow-b6d1a37385b0  1.1 How to burn firmware  https://docs.makerfactory.io/m5stack/related-documents/burn-firmware/  1.2 M5Burner  https://github.com/m5stack/M5Stack-Firmware Arduino 1 Install Arduino IDE - [1] arduino ide - [2] arduino on vscode 2. Install ESP32 board on Arduino IDE https://randomnerdtutorials.com/installing-the-esp32-board-...

Setup Raspberry PI

1. install raspberrian image into micro sd card Note: I used '2018-11-13-raspbian-stretch.img' via balenaEtcher 2. In case you don't have external keyboard but you have mouse. It needs to set wifi ssid/password via config file.     - Create file 'wpa_supplicant.conf' and add text as following into the file and save it to microsdcard country=US ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={  ssid="wifissid"  scan_ssid=1  psk="wifipassword"  key_mgmt=WPA-PSK } 3. Turn on ssh via create ssh file or use raspberry destop > preference config 4. If you need to write down a python code related bluetooth. You need to install bluepy > sudo apt-get install python-pip libglib2.0-dev > sudo pip install bluepy > sudo hcitool lescan  //get mac address Reference [0] How to install raspberry [1] Install Bluepy [2] Raspberry Document [3] Startup Bluetooth on Raspberry PI

Angular login registration example

Reference http://jasonwatmore.com/post/2018/05/16/angular-6-user-registration-and-login-example-tutorial

MySql Command Cheatsheet

First time setup https://linuxize.com/post/install-mysql-on-centos-7/ **************************************************************** Setup initiate Open terminal and edit  /etc/mysql/my.cnf sudo nano / etc / mysql / my . cnf Underneath the  [mysqld]  section.add: lower_case_table_names = 1 Restart mysql sudo / etc / init . d / mysql restart **************************************************************** Remove mysql completely Execute the following command : # rpm -qa | grep mysql It will list all installed mysql packages on your system. Eg:  mysql-libs-5.1.73-3.el6_5.x86_64 now execute the command: # yum remove <name displayed in above step-1> Eg:  yum remove mysql-libs-5.1.73-3.el6_5.x86_64 **************************************************************** > mysql -u root -p > CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; > GRANT ALL ON db1.* TO 'username'@'%'  ...

Express connect to mysql

MySQL Module :  mysql Installation $ npm install mysql Example var mysql = require ( 'mysql' ) var connection = mysql . createConnection ( { host : 'localhost' , user : 'dbuser' , password : 's3kreee7' , database : 'my_db' } ) ; connection . connect ( ) connection . query ( 'SELECT 1 + 1 AS solution' , function ( err , rows , fields ) { if ( err ) throw err console . log ( 'The solution is: ' , rows [ 0 ] . solution ) } ) connection . end ( ) Reference https://expressjs.com/en/guide/database-integration.html https://www.terlici.com/2015/08/13/mysql-node-express.html https://codeburst.io/build-a-rest-api-for-node-mysql-2018-jwt-6957bcfc7ac9 https://github.com/waiyaki/postgres-express-node-tutorial/blob/master/ http://docs.sequelizejs.com/manual/tutorial/models-usage.html#data-retrieval-finders

Express by Node.js

It is a web application framework. Install go to the directory of app > mkdir api > cd api > npm init > npm install express --save > node app.js Or install via Express Generator generator tool,  express-generator , to quickly create an application skeleton. #1  The  express-generator  package installs the  express  command-line tool. Use the following command to do so: npm install express-generator -g cd .. //go to parent path #2 For example, the following creates an Express app named  api . The app will be created in a folder named  api in the current working directory and the view engine will be set to  Pug : express --view=pug api #3 Then install dependencies: $ cd myapp $ npm install #4 Run the app > set DEBUG=myapp:* & npm start In case, need to monitor change install nodemode > npm i -g nodemod > nodemon app.js //instead of calling npm start //Nodemon will watching for changing ...