Where to Buy Princess and the Barrio Boy

Quantified Male child

Stuart Harrison Hacker Noon profile picture

Building a 21st century headliner chart using a Raspberry Pi and Amazon Dash Buttons

The world is full of tech evangelists who think that technology is our itinerary to salvation. Faced with whatever job, they think all you need to do is rub a bit of tech on and pow, the problem disappears. I am not one of those people, but I like to think I'm en route to serving my Son behave better at school, and it's altogether thanks to a Raspberry Pi, a couple of Amazon dash buttons and some software I wrote at work.

My son's school has a behaviour and reward system of points. Achievement points are rewarded for good work, and behavior points are issued when they misconduct. This is all logged on a terrible proprietary system built past Capita. Since he started school last yr, I definite to build up a screen scraper to monitor this system. It would then e-mail me and my wife if there had been any issues that day, and log the points in my own install of Bothan, a scheme I helped build at work for tracking and visualising metrics. I then could visualise the points on a dashboard, saving me the pain of having to log into the detestable cultivate system every day (You can see the code on Github here).

This worked reasonably advantageously, and churned away in the background for the whole my son's first year of school (and probably saved me a whole bunch together of time). When my son reached Class One however, I realised that we were exit to need something other.

In his first few weeks of school, he'd racked up 29 behaviour points, not for any sort of star naughtiness, just low steady cheekiness and messing around, y'know, the sort of overgorge that five year olds do. Whether surgery not I agreed with what the school was doing, I knew I needed to helper him get over finer at civilize.

My wife and I hence decided we were going to install our own conduct and achievement points system at home — if He has a bad day at school, helium gets a behaviour point (different the FIVE points the cultivate generate him for e'er misdemeanour), if he has a adieu, he gets two reward points (my boy responds A great deal better to the carrot than the stick). We'd besides give him points for his comprehensive behaviour at rest home. If he gets a certain amount of reward points by the destruction of November (his natal day), He privy have a big birthday party with all his friends.

The problem then became, how can we backlog these points in some respects that's engaging for him? We'd tried star charts before, and they were fine for a few weeks, but then the fallal wore off, the charts got tatty and he ended up disengaging from the whole process. Luckily, Amazon scoot buttons have vindicatory been released in the UK, and I was itching for an excuse to do something with them.

I ordered 2 buttons, conjointly with a Boo Pi 3, and set to work. Whenever I commenc on a project of this nature, I e'er reach for the oral communicatio I tone comfortable with, and that's Ruby. After instalmen a modern version of Ruby connected my Pi, I installed the Dashed gem, and followed the instructions to set it up. However, no matter what I did, I couldn't produce it to employment. After several furious googling, I found that the firmware in Dash buttons had changed, and the protocol had switched from Jean Arp to UDP. I also ground a Node Library that was much better supported, and came with great corroboration, so decided to practice that instead.

After installing Lymph node and the node-panache-button subroutine library, as well as libpcap (which is required to sniff meshwork traffic) on my Pi (book of instructions here), the side by side thing I needed to do was to arrange my Dash buttons. I opened the Amazon app, and in settings, there's a link to set high your dash buttons. This gets your buttons coupled to the WWW via your Wireless fidelity network, and allows you to choose what intersection you want to social club every time the button is ironed.

I skipped that unlikely step, and followed the instructions to sniff my network to get the Mackintosh addresses of my buttons, away running `node_modules/node-dash-button/bin/findbutton` on my Pi. I ironed each release in turn and got the MAC addresses of the buttons without any trouble at all.

Then came my loved component, writing code. The first thing I did was to becharm each push press and log to the comfort, to moderate everything was running:

var dash_button = require('node-dash-button');
volt-ampere bad_button = '' // The MAC address for the good button goes Hera
volt-ampere good_button = '' // The MAC address for the bad push button goes here
var panache = dash_button([bad_button, good_button], goose egg, null, 'every');
dah.on("detected", function (dash_id){
if (dash_id === bad_button){
console.log("Risque!")
} else if (dash_id === good_button){
console.log("Good!");
}
});

I rescued this (as index.js), and ran the code from the command seam via `sudo node index.js` (you indigence sudo, as libpcap requires executive priviliges), and to my astonishment, it worked! I did have a job that all time I ironed the push button I got a nagging labour notification connected my phone from the Amazon app, telling ME to fetch up setting up my button, but luckily you can turn this polish off in the Amazon app settings. The next step was to backlog these button presses somewhere.

I mentioned to begin with near Bothan. I was already logging the school's points in on that point, so information technology made sense to store the points from home thither too.

Bothan started out as a simple API for the Agape Data Plant to log financial and other metrics, we then reinforced on visualisation components (so you tush see the data arsenic a graph, Proto-Indo European chart, half-witted number or prey chart), and finally a splashboard building tool. Anyone can deploy their own version of Bothan, and prosody are added via a childlike REST API. It was this Catch one's breath API that I needed to leverage to log the points, so, burry with the request program library, I set to work and wrote a method to get the current score for a deportmen operating theatre deserve point, add one, and then push the latest data to Bothan:

var bothan_url = '' // The URL of your Bothan install
volt-ampere bothan_username = '' // The URL of your Bothan establis
var bothan_password = '' // The Universal resource locator of your Bothan install
var postPoint = function(metric) {
var bothanURL = bothan_url
var metricURL = bothanURL + '/metrics/' + metric + '.json'
var date = other Date()
                request(metricURL, occasion(error, response, body) {
json = JSON.parse(personify)
note value = (json == null) ? 0 : json.value
                request.stake(metricURL, {
auth: {
substance abuser: bothan_username,
pass: bothan_password
},
json: {
time: date.toISOString(),
value: value + 1
}
})
})
}

(I agnize IT's a faff to get the latest measured and add one (as advantageously as an extra HTTP request), sol one of the improvements I'd like to make to Bothan is to add an /append API method to just add one to a apt metric)

With this method, information technology was righteous a vitrine of calling the method with the metric linear unit name to log either a conduct operating room merit point to Bothan, the likes of so:

dash.on("detected", function (dash_id) {
if (dash_id === bad_button){
console.log("Naughty!")
postPoint('home-behavior-points')
} else if (dash_id === good_button){
console.log("Good!");
postPoint('home-acheivement-points')
}
});

I so added a package.json file with the dependencies, together with a script definition, so the code could be run vianpm start, and so looked at how I could automatically run this along my Pi on boot. I've finished this before in other projects (alike Ellie Harrison's Vending Machine art piece, which me and a colleague rengineered after the original laptop powering it broke down), and victimised init.d scripts, but this seemed equivalent overkill. This time, I fair-minded added the pursuing command to /etc/rc.topical anesthetic to make the book chug away gayly in the background:

cd /home/pi/quantified-boy && npm start &adenosine monophosphate;

(The final & is important here, as it forks the process, otherwise the Pi would just run this script and never boot properly)

I rebooted, tested and it worked. The final piece of the puzzle was displaying the metrics, so I could see at a glimpse how my son was doing, and crucially, so helium could get instant feedback after he ironed the button. I used Bothan's dashboarding feature to build a dashboard (linking to a demonstrate one here), and added the following to the~/.config/lxsession/LXDE-pi/autostart file to open the dashboard URL in Chromium in kiosk mode, and stop the Pi from exit to sleep, so I could see the dashboard at any meter:

I then rebooted the Principal investigator, and after the rush completed I saw my dashboard. Finally, I invested £27 in a 5 inch screen from Amazon River, and set the sight up in the kitchen:

A week or so has passed, and my son loves engaging with the button (I say 'button', because he never wants to fourth estate the behaviour point push button for some reason). He loves the instant gratification of seeing his points run up, and it's a big way of getting him to engage beyond the normal star chart.

The final cypher is available happening Github here, and you can install your personal free illustration of Bothan via bothan.io. You can wont this code to measure anything. The only limit, as they say, is your imaaaaaaaagination!

Tags

# nodejs# javascript# parenting# hoot-shamus

Where to Buy Princess and the Barrio Boy

Source: https://hackernoon.com/quantified-boy-726e9558594f

0 Response to "Where to Buy Princess and the Barrio Boy"

Publicar un comentario

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel