Skip to content

MSR806/IoT_pub_sub

Repository files navigation

IoT

Installation Guide on Raspberry Pi

Raspberry Pi Imager

https://www.raspberrypi.org/downloads/

Download Putty

https://putty.org/

Connecting to Rpi via VNC

https://www.raspberrypi.org/documentation/remote-access/vnc/
You might also face a situation of Cannot currrently show the desktop error for that https://www.tomshardware.com/how-to/fix-cannot-currently-show-desktop-error-raspberry-pi

Update your pi

sudo apt-get update
sudo apt-get upgrade

Connecting to wifi on Raspberry Pi when headless

https://www.raspberrypi.org/documentation/configuration/wireless/headless.md
sudo raspi-config
sudo reboot -h now

Install Mosquitto MQTT

sudo apt install -y mosquitto mosquitto-clients

Run Mosquitto MQTT at boot:
sudo systemctl enable mosquitto.service

Check Mosquitto is installed:
mosquitto -v

Install node-red:

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

Run node-red at boot:
sudo systemctl enable nodered.service

Install SQLite:

sudo apt-get install sqlite3

Sqlite3 commands

sqlite3 data.db

This will create a database in the file data.db. We should now be in a sqlite shell, so type:
CREATE TABLE climate (reading_time datetime, temperature float, humidity float);

Now we’ve created a table called climate, we can add to that table. Let’s test it by adding a random date, time, humidity and temperature:
INSERT INTO climate (reading_time, temperature, humidity) values (“2011-06-21 12:34:56”, 20, 77);

You can view the contents of the table,
SELECT * FROM climate;

And you can clear the table,
DELETE FROM climate;

Node Red Installation guide on Windows

1. Install Node.js

Download the latest 12.x LTS version of Node.js from the official Node.js home page. It will offer you the best version for your system.

Run the downloaded MSI file. Installing Node.js requires local administrator rights; if you are not a local administrator, you will be prompted for an administrator password on install. Accept the defaults when installing. After installation completes, close any open command prompts and re-open to ensure new environment variables are picked up.

Once installed, open a command prompt and run the following command to ensure Node.js and npm are installed correctly.

Using Powershell: node --version; npm --version

Using cmd: node --version && npm --version

You should receive back output that looks similar to:

v12.15.0
6.14.5

2. Install Node-RED

Installing Node-RED as a global module adds the command node-red to your system path. Execute the following at the command prompt:

npm install -g --unsafe-perm node-red

3. Run Node-RED

Once installed, you are ready to run Node-RED.