The Internet of Things

Node-Red Security

Log in to the Raspberry Pi using Putty 

Stop Node-Red

  • sudo systemctl disable nodered.service
  • node-red-stop
  • sudo reboot & exit

Generating new SSH keys

  •  cd .node-red  (cd /home/pi/.node-red or cd ~/.node-red)
  •  openssl genrsa -out privatekey.pem 1024
  •  openssl req -new -key privatekey.pem -out private-csr.pem
  •  openssl x509 -req -days 365 -in private-csr.pem -signkey privatekey.pem -out certificate.pem
  • ls -all and you find 3 new files:
    • certificate.pem
    • private-csr.pem
    • privatekey.pem

 Update settings.js

  • nano settings.js
  • uncomment lines:
    •  var fs=required("fs");
    •  
    •  https: {
    •  key: fs.readFileSunc('/home/pi/.node-red/privatekey.pem')
    •  cert: fs.readFileSunc('/home/pi/.node-red/certificate.pem')
    •   },
    •  
    •  adminAuth: {
    •  type: "credentials",
    •  users: [{
    •  Username: "admin",
    •  password: " --- ",
    •  permissions: "*"
    •  }]
    • },
  • save & exit settings.js 

Install node-red-admin

  • su (to log as root)
  • npm install -g node-red-admin
  • exit
  •  pwd
  • cd .node-red
  • node-red-admin hash-pw
Enter the password you want, copy the hash code and save this to the 'password' line in the settings.js file.

Start Node-red

  • sudo systemctl enable nodered.service
  • node-red-start
Now you cane see Node-red in your browser by using https://'ip adres raspberry pi':1880
and login with admin and your password.

Update Node-Red on the Raspberry Pi

 

Update Raspberry Strecht Lite to the latest version.

Log in to the Raspberry Pi using Putty
Type the following commands one by one
  • sudo rpi-update
  • sudo reboot & exit (reboot the Raspberry Pi)
  • sudo apt-get -y update
  • sudo apt-get -y upgrade
  • sudo apt-get dist-upgrade
  • sudo reboot & exit (reboot the Raspberry Pi)


Install the latest Node.js and Npm

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

To find the version type this commands:
node -v
v8.9.3
npm -v
5.5.1

Install n

  • sudo npm install -g n
  • sudo n latest
  • sudo npm install -g npm@latest
  • sudo reboot & exit (reboot the Raspberry Pi)
To find the version type this commands: 
node -v
v9.3.0
npm -v
5.6.0

Start and Stop Node-Red

node-red-stop - to stop Node-red
node-red-start - to start Node-Red
node-red-log - to view the recent log output
sudo systemctl enable nodered.service  - to autostart Node-Red at every boot
sudo systemctl disable nodered.service - to disable autostart on boot

Fix the Serialport Error

  • cd .node-red
  • node-red-stop
  • sudo npm rebuild
  • node-red-start (ctrl c to exit Node-red)

Start Node-Red as a service

  • sudo systemctl enable nodered.service
  • node-red-start (ctrl c to exit Node-red)
Now you cane see Node-red in your browser by using http://'ip adres raspberry pi':1880

https://youtu.be/B0hpv_8is0Q




MQTT


MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code
footprint is required and/or network bandwidth is at a premium. For example, it has been used in sensors communicating to a broker via satellite link, over occasional dial-up connections with healthcare providers, and in a range of home automation and small device scenarios. It is also ideal for mobile applications because of its small size, low power usage, minimised data packets, and efficient distribution of information to one or many receivers.

MQTT 








What do you need?

  1. Raspberry Pi
  2. Power supply 5V 2A
  3. SD Card with Raspbian Strech Lite link
  4. UTP Cable
  5. Case for the Raspberry Pi
  6. PuTTy on a Windows or Linux computer.

  Setup Raspbian Stretch Lite

  1. Installation of the MQTT Broker on Raspberry Pi. http://mqtt.org/
  2. Make a SSH connection with PuTTy:
    Login: 'pi'
    Password: 'raspberry'
  3. sudo apt-get update 
  4. sudo apt-get install mosquitto 
  5. sudo apt-get install mosquitto-clients
  6. Testing the Working of MQTT
  7. Open two putty programs on windows, you can do this by clicking the putty.exe file and enter the host name and click to open do this twice so that two putty programs access Pi via ssh. Lets say putty1 and putty2 are open and connected to Pi via ssh for our convenient.
  8. In putty1 window type the command with the topic name armtronix_mqtt this topic name can be anything, according to the convenience of the user .

    mosquitto_sub –d –t YouTube test
  9. In putty2 image 2 window type the following command with the same topic i.e armtronix_mqtt

    mosquitto_pub –d –t YouTube test –m “Hello from Yuotube”
  10. Now come to the window putty1, image 1 here you will be able to see the message

    Hello from Yuotube


https://youtu.be/hhcc9Pt03x8







Node-Red


Install Node-red on the Raspberry Pi

Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.




What do you need?

  1. Raspberry Pi
  2. Power supply 5V 2A
  3. SD Card with Raspbian Strech Lite link
  4. UTP Cable
  5. Case for the Raspberry Pi
  6. PuTTy on a Windows or Linux computer.


https://youtu.be/3SxMvdSnaQk

Setup Raspbian Strech Lite without a Monitor and Keyboard

What do you need?

  1. Raspberry Pi
  2. Power supply 5V 2A
  3. SD Card with Raspbian Strech Lite link
  4. UTP Cable
  5. Case for the Raspberry Pi
  6. PuTTy on a Windows or Linux computer.
  7. ipscan24.exe

  Setup Raspbian Stretch Lite

  1. Install PuTTy http://www.putty.org/
  2.  Run ipscan24.exe to find the Raspberry pi IP address.
  3. Enable SSH by placing a file named “ssh” (without any extension) onto the boot partition of the SD card.
  4. Make a SSH connection with PuTTy:
    Login: 'pi'
    Password: 'raspberry'
  5. Run 'Sudo Raspi-config' on the Raspberry pi to:
    Change user password.
    Expand filesystem.
    Set the memory for the GPU to 16 MB.
    Set the Localisation options - Language - Timezone and Wi-fi country.
  6. Reboot the Raspberry Pi 'sudo reboot & exit'
  7. Make a SSH connection with PuTTy.
  8. Run 'sudo apt-get update'
  9. Run 'sudo apt-get upgrade'
  10. Now you have a Rasberry Pi with teh latest Rasbian software installed.



https://youtu.be/5p60JCOu_04

Install Raspbian Stretch Lite on the Raspberry Pi 3.

What do you need?

  1. Raspberry Pi
  2. Power supply 5V 2A
  3. SD Card
  4. UTP Cable
  5. Case for the Raspberry Pi

Install Raspbian Stretch Lite


  1. Download Raspbian Stretch Lite from https://www.raspberrypi.org
  2. Unzip with 7-Zip http://www.7-zip.org/
  3. Install Win 32 Disk Imager https://sourceforge.net/projects/win32diskimager/
  4. Save the image to the SD card with Win 32 Disk Imager



https://youtu.be/EYR8DrWFRzg


8/10/2017