Individual: write an application that interfaces with an input &/or output device that you made:
group assignment: compare as many tool options as possible
Google Script to RGB.
https://flows.nodered.org/node/node-red-node-google
Languages:
Pick a programming language
Talk to a device
Do a user interface
Do graphics
Setup a service in the cloud
Device interfaces:
Binder
Store data:
data interfaces
Write data to file, read to memory, then read memory.
Databases might not be neccesary for less than gigabites of data.
User interfaces
TK interface
Defining Idle routine - w
def idle(parent,canvas):
wxwidgets
Sets of widgtes
Qt, PyQt: https://www.qt.io/
GTK, PyGTK https://www.gtk.org/
Clutter, PyClutter https://blogs.gnome.org/clutter/
HTML forms: Java script in HTML https://www.w3.org/TR/html5/forms.html
JQuiry: http://jqueryui.com/widget/
Flat UI: http://designmodo.github.io/Flat-UI/
Lots of different Java Script programming:
Meteor: https://www.meteor.com/
Babel
React, React Native
Cordova, Ionic
Electron, Blynk, Node-RED
Neil tend to use HTML forms, does not require loading, build in to browser.
https://www.w3.org/TR/html5/forms.html
Graphics
Visual representations of, what is happening.
X Windows https://www.x.org/wiki/ ancient... Used to be important because it talks directly to the window manager. Not required any more because of GPU and browsers
AWT, JFC, Swing. Frameworks for Java - would not recommend in not used.
Canvas element: https://www.w3.org/TR/2dcontext/ (like GIMP - raster)
SVG: https://www.w3.org/TR/SVG/ (like inkscape)
WebGL: https://www.khronos.org/webgl/ (not recommended for beginners)
Three.js:
World building environments:
Unity: https://unity3d.com/
Unreal: https://www.unrealengine.com/en-US/what-is-unreal-engine-4
Multimedia:
SDL - Multimedia
HTML5:
Math:
Netlib (old)
MATLAB (build on top of netlib)
Data collection and representation:
Simple code: line.py: http://academy.cba.mit.edu/classes/interface_application_programming/programs/line.py
IPython: Build a interactive notebook
D3: Rich plots: https://d3js.org/
performance
Speed measured in 'Mega flops'.
Python: pi.py, numpi.py: Fast
Cython: Even faster way to calculte using python.
Using web workers to devide work and increase speed. pi.html, pi.c, pim.c
Deploy - services to run stuff in the cloud
Amazon AWS EC2 Lambda
Google Cloud
Competitors: DigitalOcean, Linode, Heroku, Docker
Installing Node-RED:
https://www.npmjs.com/package/node-red
I found this quick guide https://www.npmjs.com/package/node-red#quick-start. and installed Node-RED with the following command:
sudo npm install -g --unsafe-perm node-red
Result:
npm WARN deprecated [email protected]: you can use npm install i18next from version 2.0.0
npm WARN deprecated [email protected]: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated [email protected]: This project is unmaintained
npm WARN deprecated [email protected]: This project is unmaintained
npm WARN deprecated [email protected]: This project is unmaintained
npm WARN deprecated [email protected]: This project is unmaintained
/usr/local/bin/node-red-pi -> /usr/local/lib/node_modules/node-red/bin/node-red-pi
/usr/local/bin/node-red -> /usr/local/lib/node_modules/node-red/red.js
> [email protected] install /usr/local/lib/node_modules/node-red/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
[bcrypt] Success: "/usr/local/lib/node_modules/node-red/node_modules/bcrypt/lib/binding/bcrypt_lib.node" is installed via remote
added 336 packages in 13.458s
I then updated using the following command:
sudo npm i -g npm
Result:
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
added 89 packages, removed 42 packages and updated 67 packages in 15.615s
And then installed the Google API by running the following command in the root directory of your Node-RED install:
cd /Users/nicolaisens/node_modules/npm
npm install node-red-node-google
Result:
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm notice created a lockfile as package-lock.json. You should commit this file.
added 58 packages in 6.352s
I found this thread: https://github.com/npm/npm/issues/13525
npm install [email protected] --save-dev
I still get the error, but running the following command, showed that node-red is not dependand on version:
npm ls minimatch
│ └── [email protected]
I then found this thread, and ran the following commands:
npm update [email protected]
npm update -d
Which still didn't remove the warning, so I tried the following command from the same thread:
npm update -g [email protected]
Which still didn't remove the warning, so I tried the following command from the same thread:
Following a comment on this GitHub issue,
$ npm update minimatch
$ npm -v 2.10.1
$ npm install -g npm@3/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
[email protected] /usr/local/lib/node_modules/npm
$ npm install -g [email protected]
/usr/local/lib
├── [email protected]
└── [email protected]
$ npm -v
3.10.5
$npm view minimatch version
3.0.2
I then decided to uninstalle the google module, using the following command
npm uninstall node-red-node-google --save
Got the following result:
npm WARN deprecated [email protected]: several bugs fixed in v3.2.1
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
added 566 packages from 345 contributors, removed 5 packages and moved 1 package in 24.794s
I then updated minimatch and checked the dependencies, and reinstalled the google node:
npm update -g [email protected]
npm ls minimatch
npm install node-red-node-google
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
added 6 packages from 19 contributors in 7.656s
By following this guide on GitHub i installed the Google Module in another folder:
cd /Users/nicolaisens/.node-red
npm install node-red-node-google
Result:
Familiens-MacBook-Pro:.node-red nicolaisens$ npm install node-red-node-google
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
added 60 packages from 74 contributors in 3.413s
I still got the warning - but this time the Google Module turns up in Node-RED.
I then prepared the API by completing the following Pre-requisites:
You must enable the Google APIs.
In the Google Developer Console under "Api & auth" select "APIs"
Search for "Directions API" click on it and then click "Enable API"
Create credentials: and got an API key (listed below)
The key can be restricted later if needed, floowl this link:
I created a project:
Name: Calendar integration
project ID will be calendar-integration-201607
API key: AIzaSyDLFG2zsrU0NZfu8cHFDnyoW0Y58pU5YNg
node-red
And openedhttp://localhost:1880
Create your own project by following these instructions
Please configure the authorized Redirect URIs of your app to include the following url:
http://localhost:1880/google-credentials/auth/callback
Here is your client ID
611841483681-3dkmih3ou59lr6geqvdsk0v28qma6chr.apps.googleusercontent.com
Here is your client secret
1VzdQOgcslce6afpGE8JOpLD
When pressing authorisation with Google - I got the following message:
auth worked but profile fetching failed
Google search led me to this issue on GitHub -after which I enable the Google+ API in Google's developer console:
https://github.com/node-red/node-red-web-nodes/issues/206
I retried the authoriztion, and got following succes message:
Authorised - you can close this window and return to Node-RED
I entered name of the calender - and deployed the workshpace.
I decided to also add a trigger for the event (an incomming mail)
And added app specific password (to my icloud mail)
After some investigation
https://stackoverflow.com/questions/41505374/read-google-calendar-date-and-title-in-node-red?rq=1
I ended on this side:
https://flows.nodered.org/node/node-red-contrib-google
And decided to install the following code, that as mentioned on the page: "contains two nodes. There is configuration node made for maintaining connection to Google API Services (google-conn) and regular node providing posibility to call any method of any API exposed via official Google's Node.js Client."
cd /Users/nicolaisens/.node-red
npm install node-red-contrib-google
I got some warnings, but tried to open anyways:
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
added 75 packages from 62 contributors in 7.373
Opening node-red:
node-red
And openedhttp://localhost:1880
With the following error:
google-credentials:5e90b550.9181cc] 1. failed attempts.
I added the Google Node and created a new service account.
Service account name: Calender Integration
Role: Owner
Service account ID: calender-integration (Calendar integration-f13e39cfe5c2.json)
Key type: JSON
ID: f13e39cfe5c22774136699c148804f081efb9687
Add Google Node
Add Inject node:
As mentioned on this page (https://stackoverflow.com/questions/41505374/read-google-calendar-date-and-title-in-node-red?rq=1\ I then passed "the "calendarId" into the node as a json: {"calendarId" : "<your cal id goes here>"}"... into an inject node to inject this input into the "google" node".
{"calendarId" : "[email protected]"}
Debug gave the following error:
"Error: Access Not Configured. Calendar API has not been used in project 611841483681 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=611841483681 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
So I added the following to the "uthorized redirect URIs:"
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.readonly
That didn't work, so I added the Google Calender API (as menitioned in the error message;-)
Didn't work at once, so I added the following to to URI - and then it works:
https://www.googleapis.com/calendar/v3
Free / Busy Code:
https://developers.google.com/calendar/v3/reference/freebusy/query?authuser=1
Select string
Create string using Google API: https://developers.google.com/calendar/v3/reference/events/get
Creating
Then
https://flows.nodered.org/node/node-red-node-google
A set of Node-RED nodes to access various Google services:
npm install node-red-node-google
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff; min-height: 13.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d53bd3; background-color: #ffffff}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.s2 {font-variant-ligatures: no-common-ligatures; color: #bfbfbf; background-color: #000000}
span.s3 {font-variant-ligatures: no-common-ligatures; background-color: #999900}
span.s4 {font-variant-ligatures: no-common-ligatures; color: #d53bd3}
span.s5 {font-variant-ligatures: no-common-ligatures; color: #990000; background-color: #000000}
span.s6 {font-variant-ligatures: no-common-ligatures; color: #000000}
Last login: Tue Apr 17 16:33:54 on ttys000
Familiens-MacBook-Pro:~ nicolaisens$ npm install node-red-node-google
[email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npmWARNenoentENOENT: no such file or directory, open '/Users/nicolaisens/package.json'
npmWARNnicolaisens No description
npmWARNnicolaisens No repository field.
npmWARNnicolaisens No README data
npmWARNnicolaisens No license field.
npmERR!path/Users/nicolaisens/node_modules/npmi/node_modules/npm/node_modules/ansistyles
npmERR!codeENOENT
npmERR!errno-2
npmERR!syscallrename
npmERR!enoentENOENT: no such file or directory, rename '/Users/nicolaisens/node_modules/npmi/node_modules/npm/node_modules/ansistyles' -> '/Users/nicolaisens/node_modules/npmi/node_modules/npm/node_modules/.ansistyles.DELETE'
npmERR!enoentThis is related to npm not being able to find a file.
npmERR!enoent
npmERR!A complete log of this run can be found in:
npmERR! /Users/nicolaisens/.npm/_logs/2018-04-19T06_34_32_966Z-debug.log
Familiens-MacBook-Pro:~ nicolaisens$
Familiens-MacBook-Pro:~ nicolaisens$
https://developers.google.com/calendar/quickstart/nodejs?authuser=1
Step 1: Turn on the Google Calendar API
Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
On the Add credentials to your project page, click the Cancel button.
At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button.
Select the Credentials tab, click the Create credentials button and select OAuth client ID.
Select the application type Other, enter the name "Google Calendar API Quickstart", and click the Create button.
Click OK to dismiss the resulting dialog.
Click the file_download (Download JSON) button to the right of the client ID.
Move this file to your working directory and rename it client_secret.json.
Here is your client ID
642414429445-drhoqt6d3nc5ekeqlvlkpt5s5ajo00p2.apps.googleusercontent.com
Here is your client secret
N_lMT9Du69z3i3zkZawql7lu
I then succesfully installed the Google API using the following command
npm install googleapis@27 --save
Which suggested me to update NPM which I did using the following command:
sudo npm i -g npm
https://docs.npmjs.com/getting-started/installing-node#1-install-nodejs--npm
Created NPM login credentials:
clausnicolaisen
H*****
Familiens-MacBook-Pro:~ nicolaisens$ npm login
Username: clausnicolaisen
Password:
Email: (this IS public) [email protected]
Logged in as clausnicolaisen on https://registry.npmjs.org/.
Familiens-MacBook-Pro:~ nicolaisens$
I followed this guided and execute the following code:
https://github.com/creationix/nvm/blob/master/README.md#installation
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
Familiens-MacBook-Pro:~ nicolaisens$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12818 100 12818 0 0 45224 0 --:--:-- --:--:-- --:--:-- 45453
=> Downloading nvm from git to '/Users/nicolaisens/.nvm'
=> Cloning into '/Users/nicolaisens/.nvm'...
remote: Counting objects: 267, done.
remote: Compressing objects: 100% (242/242), done.
remote: Total 267 (delta 31), reused 86 (delta 15), pack-reused 0
Receiving objects: 100% (267/267), 120.33 KiB | 7.08 MiB/s, done.
Resolving deltas: 100% (31/31), done.
=> Compressing and cleaning up git repository
=> Appending nvm source string to /Users/nicolaisens/.bash_profile
=> Appending bash_completion source string to /Users/nicolaisens/.bash_profile
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:
/usr/local/lib
=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:
$ nvm use system
$ npm uninstall -g a_module
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Familiens-MacBook-Pro:~ nicolaisens$
I closed the browser and ran the following commads:
nvm use system
Result:
Last login: Tue Apr 24 15:32:56 on ttys001
Familiens-MacBook-Pro:~ nicolaisens$ nvm use system
Now using system version of node: v8.11.1 (npm v6.0.0)
Familiens-MacBook-Pro:~ nicolaisens$
And the uninstalle node-red, using the following command:
npm uninstall -g [email protected]
And the verified that NVM is working:
command -v nvm
Bas input:
Use node.js
Find examples
The following error made me install 'mkdirp'.
Error: Cannot find module 'mkdirp'
npm install mkdirp
I then got a Google Auth error:
TypeError: Cannot read property 'OAuth2' of undefined
And followed the comment in this thread and installed the google-auth-library and changed this line:
const google = require('googleapis');
const {google} = require('googleapis');
http://danlec.com/st4k#questions/49848105
I ran the then recieved this error:
TypeError: Cannot destructure property `client_secret` of 'undefined' or 'null'.
Here is your client ID: 611841483681-0146obulke9368h54m72no28tgpv0cbi.apps.googleusercontent.com
Here is your client secret: OdYwo8SfLz5-RLkDcLrE89st
Further reading
Google APIs Client for Node.js documentation
https://github.com/google/google-api-nodejs-client/#google-apis-nodejs-client
Create events
https://developers.google.com/calendar/create-events
Calendar API reference documentation
https://developers.google.com/calendar/v3/reference/
URI:
http://localhost:1880/google-credentials/auth/callback
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.readonly
https://www.googleapis.com/calendar/v3
Serial communication:
npm i node-red-node-serialport
https://flows.nodered.org/node/node-red-node-serialport
npm install serialport
Download FTDI driver
https://www.intra2net.com/en/developer/libftdi/download.php
Requirements and dependencies
libusb 1.0 - Library for talking to USB devices from user-space. Needed by libftdi.
libconfuse - Library for parsing configuration files. Needed by ftdi_eeprom.
Installed libusb (http://libusb.info/\)
Birita
Serial Connection
Software serial: MISO MOSI.
Pin connected to FTDI
Bridge uses SPI header get reset line - PB0 and PB1
FTDI header, ISP, AT45
See Arnar Dadi
Linda Wander 2012, week 13.
Hver bit tager et stykke til 9600 bits / sekund
.000104 s = 0.104 m/s = 1 micro sek
5 V base: start bit = 0V, stopbit altid = 1
8 Bit sendes af gangen
ASCII table:
Dec Hex
0: 48
ASCII = 0 or Hex (0x30)
Hex 3 0
0011 0000
Get chat & Put char - can always be copy pasted
Put string
ESP8266 connection to Attiny45 / 44
Either Serial or MQTT Node-Red