Test Pi gateway serial without Moteino? [solved]

Started by LukaQ, January 10, 2017, 04:34:55 AM

LukaQ

Hello,

I wanted to try gateway before I get anything else then PI3. What would be needed, to send, to serial of PI3 to get node in gateway to pop up and show data, make graph... even if data would be static all the time?

So in short:
PC > USB to serial > PI3 serial
to get node to show with some data (let say one would send water meter data)

what would that ASCII string look like on PI3 serial port?


Best regards, Luka

Felix

#1
Just send some sample data to the Pi's serial port (/dev/ttyAMA0 default, configurable in the settings page of the GUI), it doesn't have to come from a Moteino.
The acceptable metrics are defined as regular expressions in metrics.js.
A simple example is sending random temperature data: C:34.5 or F:75.8, these will automatically start logging.
An example complete data packet would be like (prepended by node ID):

[123] C:33.5 H:80 120W


Edit: forgot to mention each message has to end with a newline.

LukaQ

Hello,

I must be doing something wrong, since even what you posted doesn't create the node and for that reason node count stays at 0.
I did try different string before, for GAL and GPM which is also in metrics.js, but same result.

This is what I have already tried:
I turned of BT since it was using ttyAMA0
I could read and write out to ttyAMA0 (when write out, I was reading outgoing data with serial to usb on pc side)
I could write with python script and with other python script read, what was sent, all was ok.
This is "stock" image out of PiBakery, only setting WIFI and password
Login shell over serial is on, if not, there is no ttyAMA0
The last thing I didn't try now is, using converter on usb of PI3, but did before with OK data, but not seeing anything in gateway
I didn't use boost, with scope baud rate is only about 20 Hz off and don't think its any problem. Baud rate is 19200

In some of the above cases I didn't have TX of PI connected, since I think there is nothing to be sent out, am I right?

For the last try I had serial to usb on PI's usb, serial was send by arduino, I did see correct data with python script, but not with gateway (yes gateway was also changed to right inputs in all cases, this one was ttyUSB0)

What can I do/try?

Felix

Your problem is the Pi gpio serial.

1. disable ttyama0 console.
2. enable the uart.

From this link:

QuoteNOTE FOR RASPBERRY PI 3: The Raspberry pi 3 has changed things a bit and you might need to add the option enable_uart=1 at the end of /boot/config.txt (see this post by a Pi Engineer)

Otherwise you could just use a USB serial adapter like the FTDIAdapter or similar, then your serial port would be /dev/ttyUSB0 or something like that.

Use minicom to test your serial connection. If minicom can open it and see the data coming in, then the gateway app should also.
Good luck.

LukaQ

Hello,

I had uart=1, serial console=0,

both screen and minicom show data on /dev/ttyUSB0, like so:
[123] C:33.5 H:80 120W[123] C:33.5 H:80 120W[123] C:33.5 H:80 120W....

my adapter is with CP2102

What now?

Felix

I think you're missing newlines after each message.
Also have you configured the GUI to use /dev/ttyUSB0 instead of ttyAMA0 ?

LukaQ

#6
Hello,

I don't have newline, will change that
I do have GUI set to use /dev/ttyUSB0 (arduino is 5v logic as is)

AND it works, newline was missing and that made it not work

Is there live graph, something like moving as data comes in or as time passes?


Felix, you have something special here, I prefer this over OEM, very good job you did and with product you have!


Felix

Great,
I initially missed specifying that newline is required after each message.
Usually the receiving moteino does all that formatting including adding the sender ID and the RSSI and newline to each packet received.
The newline is how the gateway.js app separates between messages.

QuoteIs there live graph, something like moving as data comes in or as time passes?

Yes as long as the tokens received are matching a metric which is set as graph:1 it should start logging automatically, when you click that metric in the node details you will see the graph. If you leave the zoom level at the default latest zoom (ie you do not zoom to a different view which is not including the latest received point), then the graph should slide to the left as new data is coming in.

Thanks for the feedback, glad you find it useful.

ababak

Hi,

I am trying to test the Gateway without the nodes too. It looks like I have similar problems and reading this thread doesn't help.

Here's my setup:
MightyHat with Raspberry Pi 2. The Gateway is running.

I am connecting to serial port like this:
sudo minicom -b 19200 -o -D /dev/ttyAMA0

And I don't get any response here.

When I connect a Serial Monitor via FTDI I can see the feedback there. So when I paste a "KEY?" command to minicom window I can see the reply in the SerialMonitor on my Mac.

When I open a Gateway Log/Terminal I see this:
10:07:13 PM : SERVERTIME OFFSET: 274ms
10:07:13 PM : Connect

When I switch to "Send raw data" window and send "KEY?", the only place where I see the result is again my Serial Monitor.

So I tried sending data from Python like this:
>>> import serial
>>> sp = serial.Serial("/dev/ttyAMA0", 19200, timeout=1.5)
>>> sp.write("[99] F:70.15 H:30 [RSSI:-80]\n")
29

and tried to read back the response but again, no response anywhere except SerialMonitor.

I tried closing Serial Monitor and stopping Gateway but still haven't got any response from serial port on my Pi.

I checked the /boot/config.txt, checked the permissions on /dev/ttyAMA0, checked the gateway log and didn't find anything suspicious.

Could you suggest what am I doing wrong or how to debug this issue?

Thank you.

Regards,
Andrey

Felix

You cannot randomly connect several things to a serial port as if they are the real endpoints sending/receiving data.
Serial is between 2 (two) endpoints. While you might sniff the port with a FTDI or a logic analyzer, that's not meant as a means to replace one of the endpoints.

Also the data you are writing is invalid, the gateway software is expecting this type of format:

sp.write("F:70.15 H:30\n")


You say you send this from python, but you send that back to the Mighty Hat? Are you sure you understand the (two: sending and receiving) parts involved here?
It's the Hat that sends that data to your Pi via serial.

ababak

Yes, it looks that I was doing something wrong here :)

ababak

So what is the easiest way to emulate some events without another Moteino that sends some data over the air?

Felix

Just hook up another serial device over your Pi header.
Or make the Hat send some random made up data.
Sometimes it really pays to look around at sample sketches that I put out in the RFM69 library.
Here's a random data generator that will make nice graphs in the Gateway UI.


ababak

After a long break, I was able to get back to MightyHat. This time I've prepared a Moteino that sends a random temperature. MightyHat successfully receives the packets and shows this random temperature on the LCD. But there is nothing showing up on the gateway.
Sending data from gateway to Moteino node works just fine, Moteino shows the received text in its console.
I've double-checked the /boot/config.txt serial settings.
Then I tried to stop the gateway service and connect to /dev/ttyAMA0:
sudo minicom -b 19200 -o -D /dev/ttyAMA0

And I can't get any feedback from there while it should send the same string it shows on the LCD.
Can you help me to diagnose whether this is a software or a hardware problem?

Thank you.
Cheers,
Andrey

Felix

Hey Andrey!
Is your Gateway software a stable working install?
Remember to match the BAUD on the MightYHat to that in the Gateway settings page.

After that check, look in the gateway.sys.log file to see incoming serial data.
After that check, make sure your metrics match one of the definitions in metrics.js. The random sending temperature example in the RFM69 library will work without needing any changes in metrics.