# I'm looking for help with my project

**URL:** <https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964>\
**Category:** General\
**Created:** [21 October 2019 15:09 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964 "2019-10-21T15:09:09Z")\
**Posts on this page:** 18\
**Page:** 3

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 November 2019 17:52 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/42 "2019-11-08T17:52:33Z")

</div>

> [@fralac](#):
>
> Yes,I now...I was wrong

So are your OK now?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 November 2019 19:15 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/43 "2019-11-08T19:15:30Z")

</div>

> [@fralac](#):
>
> The third one I don't know how to answer. The fourth I don't know how to answer

1. is what cronplus is sending what you need to send into the gpio node?

To know what the `gpio` node needs, you need to read the info tab of the node. Once you know that, you could attach a `debug` node to the output of the cronplus node to see what it is sending.

if they are the same then you are all set, ifthey are different you will need some logic to `change` the value coming from the cronplus node so you can send it to the `gpoi` node.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [9 November 2019 07:20 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/44 "2019-11-09T07:20:43Z")

</div>

Just try this flow, worked "out of the box"  
Turns on the LED when sun is down. Change coordinates to your location. Could it be simpler?

 ![IMG_1008](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c70a6be079bd9bc4a5af15233e3edbba850a95fa.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f0921c862263168e2b95f487c74f0b2e275eabc3.png)

```auto
Also add SunCalc to your settings.js

```

```
functionGlobalContext: {
    SunCalc:require('suncalc'),
    os:require('os')
    // octalbonescript:require('octalbonescript'),
    // jfive:require("johnny-five"),
    // j5board:require("johnny-five").Board({repl:false})
},

```

```auto

[{"id":"62deabc1.443024","type":"cronplus","z":"60f50465.20a53c","name":"","outputField":"payload","timeZone":"","options":[],"x":590,"y":2220,"wires":[["a4ba9e6e.0133b","176e84d.3522d7b"]]},{"id":"4091a3f2.f02f9c","type":"inject","z":"60f50465.20a53c","name":"status-all","topic":"","payload":"{\"command\":\"status-all\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":2250,"wires":[["62deabc1.443024"]]},{"id":"a4ba9e6e.0133b","type":"debug","z":"60f50465.20a53c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":760,"y":2220,"wires":[]},{"id":"176e84d.3522d7b","type":"rpi-gpio out","z":"60f50465.20a53c","name":"","pin":"36","set":false,"level":"1","freq":"","out":"out","x":820,"y":2300,"wires":[]},{"id":"d2c7fadc.0834b8","type":"inject","z":"60f50465.20a53c","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":820,"y":2380,"wires":[["176e84d.3522d7b"]]},{"id":"9cbb07e0.456018","type":"inject","z":"60f50465.20a53c","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":820,"y":2420,"wires":[["176e84d.3522d7b"]]},{"id":"d3f60b7e.c709b8","type":"function","z":"60f50465.20a53c","name":"SunRiseSet","func":"var SunCalc = global.get('SunCalc');\nvar loc = msg.payload.split(';');\nvar times = SunCalc.getTimes(new Date(), loc[0], loc[1]);\nvar sunriseStr = [times.sunrise.getHours().toString(), times.sunrise.getMinutes().toString()];\nvar sunsetStr = [times.sunset.getHours().toString(), times.sunset.getMinutes().toString()];\n\nfunction updateNodeStatus(txt) {\n node.status({\n \ttext : txt\n });\n}\n\nif (sunsetStr[0].length<2){\n sunsetStr[0]='0'+sunsetStr[0];\n}\nif (sunsetStr[1].length<2){\n sunsetStr[1]='0'+sunsetStr[1];\n}\nvar sunset = sunsetStr[0]+':'+sunsetStr[1];\n\nif (sunriseStr[0].length<2){\n sunriseStr[0]='0'+sunriseStr[0];\n}\nif (sunriseStr[1].length<2){\n sunriseStr[1]='0'+sunriseStr[1];\n}\nvar sunrise = sunriseStr[0]+':'+sunriseStr[1];\n\nlet info = 'sunUp:'+sunrise+' '+'sunDown:'+sunset;\nupdateNodeStatus(info);\n\nlet srh = times.sunrise.getHours();\nlet srm = times.sunrise.getMinutes();\nlet ssh = times.sunset.getHours();\nlet ssm = times.sunset.getMinutes();\n\nlet expr1 = '*/1 0-'+srh.toString()+' * 8-11 *';\nlet expr2 = '0-'+srm.toString()+'/1 '+(srh+1).toString()+' * * *';\nlet expr3 = '*/1 '+ssh.toString()+'-23'+' * * *';\nlet expr4 = ssm.toString()+'-59/1 '+(ssh-1).toString()+' * * *';\n\nlet expr5 = '*/1 '+(srh+2).toString()+'-'+(ssh-2).toString()+' * * *';\nlet expr6 = '';\nif(srm<59){\n expr6 = (srm+1).toString()+'-59/1 '+(srh+1).toString()+' * * *';\n}\nelse{\n expr6 = '0';\n}\nlet expr7 = '';\nif(ssm>0){\n expr7 = '0-'+(ssm-1).toString()+'/1 '+(ssh-1).toString()+' * * *';\n}\nelse{\n expr7 = '0';\n}\n\nmsg.payload = [\n {\n 'command': 'add',\n 'name': 'one',\n 'expression': expr1,\n 'payload': '1',\n 'type': 'num',\n },\n {\n 'command': 'add',\n 'name': 'two',\n 'expression': expr2,\n 'payload': '1',\n 'type': 'num',\n },\n {\n 'command': 'add',\n 'name': 'three',\n 'expression': expr3,\n 'payload': '1',\n 'type': 'num',\n },\n {\n 'command': 'add',\n 'name': 'four',\n 'expression': expr4,\n 'payload': '1',\n 'type': 'num',\n },\n {\n 'command': 'add',\n 'name': 'five',\n 'expression': expr5,\n 'payload': '0',\n 'type': 'num',\n },\n {\n 'command': 'add',\n 'name': 'six',\n 'expression': expr6,\n 'payload': '0',\n 'type': 'num',\n },\n {\n 'command': 'add',\n 'name': 'seven',\n 'expression': expr7,\n 'payload': '0',\n 'type': 'num',\n }\n]\n\nreturn msg;\n","outputs":"1","noerr":0,"x":600,"y":2420,"wires":[["b0b0c10c.ff517"]]},{"id":"b0b0c10c.ff517","type":"rbe","z":"60f50465.20a53c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":420,"y":2310,"wires":[["62deabc1.443024"]]},{"id":"d878b71b.d4a0d8","type":"inject","z":"60f50465.20a53c","name":"","topic":"","payload":"59.4200;18.0000","payloadType":"str","repeat":"60","crontab":"","once":true,"onceDelay":"","x":340,"y":2420,"wires":[["d3f60b7e.c709b8"]]},{"id":"23e95def.7c8072","type":"inject","z":"60f50465.20a53c","name":"remove-all","topic":"","payload":"{\"command\":\"remove-all\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":2200,"wires":[["62deabc1.443024"]]}]

```

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [9 November 2019 07:25 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/45 "2019-11-09T07:25:38Z")

</div>

> [@krambriw](#):
>
> Also add SunCalc to your settings.js

There is also a contrib node for that

> **[node-red-contrib-sunevents](https://www.npmjs.com/package/node-red-contrib-sunevents)**
>
> A node for node-red that generates events based on the position of the Sun at the appropriate time of day. Latest version: 3.1.1, last published: a year ago. Start using node-red-contrib-sunevents in your project by running \`npm i...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 November 2019 07:42 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/46 "2019-11-09T07:42:42Z")

</div>

Or node-red-node-suncalc

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [9 November 2019 09:05 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/47 "2019-11-09T09:05:07Z")

</div>

All roads lead to Rome...many ways to solve a task  
Thats the beauty!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2019 09:26 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/48 "2019-11-09T09:26:22Z")

</div>

The problem is that sometimes you find yourself on a diversion via Outer Mongolia.  
Though this is not a problem for any users from Outer Mongolia of course.

---

<div class="post-metadata">

**Author:** ![fralac](https://avatars.discourse-cdn.com/v4/letter/f/e9a140/32.png) [@fralac](https://discourse.nodered.org/u/fralac)\
**Post date:** [9 November 2019 09:33 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/49 "2019-11-09T09:33:36Z")

</div>

I don't understand your answer. I can only say that not everyone can do everything and the forum serves to ask for help...

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [9 November 2019 09:39 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/50 "2019-11-09T09:39:32Z")

</div>

> [@fralac](#):
>
> I don't understand your answer

Strange, if you have problems getting things working, as I have understood you have, the best is to get a ready made working project served right on your plate to start playing with. If that is not an excellent service, I do not know what it is. Anyway, I would be grateful if I would get that kind of support myself when needed. If you do not understand this, let me know, we might have some language problems

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2019 09:41 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/51 "2019-11-09T09:41:22Z")

</div>

> [@fralac](#):
>
> I don't understand your answer.

Which answer don't you understand?

---

<div class="post-metadata">

**Author:** ![fralac](https://avatars.discourse-cdn.com/v4/letter/f/e9a140/32.png) [@fralac](https://discourse.nodered.org/u/fralac)\
**Post date:** [9 November 2019 09:43 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/52 "2019-11-09T09:43:00Z")

</div>

Yes, I do. This is a project I want to end but I can't. If anyone could solve it I'd be grateful... so you understand, at work finished, what I did wrong and how it should be solved the problem.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [9 November 2019 09:45 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/53 "2019-11-09T09:45:42Z")

</div>

Are you real??? Try the project I provided to you. Learn from there

---

<div class="post-metadata">

**Author:** ![fralac](https://avatars.discourse-cdn.com/v4/letter/f/e9a140/32.png) [@fralac](https://discourse.nodered.org/u/fralac)\
**Post date:** [9 November 2019 09:45 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/54 "2019-11-09T09:45:47Z")

</div>

I find myself in this situation, where ninth I can connect my gpio to the flow. I'm trying all of them, but I just can't. I understand that for you it is simple, but not knowing the cron plus I can not change it.

 ![Cattura](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a692d5fe630ce113da647e8474c6f46d07397f25.png)

---

<div class="post-metadata">

**Author:** ![fralac](https://avatars.discourse-cdn.com/v4/letter/f/e9a140/32.png) [@fralac](https://discourse.nodered.org/u/fralac)\
**Post date:** [9 November 2019 09:47 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/55 "2019-11-09T09:47:56Z")

</div>

I took inspiration to change my flow

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [9 November 2019 09:48 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/56 "2019-11-09T09:48:41Z")

</div>

Check my code in the function node in the project I provided, this shows how you can change the data type sent from cron+  
It is also described in the info tab for the node itself  
As example:

```
{
    'command': 'add',
    'name': 'seven',
    'expression': expr7,
    'payload': '0',
    'type': 'num',
}

```

This will send the correct data type supported by the GPIO node

---

<div class="post-metadata">

**Author:** ![fralac](https://avatars.discourse-cdn.com/v4/letter/f/e9a140/32.png) [@fralac](https://discourse.nodered.org/u/fralac)\
**Post date:** [9 November 2019 09:50 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/57 "2019-11-09T09:50:45Z")

</div>

Should the code be placed inside the msg.payload or inject 1/0?

---

<div class="post-metadata">

**Author:** ![fralac](https://avatars.discourse-cdn.com/v4/letter/f/e9a140/32.png) [@fralac](https://discourse.nodered.org/u/fralac)\
**Post date:** [9 November 2019 09:53 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/58 "2019-11-09T09:53:37Z")

</div>

found the codes!

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [9 November 2019 09:54 UTC](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964/59 "2019-11-09T09:54:20Z")

</div>

Please study the complete solution I provided, try to understand how it works, study the code in the function node, try to understand how it works, then ask specific questions about it

[Previous page](https://discourse.nodered.org/t/im-looking-for-help-with-my-project/16964.md?page=2)
