E Book
E Book
E Book
By TESR
NodeRed for IoT
node-red
NodeRed for IoT
http://localhost:1880
NodeRed for IoT
Auto Start
Task Scheduler
NodeRed for IoT
Edit Name
NodeRed for IoT
NodeRed for IoT
C:\Users\<user>\AppData\Roaming\npm\node-red.cmd
NodeRed for IoT
NodeRed for IoT
NodeRed for IoT
User authentication
NodeRed for IoT
Dicrectory C:\Users\name\.node-red
To enable user authentication on the Editor and Admin API, add the following to your settings.js file:
adminAuth: {
type: ”credentials” ,
users: [{
username: “admin” ,
password: “$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.” ,
permissions: “*”
}]
}
NodeRed for IoT
2
3
2
3
JSON format
NodeRed function
Set and Get global variable (1)
NodeRed function
Set and Get global variable (2)
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Dashboard
NodeRed Datalogger
NodeRed Datalogger
NodeRed Datalogger
NodeRed Datalogger
NodeRed Datalogger
NodeRed Datalogger
NodeRed Datalogger
NodeRed for IoT
Line Notify
NodeRed with Line Notify
https://notify-bot.line.me/en/
NodeRed with Line Notify
NodeRed with Line Notify
NodeRed with Line Notify
NodeRed with Line Notify
Install Line Library
1
2
3
NodeRed with Line Notify
NodeRed with Line Notify
Result message
NodeRed with Line Notify
Result Sticker
https://devdocs.line.me/files/sticker_list.pdf
Package ID
ID
NodeRed with Line Notify
Result image url
Image url
NodeRed with Line Notify
Http post request(message)
msg.url = "https://notify-api.line.me/api/notify";
var AccessToken = "Zg92EXNIowH1wJfryuT29SurnlRnjAiVrswIQMxvGAI";
msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer '+ AccessToken};
msg.payload = {
"message": "Photo from Url testing",
"imageThumbnail":msg.payload,
"imageFullsize":msg.payload
};
return msg;
NodeRed with Line Notify
Result Http post request(photo url)
NodeRed with Line Notify
Http post request(Sticker)
msg.url = "https://notify-api.line.me/api/notify";
var AccessToken = "Zg92EXNIowH1wJfryuT29SurnlRnjAiVrswIQMxvGAI";
msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer '+ AccessToken};
msg.payload = {
"message": "Stick testing",
"stickerPackageId" : "2",
"stickerId" : "41"
};
return msg;
NodeRed with Line Notify
Result Http post request(Sticker)
NodeRed Send Email
Gmail
Sending Email
NodeRed Send Email
https://myaccount.google.com/lesssecureapps
NodeRed Send Email
NodeRed Send Email
Result
NodeRed influxdb
NodeRed influxdb
This database is perfect for Storing data of variables that make changes in the time,
for the field of monitoring of applications of the Internet of things like sensors in
real time.
NodeRed influxdb
Installing InfluxDB
Windows Binaries (64-bit)
https://dl.influxdata.com/influxdb/releases/influxdb-1.8.2_windows_amd64.zip
unzip influxdb-1.8.2_windows_amd64
Ref. https://portal.influxdata.com/downloads
NodeRed influxdb
Installing InfluxDB
Start service InfluxDB by going to “cmd”
Connect to InfluxDB
influx
Database name
NodeRed influxdb
Installing InfluxDB on NodeRed
use test
select * from test_time Measurement
exit
Result
NodeRed Grafana
NodeRed Grafana
Run at “grafana-server.exe”
unzip
NodeRed Grafana
Login Grafana
User:admin
Pass:admin
http://yourserverip:3000/login
NodeRed Grafana
Add Data Source
URL: http://localhost:8086
Database: test
NodeRed Grafana
Create Dashboard
NodeRed Grafana
Create Dashboard
https://grafana.com/grafana/plugins?utm_source=grafana_plugin_list
NodeRed Grafana
Grafana install app and Plugin
Gauge
NodeRed Grafana
Grafana install app and Plugin
http://localhost:1880/Datatest?payload=on&sensor=1234
NodeRed Grafana
Grafana install app and Plugin
Button
NodeRed Grafana
Grafana install app and Plugin
Master
Slave1
A/TX/RX/+ Slave2
B/TX/RX/-
Slave3
NodeRed ModBus RS485
Function Code
Function type Function name Function code
Physical Discrete Inputs Read Discrete Inputs 2
Read Coils 1
Bit access
Internal Bits or Physical Write Single Coil 5
Coils
Write Multiple Coils 15
1 Quantity = 2 Bytes
NodeRed ModBus RS485
Array int16 to float32 “CD AB” format (decode data)
NodeRed ModBus RS485
Modbus Write
NodeRed ModBus RS485
Example
NodeRed ModBus RS485
Example
Comport RS485
USB comport to RS485 Convertor
Computer
A A
B B
12V
GND
NodeRed ModBus RS485
Example
ใช้ protocol การสื่ อการแบบ MODBUS-RTU โดย Baud rate ในตอนเริ่มต้ นคือ 9600 bps, 1 start bit , 8 data bits, no parity
Communication address range: 1-255 ในตอนเริ่มต้ นคือ 0x01
Baud rate range: 1200,2400,4800,9600,19200 bps
Return format
Definition Address Function Code Number of data Temp data Hum data CRC Check
DATA ADDR 0x03 0x02 0x0001 0x0001 CRC 16
BYTES 1 1 1 2 2 2
examples of raw data 0x01 0x03 0x04 0x01 0x56 0x03 0x0E 0x9A 0xEB
Thermometer: 0x0156 (hexadecimal) = 342(DEC)=34.2 °C, when the temperature is lower than 0 °C,
the data is expressed in two’s complement,0xFF64 (hexadecimal) -156(DEC) = -15.6 °C.
Humidity calculation: 0x030E(hexadecimal) = 782(DEC) = 78.2%
NodeRed ModBus RS485
Example
Contact us
: 090-465-6519 : ceo.anoney.potter@gmail.com
: @ion1900z : www.facebook.com/ThaiEmbedded
: www.youtube.com/tesrchannel : tesracademy.wordpress.com
Anoney Potter