PMPOS on Raspberry pi 3

What do you think? It seems working better than I’ve expected.

5 Likes

Yes, the web client works very very well on any device regardless of (lack of) power of the hardware, so I am not surprised that it also works well on a Pi.

1 Like

I liked Pi 3 a lot. It have own wireless / bluetooth etc.

For most cases using a tablet makes better sense but I think I can add a sensor on it and create a sambapos task whenever it signals a value. We can use it to count stuff.

3 Likes

What could we count with it. I love the idea of new technology in restaurants :slight_smile:

OK I found a cheap PIR sensor and implemented an idea.

I attached the PIR sensor through GPIO port of the raspberry.

You’ll notice nothing connected to raspberry other than the power. To be able to simplify development for raspberry I setup xrdp on Raspberry to connect to it via Remote Desktop.

I also setup Samba for network access and Node JS for the application that reads the sensor and connects Message Server to create tasks.

I shared a network folder on raspberry pi and mapped it as a network drive so I wrote the node js application with visual studio code that installed on my laptop. If anyone interested I followed this tutorial for setting up everything. http://thisdavej.com/beginners-guide-to-installing-node-js-on-a-raspberry-pi/

I also setup nodemon on raspberry pi. It restarts node application as soon as I change the source code. It really simplifies development.

This is the source code of the application.

var Gpio = require('onoff').Gpio;
var https = require('https');
var http = require('http');
var querystring = require('querystring');
var request = require('request');

var pir = new Gpio(7, 'in', 'both');

var messageServer = '192.168.1.6';
var messageServerPort = 9000;
var accessToken = '';

Authorize();

function start() {
    console.log('Watching...');
    pir.watch((err, value) => {
        if (err) exit();
        console.log('Value > ' + value);
        if (value === 1) {
            var script = getCreateTaskScript('Motion Detected');
            gql(script, () => gql('mutation m{postTicketRefreshMessage(id:0){id}}'));
        }
    });
}

function Authorize() {
    var form = { grant_type: 'password', username: 'samba', password: 'password' };
    var formData = querystring.stringify(form);
    var contentLength = formData.length;

    request({
        headers: {
            'Content-Length': contentLength,
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        uri: 'http://' + messageServer + ':' + messageServerPort + '/Token',
        body: formData,
        method: 'POST'
    }, function (err, res, body) {
        accessToken = JSON.parse(body).access_token;
        start();
    });
}

function gql(query, callback) {
    var data = JSON.stringify({ query: query });
    console.log(query);

    request({
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'Authorization': 'Bearer ' + accessToken
        },
        uri: 'http://' + messageServer + ':' + messageServerPort + '/api/graphql',
        body: data,
        method: 'POST'
    }, function (err, res, body) {
        if (callback) callback(JSON.parse(body).data);
    });
}

function getCreateTaskScript(content) {
    return `mutation m {addTask(task:{taskType:"Motion Task",content:"${content}",isCompleted:true}){id}}`;
}

function exit() {
    pir.unexport();
    process.exit();
}

and the package.json file for the npm packages I used.

{
  "name": "sensortest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "onoff": "^1.1.1",
    "querystring": "^0.2.0",
    "request": "^2.79.0"
  }
}

You can watch this video to see it in action. When I move my hand in front of the sensor it increments the counter. When it senses a motion it creates a task on SambaPOS via graphql and broadcasts a message.

This is the PIR sensor I’ve used. It costs about $5.00 and it have 4 meters range.

It have an 10 second delay before it resets state after it detects a motion. There are several adjustable PIR sensors. For example this one sized a little bigger but you can configure delay and sensitivity by using orange screws. This one costs about $3.00.

Of course that won’t be a accurate people counter as it only activates when it senses a motion. However it may give an idea about the busyness of an area. For example when placed in front of the main entry, analyzing motion data with sales or ticket counts may give better insights about the operation. Adding more sensors for bar or bathroom areas can improve accuracy of the data. I’ll specifically use it for our self servicing kiosk to understand if someone stands in front of it. Also additional sensors like light sensors or ultrasonic sensors may help to generate more accurate data. There are lots of different sensors that can be used for different purposes.

Update: Today I noticed our people counter published on adafruit blog. https://blog.adafruit.com/2017/02/03/raspberry-pi-powered-people-counter-for-sambapos-raspberry_pi-piday-raspberrypi/

This website is a great resource to follow if you’re interested on DIY projects.

6 Likes

Hie
I´d like to know about the “WEB CLIENT”.
where can i find information to deploy it on a netbook with linux?
thanks in advance

Its in the beta testing version/forum section at the moment.
You can request to be added but it is at leaders discretion and typically more for regular level forum users with regular active input into the development.
It is progressing well and v5.1.61 is looking to contain allot of improvements and likely a solid base of the API which powers the web client.
The web client is on github however without the latest beta version of samba is not much use as will be using many of the latest api requests.

1 Like

I have a raspberry pi 3, I use it as a mediacenter, I’d like to try, how can I install to do a test?

PMPOS and Q’s QPMS are web based interfaces using the samba API so just run in a browser.
A PI is unlikely to have the power to run samba natively if it we’re possible to run Windows on one.

Any device that can run a Browser such as Chrome can use QMX which includes a very robust and feature-rich POS Module, among others such as Customer Display and Kitchen Display. If you can run a Browser on a Raspberry Pi, you can use QMX.

QMX is a cross-platform web-based mobile client containing several “modules” which interact with a main SambaPOS “server” installation installed on a Windows machine, via the GraphQL API and the SambaPOS Message Server.

1 Like

mine was just a curiosity, I tried to install pmpos but without success. does it need to be installed on the server? is fine with Windows 7 64 bit?

PMPOS is a website, you would need to update samba and reconfigure message server to new ports for api etc.
As it’s more than a basic HTML page I believe you need to install webserver facility on the server which makes it a local webserver.

Believe qs is far inproved over PMPOS which was mainly just proof of concept, he has documented the install and setup for it

Sigh… don’t mean to sound that way, but, just try QMX. Seriously.

You install QMX on the main machine where you installed SambaPOS and the Database and the Message Server. This is required for any Mobile Client, just like the Mobile Client Helper, since the Client Devices require a Webservice, the Message Server and some access to the DB in some fashion. Even the GraphiQL interface runs within a Webserver service from the main SambaPOS installation.

As far as QMX goes, it contains a “service” that is installed on your main SambaPOS “Server” where the Message Service and Database resides. This allows for extended functionality to the Clients beyond what GraphQL provides. The QMX Server runs a Webserver (which is required by any mobile client), and can directly access the DB and Filesystem on the SambaPOS Server… that is how the “magic” happens.

After that, everything is WEB-BASED. Clients can be ANY platform or Device that is capable of running a Web Browser like Chrome. No installation of any kind is required on the Client Device whatsoever. The Client is not Android or iOS or Windows specific. The Client platform does not matter. You can customize the QMX Modules on a per-device basis depending on their desired role or use.


P.S. the POS Module included in QMX was initially inspired by Emre’s proof-of-concept “PMPOS” (Poor Man’s POS) code. Even SambaPOS’s “official” Mobile Client is nearly identical code-wise to PMPOS.

However, QMX is far beyond that, and is much more that just a “Mobile Table-side order-taking App”. It has several other Modules that you will love… AND the QMX POS Module, is far more feature-rich and capable than the official SambaPOS Mobile Client (sorry SambaPOS devs, but it is blatantly true, undeniably).

I don’t know how else to put it… just try QMX.

Current release version is 1.1.0. Coming in the next week or so will be 1.2.0 which includes many improvements and feature additions.

2 Likes

If you can give us table layouts with a custom background image on tablets you have me bought out for all my clients. For our clients no table entity screen layouts is unfortunately a deal breaker. Compared to sambapos mobile client, QMX is far better.

1 Like

I tried qmx but I find many problems believed to be due to lingiua.
now I get this error that I can not solve