PiGateway Moteino Setup

Started by vkMoteino, March 02, 2017, 07:40:35 PM

vkMoteino

I have a moteino that I want to use with a Raspberry Pi. It is connected to my programmer so that I can make sure that it works first before connecting to the Pi.  I uploaded the PiGateway sketch and on boot, the last message I see is,

"SPI Flash Init OK!"

Then it's dead. I have another moteino running the Gateway sketch and as nodes transmit, it responds by listing the messages. The PiGateway sketch also has this capability but it's not happening. I can get messages out of the PiGateway moteino but only if I comment out the line below.

inputLen = readSerialLine(input);

Somehow calling the readSerialLine function is causing problems. I believe this function is in the RFM69_OTA.cpp file. But why does it break things?

I guess I can change the code to what is used in Gateway.in0, Serial.available() and Serial.read() but this shouldn't be necessary.

If I add additional DEBUG() statements inside loop(), it looks like my statements print out once every 1000ms which is the default timeout in readSerialLine(). Doesn't this mean that radio messages will be missed if more then one is received within 1 sec?

Felix

Can you verify what transceiver are you using on the "dead" moteino?
Are all your settings matching between the nodes?

vkMoteino

I am using the same transceiver as the rest of the moteinos: RFM69HW. The settings are the same. This particular moteino works fine when loaded with the Gateway sketch but not fine with the PiGateway sketch. However if I comment out the readSerialLine() in the PiGateway sketch, it's back to normally receiving messages from nodes.

I added additional sprintfs and can confirm that it is going through the loop. It never has inputLen > 0 so that section is never entered. But what's confusing is that it also never enters the radio.receiveDone() section.

The readSerialLine() function blocks for 1000ms waiting for endOfLineChar. Is this normal? Should there be a test for data in the receive buffer before blocking?

Felix

It may depend on the IDE version, but I could be wrong here. Seems like lots of things vary and change between IDE versions, wouldn't be surprised if this did too.
The readSerialLine() is indeed blocking, that's because it has to wait a "reasonable" amount of time for a complete line to come in. But the last I recall about this is it wait for that amount of time for anything to come in at which point it waits some more until the serial is done and if nothing comes in in that timeout it ends.
So ........... not sure what to say, what IDE do you have?

vkMoteino

I'm using PlatformIO currently. I switched from Arduino 1.0.6. What is the recommended IDE?

Any benefit with using Atmel Studio?

Felix

Since most folks use the Arduino IDE I use IDE 1.0.6 for most things, and I try to stay compatible with the latest version. I use Atmel Studio for direct programming and burning fuses.

vkMoteino

It appears that I can run only one gateway at a time. Once I powered down the moteino running the Gateway sketch, the one running the unmodified PiGateway sketch started working as expected. To get them both to work posting messages from nodes at the same time requires me to comment out the readSerialLine() line. No idea why this matters.

Anyway, I'm glad I'm making progress and now have nodes popping up on the Pi hosted webpage. Exciting!

Felix

Quote from: vkMoteino on March 03, 2017, 08:23:10 PM
It appears that I can run only one gateway at a time. Once I powered down the moteino running the Gateway sketch, the one running the unmodified PiGateway sketch started working as expected.
Definitely, can't have 2 gateways on the same frequency and settings because they will react to received packets in similar ways (ACKs) and they trample on each other.
So you're using the LowPowerLab no-cloud Gateway solution huh?

vkMoteino

I wasn't sure if I had the Pi3 serial comms working correctly and was using the original gateway to debug the new one and created more problems then necessary. I did have to make changes on the Pi to get serial up on the normal GPIO pins as things have changed from Pi2 to Pi3.

I never cared for the cloud based IOT options and had bought parts, arduinos and sensors, to roll my own a few years back. In digging for low power libraries, I ran across your site and bought a few Moteinos because as expected, I could be up and running very quickly. I really appreciate all the work you've done in putting the pieces both hardware and software together, and for continuing development.

My motivation is remote monitoring when traveling away from home. One major piece I still need to figure out is how to integrate cellular failover when main cable network goes down as happened in the recent wind storm. I'm thinking an SMS interface to track status of key node would probably be simplest.

Felix

Yup on Pi3 the GPIO serial is no longer available by default, unfortunately, so manual changes are required to disable it from the bluetooth. You could always use a MoteinoUSB instead ...
RE IoT cloud stuff ... just look at @InternetOfShit :)
I will try to continue to develop and improve my Gateway software solution, it has come a long way and there's  lots more work to do. I published a TODO list here in this forum.
RE failover ... a GPRS solution might solve your problem, depending on what data plans you want to use. SMS could work but its too antiquated IMO to really get value out of it.