# IBM Watson Sensor Support

**URL:** https://discourse.nodered.org/t/ibm-watson-sensor-support/13738
**Category:** General
**Created:** [27 July 2019 06:09 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738 "2019-07-27T06:09:18Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 20:41 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/21 "2019-07-29T20:41:50Z")

</div>

ALright thanks for all the help I really appreciate it \<3

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 20:59 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/22 "2019-07-29T20:59:41Z")

</div>

Actually is there anyway to reset to variable to 0 at the beginning of each "session"

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [29 July 2019 21:02 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/23 "2019-07-29T21:02:56Z")

</div>

Session?

You mean when node-red restarts?

Global variables don't normally retain value. Have you tried restarting?

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:15 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/24 "2019-07-29T21:15:08Z")

</div>

How do i restart the whole program

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:15 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/25 "2019-07-29T21:15:32Z")

</div>

I already lost some of my saves lol by not being careful

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:15 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/26 "2019-07-29T21:15:53Z")

</div>

![Screenshot%20(9)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/025578d83f44b52cfdb5270f3605d6d9c992b450.png)  
Also what is going on with kicks here

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [29 July 2019 21:18 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/27 "2019-07-29T21:18:13Z")

</div>

No idea. But if you add debug nodes like I suggested twice before, you could figure it out yourself.

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:19 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/28 "2019-07-29T21:19:07Z")

</div>

any idea on reseting the values to 0 though?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [29 July 2019 21:24 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/29 "2019-07-29T21:24:20Z")

</div>

Like I said, restarting node-red will clear values.

You can also use an inject node linked to a change node to set `global.count` to zero.

Can I also suggest you do some [reading](https://nodered.org/docs/user-guide/) and check out the [cookbook](https://cookbook.nodered.org/). Try the examples. Learn to walk before you try to run.

And don't forget to add debug nodes after every node so you can understand what happens as the msg travels through the flow.

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:28 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/30 "2019-07-29T21:28:59Z")

</div>

Do you have any idea why my variables for kicks and sprints might be getting confused because currently they are printing as the same number as you can see in the screenshot. what should i do?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [29 July 2019 21:32 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/31 "2019-07-29T21:32:58Z")

</div>

As @Steve-Mcl has suggested quite a lot of times, you can use a Debug node throughout your flow to figure out what is happening to the messages. You have not acknowledged that advice yet ask us for what could be happening in your flows.

We cannot tell anything from a screenshot with no information about what those Function nodes currently contain.

If you wanted to share some actual details, then make sure you read this post first on how to properly share code in the forum - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:48 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/32 "2019-07-29T21:48:26Z")

</div>

Here is my latest code. As you can see the kicks and sprints seem to be getting confused in the output for some reason. This project is for a summer program that I am doing in high school at UC Davis, that is why I have very basic knowledge and require substantial assistance. All your help is appreciated 🙂

 ![Screenshot%20(9)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/025578d83f44b52cfdb5270f3605d6d9c992b450.png)

Def Kicks

```auto
var kick = global.get( "count")||0;
// sprint++;
global.set('count', kick);
msg.payload.kick = kick; 
return msg;

```

Analyze Kicks

```auto
var gyro = msg.payload.d.Y
var kick = msg.payload.kick;
if (gyro < -600) {
   kick++;
   global.set('count', kick);
}
msg.payload.kick = kick;
return msg;

```

Def Sprint

```auto
var sprint = global.get( "count")||0;
// sprint++;
global.set('count', sprint);
msg.payload.sprint = sprint; 
return msg;

```

Analyze Sprint

```auto
var accel = msg.payload.d.Z 
var sprint = msg.payload.sprint;
if (accel > 1500) {
   sprint++;
   global.set('count', sprint);
}
msg.payload.sprint = sprint;
return msg;

```

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:52 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/33 "2019-07-29T21:52:29Z")

</div>

![Screenshot%20(10)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/628489955f0c44e014c0abab969eeb818da1ac5d.png)

How come two different variables have the same value?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [29 July 2019 21:53 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/34 "2019-07-29T21:53:02Z")

</div>

What do the messages coming from the IBM IoT node look like? From the screenshot, I see you have a Debug node attached to it, but it appears to be configured to only show `msg.payload.d.Level` - so we cannot see what the full message looks like.

You asked why the kicks and sprints values were 'getting confused'.

You are storing both in the same global context value called `count` - that is why they are the same.

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:53 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/35 "2019-07-29T21:53:48Z")

</div>

So if I change one of them will they be different?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [29 July 2019 21:55 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/36 "2019-07-29T21:55:51Z")

</div>

You are storing the two different values in the same context variable. So yes, you need to change something.

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 21:58 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/37 "2019-07-29T21:58:31Z")

</div>

Thanks! Do you know any way to introduce time (eg. implementing a delay after a kick has been detected?)

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [29 July 2019 22:04 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/38 "2019-07-29T22:04:17Z")

</div>

> [@rayy](#):
>
> Do you know any way to introduce time (eg. implementing a delay after a kick has been detected?)

Have you looked at the Delay node?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [29 July 2019 22:05 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/39 "2019-07-29T22:05:42Z")

</div>

Hi again, I'm sorry to say but it seems you have tried nothing and you're all out of ideas!

If you aren't careful, you will lose support from us unpaid folk.

Have you looked at the available nodes? There is one called delay. Give it a try, drop on onto the editor & read the built in info.

Also, search the [flows library](https://flows.nodered.org/?term=delay&type=flow&num_pages=1)

Give it a try.

IF and only IF you get stuck, 1st Search the forum THEN 2nd ask a question stating what you have tried and what went wrong.

Good luck.

---

<div class="post-metadata">

### Author: ![rayy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rayy](https://discourse.nodered.org/u/rayy)
#### Post date: [29 July 2019 22:05 UTC](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738/40 "2019-07-29T22:05:44Z")

</div>

checking it out rn thanks

[Previous page](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738.md?page=1)

[Next page](https://discourse.nodered.org/t/ibm-watson-sensor-support/13738.md?page=3)
