After seeing the node red on ibm i deiced that would be the best place to house the brain for our product. I Moved what back end i had already made and started completing it. Using MQTT proved very easy to use in node red, setting up connections to the broker and to topics are explained very well on there help sheet. I set up 2 debug nodes to allow me to see what was going on and what phase node red was at during testing. in total i had 2 MQTT superscribe nodes and 1 push node to send data out. Ill go through the different sections and what they do.
1.
1.
These are my top 2 nodes , the blue inject node is an auto run command to only happen once when its first deployed. This allows the java script function to kick in, the function sets my global variable to be created. This is done a solution to a problem that i will mention in phase 2
2.
this is step two , im listening through MQTT on topic relax/ball for the ball data. That then travels down to my java script file. This checks the data if its below 3850 it stores it in a global variable. This is why i needed the top level, because if i made the variable in this script every time i get new data it resets the variable to 0. so by having it only called once i get an array of data. I then output the data received to a debug node so i can keep track if its working. The blue inject node is in case MQTT is down it means i can still test the code by sending 1200 into the script.
3.
Phase 3 is the most complex phase in my node red. We start like phase 2 listening to a MQTT topic but in this case its relax/chair. This is because we are listening to is anyone sat into the chair. We are listening for "001" just encase for some reason some else is also sending message over this topic. In the chair check script , we listening to all the messages in the topic if one of them = 001 it starts a for loop. This loop adds up the total of all the data stores in the array and then divides it by the arrays length to get the average data throughout the day. We turn that into a int and sent in in a message payload down to the next node. In the emo node we check the value of the message and compare that emotion scores , the lower the number the more angry the user. we then send that score down MQTT.
What i learnt:
variables - i learnt how to create and update global variables within node red
IBM - the IBM server keeps discounting which is a problem perhaps there are not giving node enough memory to run
Node - node red is very powerful in what it can build by control everything on node you are able to see thew inter of your network and get live debug reports.
variables - i learnt how to create and update global variables within node red
IBM - the IBM server keeps discounting which is a problem perhaps there are not giving node enough memory to run
Node - node red is very powerful in what it can build by control everything on node you are able to see thew inter of your network and get live debug reports.