Data upload to Mqtt

This my first project with Node Red and have had some progress with Tado heating data and serial inputs. I am now stuck trying to access some data from a SR04 level sensor (oil tank level).
This sensor is remote and battery powered and sits on a nano arduino along with a 433RF Superheterodyne transmitter.
I have a matching receiver on a RPI4, whch can see the data stream with RFSniffer.
I can't find a way of pointing this data stream at a MQTT server to enable access into Node Red. I am only looking for some pointers, like the steps involved. I am thinking that maybe I haven't made the best choice of hardware and an ESP32 would be better.

While an ESP device might be neater overall, it is probably more power-hungry. So you would want to take that into consideration.

However, what you have is similar to my very first setup with Node-RED some years ago. If you have the receiver on the Pi, you should be getting the data over serial so you need to connect Node-RED to the serial port. Obviously, that gets the data direct into Node-RED so you might not even need MQTT.

Still, MQTT can still be nice to have and now that you have the data in Node-RED, you can, of course, have one flow that sends the data to an MQTT topic (or however many you need) and a separate flow (disaggregation always being nice) listening and reacting to the MQTT topic. Disaggregating that way would let you more easily make significant changes to your configuration in the future with minimal code changes - for example moving either the input flow or the processing flow to a different device.

Thanks, that was the pointer I was looking for. I have now at least got data streaming in on the serial port (pin10), but it is garbage! I have tried all the baud rates but its more than that. If I use the receiver code example from the same github source as the send, then I do get integer numbers out for numbers in.
So there is light at the end of the tunnel but just some settings to sort out. Should I work on the the transmit format or the receive or or the settings in the Node Red serial node?

Maybe share the link to the repo so others can have a look.

Depends what info they give. As I said, I've used similar configuration in the past and it worked fine but I used my own code on the Arduino to do the serial send.

OK, did you stick to C or use python?
I was basing my project on this work:


MicroPython not really viable at that time, I had to teach myself the weird mix of C and C++ that was the Arduino code of the time. Not too hard to grasp the simple parts. I've done many computer languages over the years - before and during my programming years - but always avoided C/C++ like the plague!

Still don't like it but it is the quickest way to get good results.

Done a quick read of that code and there is really nothing in it. I wouldn't bother.

Instead write a really simple sketch for your Arduino with the 433MHz module that sends some simple text. There are plenty of examples out there. On the Pi side, connect Node-RED to the serial port that is created by the receiver. Make sure that the settings match at both ends.

That should get you some basic data through. Then you can add your sensor code to the Arduino sketch.

I have done something similar for transmitting temperatures. I set up the code in Arduino to transmit the data as JSon over MQTT on an ESP8266.

I have a 433MHz USB receiver plugged into a Pi and RTL-SDR with RTL_433 along with Mosquitto to do the heavy lifting. I then use an MQTT In node to get the JSon data into Node-red. This is fairly simple to set up and can be used for all manner of 433MHz devices.

I found the original Arduino code in a RandomNerdTutorial and adapted it for my requirements.

Thanks, I think I am nearly there. Using 'example' sketches for the Transmit and Receive and including a second Arduino on the receive end. I can output on serial to the Pi and Node Red does see the incoming serial datastream.
I don't know which setting I should be matching but the baud rate is OK as I do get some good data. There is still a lot of unreadable stuff - noise?? Like this
���������a������p�p�ȁ�[�p����@��0���B���8�0���������P��H��������0�S�������p����h����0������"0?@ ���Lh00�� ������2{� �"x��P��@�@�P�00$�0���0���}M����`�o8����� ��Decimal: 5393 (24Bit) Binary: 00000000000101010000001 Tri-State: 00000FFF0F0F PulseLenaTh: 353 microseconds Protocol: 1

The last part is what was transmitted.

Cracked it - powering the 2nd Arduino with battery rather than USB eliminates the 'noise'

Typical Pi problem. You need to make sure that your Pi has sufficient power. Low power issues can cause all sorts of issues. Depending which model Pi you have and what is connected to it, you need at least a 2A supply, more for a Pi4. Also, be careful with USB cables as these can have quite high resistance.

Yes I am using a Pi4 but I think the problem was that I was using the Router USB as the power supply for the Arduino.
BTW, I am sure there is a solution that doesn't involve a second arduino as the receiver, but I can't find any code that takes the data from the receiver (pin13) and sends it to a serial port for Node Red to read. SerialPutBytes from wiringPi doesn't work
What was your line of code for that?

Not sure, a long time ago. I seem to remember that my modules presented as a serial device on the Pi but I may be mistaken. Certainly I have a Ciseco Slice of Radio still blinking away on my Pi2 That presents as serial. Nothing connects to it any more though as I transitioned everything to ESP8266 long ago. Last thing that used it was a simple robot I built with my son.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.