Help with a simple flow

Hi Everyone,

I’m really hoping you guys can help. I’m in my final year of a Geology Degree and for a summer project, I want to create a tool that can record temperatures and GPS when I push a button. I have all the hardware here and working. I can make node-red periodically record the data I need but not when I push a button. I hope this makes sense. On-demand data logger as such.

I have a button wired up to GPIO and its working (Reading 0 when presses 1 when up) but I can’t seem to marry the two processes to make it do what I need.

I have little to no experience with coding but I am trying to give it a go. I think I’ve wasted 4 weeks trying to get this to work on my own but I really need some help. I think it would be a really simple device for someone who knows to configure it.

This is my current Flow: https://imgur.com/zy8Nuw2

Any help you guys could give me would be greatly appreciated

That is only a screenshot of your flow, we need to see the flow itself to help.
Try exporting the flow to the clipboard and posting it here.
I notice that three of your nodes are not connected!

Most nodes can’t distinguish between different inputs, so your switch nodes aren’t going to magically join the input from your GPS/temp to the switch. So what you need to do is use the JOIN node to join the different bits together
There is a very similar flow being discussed in another thread DS18B20 Temperature Driving Wemo Switch

That covers 3 sensors, but effectively you have 4 Latitude,Longitude,Temp and Switch

So the JOIN node will only pass a message on when it gets all 4, take a look at this flow and see if it helps.

[{"id":"93c060e3.4759f","type":"inject","z":"92ad67d1.4157d","name":"GPS","topic":"","payload":"{\"lat\":59.9139, \"lon\":10.7522}","payloadType":"json","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":80,"wires":[["717d599.325ffa8","77f25a9.2daa324","ffd6aebc.a677c8"]]},{"id":"fb08c23c.0f1418","type":"change","z":"92ad67d1.4157d","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"T1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":80,"wires":[["f85b68e1.b6c85"]]},{"id":"f85b68e1.b6c85","type":"join","z":"92ad67d1.4157d","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":630,"y":120,"wires":[["38437991.d9fe5e"]]},{"id":"1c8ee520.d5cb83","type":"change","z":"92ad67d1.4157d","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"T4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":200,"wires":[["f85b68e1.b6c85"]]},{"id":"93d620f9.b838d","type":"change","z":"92ad67d1.4157d","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"T3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":160,"wires":[["f85b68e1.b6c85"]]},{"id":"38437991.d9fe5e","type":"change","z":"92ad67d1.4157d","name":"","rules":[{"t":"set","p":"payload.time","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":400,"wires":[["319b15da.4bb632"]]},{"id":"319b15da.4bb632","type":"csv","z":"92ad67d1.4157d","name":"DataOutput","sep":",","hdrin":true,"hdrout":false,"multi":"one","ret":"\\r\\n","temp":"time,T1,T2,T3","skip":0,"x":610,"y":340,"wires":[["7a307090.75ffc8"]],"inputLabels":["msg : string"],"outputLabels":["msg : number"]},{"id":"c2df98ed.e947","type":"inject","z":"92ad67d1.4157d","name":"SWITCH ON","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":280,"wires":[["4dfb699d.2c5678"]]},{"id":"9e3d6007.9f302","type":"inject","z":"92ad67d1.4157d","name":"Temp","topic":"","payload":"23","payloadType":"num","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":200,"wires":[["93d620f9.b838d"]]},{"id":"a3729e39.622758","type":"file","z":"92ad67d1.4157d","name":"log","filename":"/tmp/logs.csv","appendNewline":true,"createDir":true,"overwriteFile":"false","x":775.2712554931641,"y":280.1903648376465,"wires":[]},{"id":"7a307090.75ffc8","type":"debug","z":"92ad67d1.4157d","name":"CSV Debug","active":true,"console":"false","complete":"payload","x":769,"y":225,"wires":[]},{"id":"c00ec1e9.d26e68","type":"inject","z":"92ad67d1.4157d","name":"SWITCH OFF","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":320,"wires":[["4dfb699d.2c5678"]]},{"id":"717d599.325ffa8","type":"debug","z":"92ad67d1.4157d","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":270,"y":40,"wires":[]},{"id":"9f35e3ec.ba2928","type":"change","z":"92ad67d1.4157d","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"T2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":120,"wires":[["f85b68e1.b6c85"]]},{"id":"77f25a9.2daa324","type":"change","z":"92ad67d1.4157d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.lat","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":80,"wires":[["fb08c23c.0f1418"]]},{"id":"ffd6aebc.a677c8","type":"change","z":"92ad67d1.4157d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.lon","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":120,"wires":[["9f35e3ec.ba2928"]]},{"id":"4dfb699d.2c5678","type":"switch","z":"92ad67d1.4157d","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":280,"y":240,"wires":[["1c8ee520.d5cb83"]]}]

This sounds far more interesting that my summer project in my geology degree which I spent watching mud dry!

Nothing like documenting desiccation cracks haha. I’ll post my original remit below this post so you can see what i am trying to achieve. I’m sure what i want would be simple if I knew how to code or use node red correctly.

Hi Everyone,

I’m a 4rd Year Environmental Geology student and I have an independent project coming up soon. The project involves mapping a stream bed from hydrological water discharge points with the aim to show contaminated land pathways into water catchment areas. This will involve being in the stream/river and probing the sediment and recorded its temperature. This is because the water temperature is fairly linear at whatever time of the year it is. However, if there are cold spots in the bed this indicates a groundwater pathway into the stream.

I am looking to produce to best data I can but at the moment this involves probing and writing down the reading at the same time as well as wring my GPS location down. So as you can imagine this will take some time to do a small area.

What I was hoping to do is come up with a system that allows me to place a waterproof temperature prove on a rod that I can hand drive into the sediment and visually see the temperature. Following this, I would like to have some kind of data logger that is initiated with a push button followed by an audible beep. I don’t require the system to record data constantly or at time intervals but on demand.

I was hoping there might be a way of transmitting this information to my Garmin GPSMaps 64s but I have come to find out if it’s not a Garmin product it’s not going to do it and I haven’t the resources to upgrade what I have. That being said, I can export my data from the GPS as an excel doc and was hoping the proposed system above could do the same. Then I can just copy and past the data together before I run it through the mapping software. This way I press two (On the logger and GPS) buttons and record time-stamped data instead of fondling about in a river with 2 bits of kit and a clipboard.

Best case would integrate the on-demand Temperature Logger and GPS in the same unit that records all in an excel format with a press of a button. However, the GPS would have to have a high accuracy hence why my main concern is the temperature as I have a good GPS unit.

So my question is, can this be done? I’m working in water as well so I know there may be limited to my idea but I am confident I could waterproof some kind of box to it doesn’t get damaged.

I know nothing about Raspberry pi but I am very willing to give anything a go to get the data I need. With any luck, this might also lead on to a PhD opportunity so I best give it the best shot I can.

Any advice would be greatly appreciated

Simon

That flow you posted is basically what i have been trying to achieve. so how an i intergrate this with the gpsd node i have working and the two temperature probes. If i can get this to work and into a CSV i will be over the moon

You sir are a wonderful human being! After playing with it for an hour i have got it to do just want i needed it to do. I can thank you enough.

Now, not that you haven’t already done me a huge favor but do you have any experience in getting LCD displays to work? I’ve a i2c 16x2 but i will get another if it is needed. I would like to display the temperatures so i can take a reading once it has stabilized.

I’ve not used it - but this may be worth a look - https://github.com/johnty/node-red-contrib-i2clcd

Thanks for the reply. I had installed this once before but i couldn’t get it to work for me. In fact i had to uninstall and re-install node red after using it as it wouldn’t boot. Perhaps i was doing something wrong.

Yikes ! Maybe not then. We do have known working nodes for the many wires “44870” attached type versions but not so familiar with the i2c types.

I have a standard 20x4 also but i couldn’t get that to work in 4 bit mode. Having said that, i don’t think i full understand what the node required for it to display what i need.

Ok. That should work. As long as its wired up correctly then just sending it a string shpuld end up on the top line. They do need a resistor to set the contrast.

By any chance do you know of an example i could look at? I’m a real novice.

Thanks dceejay

Only the readme https://www.npmjs.com/package/node-red-node-pilcd