Data Logging With Node-RED and Arduino
by GokulP3 in Circuits > Arduino
28946 Views, 68 Favorites, 0 Comments
Data Logging With Node-RED and Arduino
Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.
Node-RED provides a browser-based flow editor that makes it easy to wire together flows using the wide range nodes in the palette. Flows can be then deployed to the runtime in a single-click.
What is this Instructable all about-
In this Instructable, we are going to feed analog data from Arduino to Twitter and to your own Node-RED supported UI dashboard through the serial port. A practical M2M or SCADA based technique. All you need is
- WIN10 laptop with internet connectivity and Arduino IDE installed in it.
- Arduino Board and an analog input Sensor.
Why Node-RED?
Open-source
- Well is it a Multi-platform/Cross-platform.
- Browser based and supported by cloud platforms like Bluemix of IBM.
- Supports real-time automation of M2M and IoT protocols.
- Future of Industrial IoT(Internet of Things)
Preparing Your Arduino Board
Im working with- Arduino UNO and MQ-7 gas sensor, you can use any analog sensors of your choice, even a POT would do.
Things to follow-
Baud-rate should be 57600.
Delay should be more than 60000 ms, as per Twitter standards.
Don't use/open your serial monitor, keep your COM port free.
Keep your arduino board connected to your computer.
Arduino Code-
const int AOUTpin= 0;//the AOUT pin of the CO sensor goes into analog pin A0 of the arduino int value; void setup() { Serial.begin(57600);//sets the baud rate pinMode(AOUTpin, INPUT);//sets the pin as an input to the arduino } void loop() { value= analogRead(AOUTpin);//reads the analaog value from the CO sensor's AOUT pin Serial.print("CO value: "); Serial.println(value);//prints the CO value delay(60000); }
Installing Node-RED in Your WINDOWS 10 Computer.
Step1- Download node.js for your computer, Click here.
Step2- Open the command prompt and install Node-RED with these command-
npm install -g node-red
Step3- Now run your Node-RED, with this command-
node-red
Step4- Copy the local-server link to your browser(Chrome)- http://localhost:1880/#
Yaa-Hoo, it is done!
Exploring the Node-RED Interface
Node-RED is of three panels,
-Nodes Panel, list of nodes.
-Flow Panel, to design your flow/wiring of the project.
-Third one is of three sub panels named as INFO panel, Debug panel and Dashboard panel.
Explore them.
Wiring Your Project
Now it is time to create your project,
Choose the following NODES-
Serial Node Input, Twitter Node, Text Node from Dashboard and debug node.
(or)
Copy and Import the following code (Menu>Import>Clipboard)
[{"id":"d6230d5f.c05e","type":"serial in","z":"b9075383.db257","name":"","serial":"1b8769a6.621dc6","x":91,"y":135,"wires":[["ea730c90.ebc4b","84c15113.4ecec","e146cbcf.251818"]]},{"id":"ea730c90.ebc4b","type":"debug","z":"b9075383.db257","name":"","active":true,"console":"false","complete":"false","x":501,"y":274,"wires":[]},{"id":"e146cbcf.251818","type":"twitter out","z":"b9075383.db257","twitter":"","name":"Tweet","x":689,"y":144,"wires":[]},{"id":"84c15113.4ecec","type":"ui_text","z":"b9075383.db257","group":"90f1c978.bba628","order":0,"width":0,"height":0,"name":"CO in PPM","label":"Arduino Reading","format":"{{msg.payload}}","layout":"col-center","x":467,"y":41,"wires":[]},{"id":"1b8769a6.621dc6","type":"serial-port","z":"b9075383.db257","serialport":"COM7","serialbaud":"57600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false},{"id":"90f1c978.bba628","type":"ui_group","z":"b9075383.db257","name":"CarbonMonoxide in Atmosphere","tab":"93b83a33.771108","disp":true,"width":"9"},{"id":"93b83a33.771108","type":"ui_tab","z":"b9075383.db257","name":"Home","icon":"dashboard"}]
SERIAL NODE-
If you couldn't find the serial node, install it with following command, and restart your computer.
npm i node-red-node-serialport
Configure the node with your COM port in which Arduino is connected. It is done manually, in my case it is COM7.
Like this configure other nodes.
Deployed Data
Now open your TWITTER and DASHBOARD, that should be feeded with data.
This is more of M2M protocol. Will be posting another Instructable of IoT application.
Mission Accomplished! Post your reviews! Thank you guyz!