structure from motion | Motioneye | Minishowcase | FrontPage | Here | Alarmpi01 | Alarmpi00

ws sohmod

  • Home
  • Timeline
  • Albums
  • Content
  • Essays
Share
February 4, 2018

ARCHLINUX HOMEBRIDGE

[alarm@alarmpi01 ~]$ sudo pacman -S nss-mdns avahi dbus pygtk python-dbus python2-dbus [alarm@alarmpi01 ~]$ sudo npm install -g --unsafe-perm homebridge [alarm@alarmpi01 ~]$ systemctl start dbus.service [alarm@alarmpi01 ~]$ systemctl start avahi-daemon.service [alarm@alarmpi01 ~]$ sudo systemctl start homeassistant [alarm@alarmpi01 ~]$ sudo systemctl start homebridge [alarm@alarmpi01 ~]$ homebridge *** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi. *** WARNING *** Please fix your application to use the native API of Avahi! *** WARNING *** For more information see *** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. *** WARNING *** Please fix your application to use the native API of Avahi! *** WARNING *** For more information see [10/16/2017, 11:30:57 PM] No plugins found. See the README for information on installing plugins. [10/16/2017, 11:30:57 PM] config.json (/home/alarm/.homebridge/config.json) not found. Scan this code with your HomeKit App on your iOS device to pair with Homebridge: ┌────────────┐ │ 031-45-154 │ └────────────┘ [10/16/2017, 11:30:57 PM] Homebridge is running on port 37495. sudo nano /etc/systemd/system/homebridge.service [Unit] Description=homebridge Nodejs HomeKit Server After=network.target [Service] User=homebridge Group=homebridge Type=simple ExecStart=/usr/bin/homebridge -U /var/lib/home-bridge [Install] WantedBy=multi-user.target sudo nano /etc/systemd/system/homeassistant.service [Unit] Description=Home Assistant After=network.target [Service] User=hass Group=hass Type=simple ExecStart=/usr/bin/hass --config /var/lib/home-assistant [Install] WantedBy=multi-user.target

Share
February 7, 2018

Cluster with MPI and ArchLinux

Ref : https://apparatusd.wordpress.com/2012/04/18/hpc-high-performance-compute-cluster-with-mpi-and-arch/

The following is a simple guide to setting up a cluster server and nodes using ArchLinux. The advantage of this approach is the flexibility of setting up a computer capable of high speed parallel computation using commodity hardware. The procedure will be generally similar for most Unix based systems.The preference for Arch is driven by its philosophy of keeping-it-simple.

’Simple’ is defined from a technical standpoint, not a usability standpoint. It is better to be technically elegant with a higher learning curve, than to be easy to use, and technically crap.Thus for a base system that will be as lean and fast as possible the minimalist base Arch install is perfect for the task at hand.

Open MPI The Open MPI Project is an open source MPI-2 implementation that is developed and maintained by a consortium of academic, research, and industry partners. Open MPI is therefore able to combine the expertise, technologies, and resources from all across the High Performance Computing community in order to build the best MPI library available. 

Machine setup This guide assumes: all the machines have been formatted and Arch base system installed according to the guide the machines are connected via a TCP/IP network with the ip addresses and hostnames noted down as they will be required in later steps. each machine has a common login account (in this case baloo) all machines are using the same processor architecture i686 or x86_64. 

Its always a good idea to get the latest and up-to date Arch system so a quick:pacman -Syu SSH setup Open MPI communicates between the nodes and server over a secure connection provided by openssh secure shell. The full details of openssh options can be found from the arch wiki or the main openssh site. Here the bare minimum is given to get a cluster up and running. Installing openssh Accomplished by calling:pacman -S openssh the default configuration for the sshd (server deamon) are enough for our needs. Inspect the /etc/ssh/sshd_config making sure all options are sane then continue. Generating ssh-keys To allow the cluster to send communication to the nodes from the server without the password being requested at every instance we shall use ssh-keys to enable the seamless logon. Using the defaults accept as given.No passphrase is selected, although inherently less secure than with one this precludes the need to setup key management via keyring.

Copying Keys to the server Start the ssh deamon rc.d start sshd on both the server and the slave node and copy the public key from each node to the server.These will all end up in the home directory for our common user baloo.ie /home/baloo/.ssh/  The server publickey (id_rsa.pub) and each of the publickeys copied over from the nodes are then appended to the authorized_keys file at ~.ssh/authorized_keys on the server. To enable two way communication its then possible to copy this file back to all the nodes after.  

IMPORTANT: make sure the permissions for the following are all appropriate for reading and writing only by the owner:

chmod 700 ~/ 

chmod 700 /.ssh 

chmod 600 authorized_keys 

logging into the remote machines via ssh should no longer require a passsword. NFS setup OpenMPI requires the programs that are to be run to be in a common location here. Instead of copying the program executable over and over to the slave nodes we set up a simple NFS shared directory with the actual folder on the server from which all the nodes will mirror the contents. Server Configuration Create the directory that will be shared /parallel in this instance and edit the /etc/exports to have the file mirrored to the remote nodes /parallel . . . . . . . *(rw,sync) and change the ownership permissions for the shared directory to nobody 

chown -R nobody.nobody /parallel 

edit /etc/conf.d/nfs-common.conf STATD_OPTS=”–no-notify” 

Client Configuration Edit /etc/fstab to include the following line so the clients can access the shared /parallel directory 192.168.2.103:/parallel /parallel nfs defaults 0 0 

Daemons Configuration Setting the appropriate daemons to launch on start-up simply requires the modification of /etc/rc.conf and adding the appropriate entries. 

Server # DAEMONS=(…….sshd rpcbind nfs-common nfs-server ……) # Nodes # DAEMONS=(…….sshd rpcbind nfs-common ……) # OpenMPI setup With the preliminary setup out of the way we can now install the openMPI package , it comes with inbuilt wrappers for c++ fortran and c additionally the python wrappers can also be installed.It should be installed on both the server and nodes pacman -S openmpi python-mpi4py python2-mpi4py *the python wrappers are there if you want to implement the parallel programs in mpi for python OpenMPI Configuration To allow Open MPI to know on which machines to run your programs create a hostfile in the default user home directory.if /etc/hosts was set up you can use the host names here otherwise the IP addresses of the machines can work just as well.~/mhosts #The master node is dual processor machine hence slots = 2 # localhost slots=2 # #The slave node is a quad core machine hence the slots=4 # Or1oN slots=4 Running Programs on the cluster To run myprogram on the cluster issue the following command from the /parallel directory: 

$mpirun -n 4 –hostfile ~/mhosts ./myprogram$mpirun -n 4 –hostfile ~/mhosts python myprogram.py or 

$mpiexec -n 4 –hostfile ~/mhosts ./myprogram $mpiexec -n 4 –hostfile ~/mhosts python myprogram.py

Share
February 11, 2018

Portraits 3D

Please wait a few seconds for data to download and it is advisible to use modern browsers for viewing. Click and drag in window to rotate point cloud, mousewheel for zoom is disabled. Definitely I had to be more vigilant during photo sessions, and if models did move a bit the outputs could break as well.

Musics on this page belonged to respective artists published on youtube. Your browser does not support the audio element.


Share
February 14, 2018

Ayat Tujuh (Munjiat)

بِسْمِ اللهِ الرَّحْمَنِ الرَّحِيْمِ

قُلْ لَنْ يُصِيْبَنَا إِلَّا مَاكَتَبَ اللهُ لَنَا هُوَمَوْلَا نَاوَعَلَي اللهِ فَلْيَتَوَ كَّلِ الْمُوءْمِنُوْنَ

وَاِنْ يَمْسَسْكَ اللهُ بِضُرٍّ فَلَاكَا شِفَ لَهُ اِلَّاهُوَوَاِنْ يُرِدْكَ بِخيْرٍفَلَا رَآدَّ لِفَضْلِهِ يُصِيْبُ بِهِ مَنْ يَشَآءُ مِنْ عِبَادِهِ وَهُوَالْغَفُوْرُالرَّحِيْمُ

وما من دابة فى الارض الاعلى الله رزقها ويعلم مستقرها ومستودعها كل فى كتاب مبين

اني توكلت على الله ربي وربكم ما من دآبة الاهو آخز بناصيتها ان ربي على صراط مستقيم

وكاءين من دآبة لاتحمل رزقها ، الله يرزقها واءيا كم وهوالسميع العليم

ما يفتح الله للناس من رحمة فلا ممسك لهاوما يمسك فلا مرسل له من بعده وهوالعزيز الحكيم

ولءن سءلتهم من خلق السموات والأرض ليقولن الله قل افرايتم ما تدعون من دون الله ان اراد ني الله بضرهل هن كاثفات ضره اوارد ني برحمة هل هن ممسكات رحمته قل حسبي الله عليه يتوكل المتوكلون

Your browser does not support the audio element.
Share
March 21, 2018

ESP8266 AT-Command

Set Arduino IDE to Serial Monitor. Set Module Baud rate to Both NL and CR.

use "AT" for check Communication Response "OK"

use "AT+RST" for Software Reset Module Response "OK"

use "AT+GMR" for check Firmware Version Response "Firmware Version xxxxxxx" Response "OK"

use "AT+CWMODE=1" for Set Mode 1 ( Station ) Response "OK"

use "AT+CWLAP" for check WiFi Network Available Response "Network Detail" Response "OK"

use AT+CWJAP="ssid","password" to Connect WiFi Network Response "OK"

use AT+CIPMUX=1 set to Multi point Mode Response "OK"

use AT+CIPSERVER=1,port to Start Server Response "OK"

use AT+CIFSR to check your IP Address Response "IP Address" Response "OK"

use AT+CIPCLOSE=0 to close all socket

Share
May 2, 2018

Control ESP8266 Anywhere

The ESP8266 is a low-cost Wi-Fi microchip with full TCP/IP stack and microcontroller capability produced by Shanghai-based Chinese manufacturer, Espressif Systems. The chip first came to the attention of western makers in August 2014 with the ESP-01 module, made by a third-party manufacturer, Ai-Thinker. The successor to these microcontroller chips is the ESP32.

...wiki

Share
June 29, 2018

Autostart X11VNC Server Session On Archlinux Booting


Steps For XFCE:

1: Forward port #5900 to your server computer from your router

2: Install x11vnc :     pacman -S x11vnc

3: Set Password :       x11vnc -storepasswd
Note: This can point to another location if you choose, but the default setting will automatically choose /home/your_user_name/.vnc/passwd and that is what I’ll use for this guide.

4: Create A Log File
Manually create an x11vnc.log file in: /home/your_user_name/.vnc/x11vnc.log

5: Command To Execute To Start (change your_user_name to your user name!)
x11vnc -nap -wait 50 -noxdamage -rfbauth /home/your_user_name/.vnc/passwd -display :0 -nocursor -forever -o /home/your_user_name/.vnc/x11vnc.log -bg
Notes: the rfbauth & log commands differ from Arch Wiki. The -nocursor command uses the host computer’s mouse pointer instead of the default weird “arrow” that x11vnc uses.

Autostart Method By Script (Do not use in conjunction with systemd method)
Create a file called x11vnc.sh 2 anywhere you want to save a script and add this to the file:

#!bin/bash
x11vnc -nap -wait 50 -noxdamage -rfbauth /home/your_user_name/.vnc/passwd -display :0 -nocursor -forever -o /home/your_user_name/.vnc/x11vnc.log -bg

Now right click the file, go to properties/permissions and check off “allow this file to run as a program”. Add the file to your autostart applications by making a custom entry in settings/session and startup/application autostart and point the entry to where you saved the x11vnc.sh 2 file. Name the startup entry whatever you want.



( source : https://forum.manjaro.org/t/guide-how-to-set-up-x11vnc-server-for-access-to-the-current-running-session/32525 )

Share
February 28, 2019

ESP8266 Webserver on Wemos Mini D1

The code was referred from Rui Santos webpage;


/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/
// Load libraries
// you should replace ( //*  =  < ) & (*//  =  >)below before run program
#include                 //*ESP8266WiFi.h*//
#include                //*EEPROM.h*//
#include                //*OneWire.h*//
#include               //*DallasTemperature.h*//

// Replace with your network credentials
const char* ssid     = "yourWifi";
const char* password = "WifiSecretPassword";
IPAddress staticIP(192,168,0,200);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
// Auxiliary variables for temperature
static char celsiusTemp[7];
static char fahrenheitTemp[7];
String temperatureString = "";      // Variable to hold the temperature reading
// EEPROM size
// Address 0: Last output state (0 = off or 1 = on)
// Address 1: Selected mode (0 = Manual, 1 = Auto PIR,
// 2 = Auto LDR, or 3 = Auto PIR and LDR)
// Address 2: Timer (time 0 to 255 seconds)
// Address 3: LDR threshold value (luminosity in percentage 0 to 100%)
#define EEPROM_SIZE 4
// Set GPIOs for: output variable, status LED, PIR Motion Sensor, and LDR
const int output = 15;
const int statusLed = 12;
const int motionSensor = 5;
const int ldr = A0;
// Store the current output state
String outputState = "off";
// GPIO where the DS18B20 is connected to
const int oneWireBus = 4;          
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);
// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);
// Timers - Auxiliary variables
unsigned long now = millis();
unsigned long lastMeasure = 0;
boolean startTimer = false;
unsigned long currentTime = millis();
unsigned long previousTime = 0; 
const long timeoutTime = 2000;
// Auxiliary variables to store selected mode and settings 
int selectedMode = 0;
int timer = 0;
int ldrThreshold = 0;
int armMotion = 0;
int armLdr = 0;
String modes[4] = { "Manual", "Auto PIR", "Auto LDR", "Auto PIR and LDR" };
// Decode HTTP GET value
String valueString = "0";
int pos1 = 0;
int pos2 = 0;
// Variable to store the HTTP request
String header;
// Set web server port number to 80
WiFiServer server(80);

void setup() {
  // Start the DS18B20 sensor
  sensors.begin();
  // Serial port for debugging purposes
  Serial.begin(115200);
  // PIR Motion Sensor mode, then set interrupt function and RISING mode
  pinMode(motionSensor, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(motionSensor), detectsMovement, RISING);
  
  Serial.println("start...");
  EEPROM.begin(EEPROM_SIZE);
  
  // Uncomment the next lines to test the values stored in the flash memory
  /*Serial.println(" bytes read from Flash . Values are:");
  for(int i = 0; i < EEPROM_SIZE; i++) {
    Serial.print(byte(EEPROM.read(i))); 
    Serial.print(" ");
  }*/
  
  // Initialize the output variable and the LED as OUTPUTs
  pinMode(output, OUTPUT);
  pinMode(statusLed, OUTPUT);
  digitalWrite(output, HIGH);
  digitalWrite(statusLed, LOW);
  // Read from flash memory on start and store the values in auxiliary variables
  // Set output to last state (saved in the flash memory)
  if(!EEPROM.read(0)) {
    outputState = "off";
    digitalWrite(output, HIGH);
  }
  else {
    outputState = "on";
    digitalWrite(output, LOW);
  }
  selectedMode = EEPROM.read(1);
  timer = EEPROM.read(2);
  ldrThreshold = EEPROM.read(3);
  configureMode();
  
  // Connect to Wi-Fi network with SSID and password
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  
  //fix ip
  WiFi.config(staticIP, gateway, subnet);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  // Print local IP address and start web server
  Serial.println("");
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  server.begin();
}
void loop() {
  WiFiClient client = server.available();   // Listen for incoming clients
  if (client) {                             // If a new client connects,
    currentTime = millis();
    previousTime = currentTime;
    Serial.println("New Client.");          // print a message out in the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected() && currentTime - previousTime <= timeoutTime) {            // loop while the client's connected
      currentTime = millis();
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        header += c;
        if (c == '\n') {                    // if the byte is a newline character
          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();                     
            // Display the HTML web page
            client.println("");
            client.println("");
            client.println("");
            // CSS to style the on/off buttons 
            // Feel free to change the background-color and font-size attributes to fit your preferences
            client.println("");
            client.println("");            
            
            // Request example: GET /?mode=0& HTTP/1.1 - sets mode to Manual (0)
            if(header.indexOf("GET /?mode=") >= 0) {
              pos1 = header.indexOf('=');
              pos2 = header.indexOf('&');
              valueString = header.substring(pos1+1, pos2);
              selectedMode = valueString.toInt();
              EEPROM.write(1, selectedMode);
              EEPROM.commit();
              configureMode();
            }
            // Change the output state - turn GPIOs on and off
            else if(header.indexOf("GET /?state=on") >= 0) {
              outputOn();
            } 
            else if(header.indexOf("GET /?state=off") >= 0) {
              outputOff();
            }
            // Set timer value
            else if(header.indexOf("GET /?timer=") >= 0) {
              pos1 = header.indexOf('=');
              pos2 = header.indexOf('&');
              valueString = header.substring(pos1+1, pos2);
              timer = valueString.toInt();
              EEPROM.write(2, timer);
              EEPROM.commit();
              Serial.println(valueString);
            }
            // Set LDR Threshold value
            else if(header.indexOf("GET /?ldrthreshold=") >= 0) {
              pos1 = header.indexOf('=');
              pos2 = header.indexOf('&');
              valueString = header.substring(pos1+1, pos2);
              ldrThreshold = valueString.toInt();
              EEPROM.write(3, ldrThreshold);
              EEPROM.commit();
              Serial.println(valueString);
            }
            
            // Web Page Heading
            client.println("
ESP8266 Web Server
");
            // Drop down menu to select mode
            client.println("
Mode selected: " + modes[selectedMode] + "
");
            client.println("
");
          
            // Display current state, and ON/OFF buttons for output 
            client.println("
GPIO - State " + outputState + "
");
            // If the output is off, it displays the ON button       
            if(selectedMode == 0) {
              if(outputState == "off") {
                client.println("
");
              } 
              else {
                client.println("
");
              }
            }
            else if(selectedMode == 1) {
              client.println("
Timer (0 and 255 in seconds): 
");
            }
            else if(selectedMode == 2) {
              client.println("
LDR Threshold (0 and 100%): 
");
            }
            else if(selectedMode == 3) {
              client.println("
Timer (0 and 255 in seconds): 
");
              client.println("
LDR Threshold (0 and 100%): 
");            
            }
            // Get and display DHT sensor readings
            if(header.indexOf("GET /?sensor") >= 0) {
              sensors.requestTemperatures(); 
              temperatureString = " " + String(sensors.getTempCByIndex(0)) + "C  " +  
                        String(sensors.getTempFByIndex(0)) + "F";   
             
              client.println("
");
              client.println(temperatureString);
              client.println("
");
              client.println("
");
            }
            else {
              client.println("
");
            }
            client.println("");
            // The HTTP response ends with another blank line
            client.println();
            // Break out of the while loop
            break;
          } else { // if you got a newline, then clear currentLine
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      }
    }
    // Clear the header variable
    header = "";
    // Close the connection
    client.stop();
    Serial.println("Client disconnected.");
  }
  
  // Starts a timer to turn on/off the output according to the time value or LDR reading
  now = millis();
  
  // Mode selected (1): Auto PIR
  if(startTimer && armMotion && !armLdr) {
    if(outputState == "off") {
      outputOn();
    }
    else if((now - lastMeasure > (timer * 1000))) {
      outputOff();
      startTimer = false;     
    }
  }  
  
  // Mode selected (2): Auto LDR
  // Read current LDR value and turn the output accordingly
  if(armLdr && !armMotion) {
    int ldrValue = map(analogRead(ldr), 0, 1023, 0, 100); 
    Serial.println(ldrValue);
    if(ldrValue < ldrThreshold && outputState == "on") {
      outputOff();
    }
    else if(ldrValue > ldrThreshold && outputState == "off") {
      outputOn();
    }
    delay(100);
  }
  
  // Mode selected (3): Auto PIR and LDR
  if(startTimer && armMotion && armLdr) {
    int ldrValue = map(analogRead(ldr), 0, 1023, 0, 100);
    Serial.println(ldrValue);
    if(ldrValue < ldrThreshold) {
      outputOff();
      startTimer = false;
      Serial.println("a");
    }
    else if(ldrValue > ldrThreshold && outputState == "off") {
      outputOn();
      Serial.println("b");
    }
    else if(now - lastMeasure > (timer * 1000)) {
      outputOff();
      startTimer = false;
      Serial.println("c");
    }
  }
}
// Checks if motion was detected and the sensors are armed. Then, starts a timer.
void detectsMovement() {
  if(armMotion || (armMotion && armLdr)) {
    Serial.println("MOTION DETECTED!!!");
    startTimer = true;
    lastMeasure = millis();
  }  
}
void configureMode() {
  // Mode: Manual
  if(selectedMode == 0) {
    armMotion = 0;
    armLdr = 0;
    // Status LED: off
    digitalWrite(statusLed, LOW);
  }
  // Mode: Auto PIR
  else if(selectedMode == 1) {
    outputOff();
    armMotion = 1;
    armLdr = 0;
    // Status LED: on
    digitalWrite(statusLed, HIGH);
  }
  // Mode: Auto LDR
  else if(selectedMode == 2) {
    armMotion = 0;
    armLdr = 1;
    // Status LED: on    
    digitalWrite(statusLed, HIGH);
  }
  // Mode: Auto PIR and LDR
  else if(selectedMode == 3) {
    outputOff();
    armMotion = 1;
    armLdr = 1;
    // Status LED: on
    digitalWrite(statusLed, HIGH);
  }
}
// Change output pin to on or off
void outputOn() {
  Serial.println("GPIO on");
  outputState = "on";
  digitalWrite(output, LOW);
  EEPROM.write(0, 1);
  EEPROM.commit();
}
void outputOff() { 
  Serial.println("GPIO off");
  outputState = "off";
  digitalWrite(output, HIGH);
  EEPROM.write(0, 0);
  EEPROM.commit();
}
Share
March 7, 2019

Install Motion

Open your terminal and type in the command 'sudo apt-get install motion ' to start the installation.

Now to make sure that the camera is correctly detected. Type in the command 'lsusb' and enter.

You should see the name of your camera. If it is NOT there, then there is some problem in your camera or the camera is not supported in 'motion'.

After the installation is complete, type in the command ' sudo nano /etc/motion/motion.conf ' and press enter.

Then you have to change some settings in the .conf file. It might be difficult sometimes to find the settings but use 'ctrl + w' to find it. So follow the steps:

Make sure 'daemon' is ON.

Set 'framerate' anywhere in between 1000 to 1500.

Keep 'Stream_port' to 8081.

'Stream_quality' should be 100.

Change 'Stream_localhost' to OFF.

Change 'webcontrol_localhost' to OFF.

Set 'quality' to 100. Set 'width' & 'height' to 640 & 480.

Set 'post_capture' to 5. Press ctrl + x to exit.

Type y to save and enter to conform.

Again type in the command 'sudo nano /etc/default/motion ' and press enter.

Set ' start_motion_daemon ' to yes. Save and exit.

Share
August 17, 2022

Lost Passage

Url linkage on koken very often got broken.

View all essays by month
Links
  • Portrait
  • Contact
1 of 2
  1. 1 2
  2. >
  • Home
  • Albums
  • Content
  • Essays
© ws sohmod mukadepan | Built with Koken