Working M0 Sketch [solved]

Started by kwalkerk, September 26, 2018, 07:42:44 PM

kwalkerk

I cannot get any radio based sketch to work on my Moteino M0.  Blink works fine.  But no sketch that attempts to use the radio works.  I can get sketches working just fine on the Feather M0.

Any suggestions?

Felix

Was the M0 ordered with the radio pre-soldered? If so, that was already tested to ensure the M0+radio is functional.
What Board/Target are you using in the Arduino IDE? You should be using Moteino M0 as explained in the guide. That will ensure the RFM69 library picks the right pins for the radio CS/Interrupt.

kwalkerk

The radio was pre-soldered.  I am using the Moteino M0 target.  Below is the code I'm using for a simple test sketch.  I am using the current libraries from GitHub.

I have soldered on a 4 pin female header so that I could attach your BME280 breakout, but it is not attached when testing this script.

Attached is the output from the serial monitor.

#include <RFM69.h>    
#define NODEID        2   
#define NETWORKID     100  
#define GATEWAYID     1
#define FREQUENCY     RF69_915MHZ
#define IS_RFM69HW    
  
RFM69 radio;

#if defined (MOTEINO_M0)
  #if defined(SERIAL_PORT_USBVIRTUAL)
    #define Serial SERIAL_PORT_USBVIRTUAL 
  #endif
#endif


char buff[50];
byte sendLen;

void setup() {
  while(!Serial)
    Serial.begin(19200);

  if (!radio.initialize(FREQUENCY,NODEID,NETWORKID))
    Serial.println("radio.init() FAIL");
  else
    Serial.println("radio.init() SUCCESS");

  radio.setHighPower();

  sprintf(buff,"Word:word");
  sendLen=strlen(buff);

  Serial.println("setup completed");

}

#define USERETRY
void loop() {
  delay(1000);
  
#ifdef USERETRY
  if(radio.sendWithRetry(GATEWAYID,buff,sendLen,1)){
    Serial.println("send ok");
  } else {
    Serial.println("send failed");
  }
#else
  radio.send(GATEWAYID,buff,sendLen);
#endif

}

Felix

Can you please try the Gateway and Node sketches from the library examples, and let me know your results?
Those sketches are known to be working and are used to test the Moteinos before they are packed and shipped.

kwalkerk

Here is result from Node sketch. It will take me a little longer to do Gateway.  I'll have to take down my actual gateway....etc

kwalkerk

Here's the screen print from the M0 running Gateway sketch while regular Moteino is running node sketch.

kwalkerk

New Info

I set up my Moteino's to run on different machines.

I've attached the screenshot of the Gateway sketch when running under that config.

I modified the Node sketch to send the string "Word:word" in all cases.  Did this so I could test it on my PiGateway.

From the screen shot it appears that the M0(running the Node sketch) is indeed sending the data.  But also not acknowledging the ping from the Gateway.

However when I stop running the Gateway Moteino and try to send the info to the PiGateway, I get nothing.

Strange?

kwalkerk

UPDATE

I may need to be scolded  ;)

If I run the PiGateway sketch from the Moteino connected to my second computer, it receives the info from transmitted from the M0(connected to another computer).  However if the same Moteino is connected to the raspberry pi running the same PiGateway sketch, it never shows up as a node.

This has perhaps been the problem all along, since i used to use the Moteino connected to the pi as the PiGateway for testing by transmitting a string that would be picked up by the CatchAll under metrics.js.

But why would it not work on the actual PiGateway?


Felix

The Gateway/Node are just simple quick tester sketches meant to be a starting point to make a 2 node link. The Gateway sketch will receive anything and just display it on the serial port.

For the IoT Gateway project please use the PiGateway sketch. This has some extras that are required to make it work with the expected formats in gateway.js/metrics.js.

kwalkerk

I am using the PiGateway sketch.  It works when I run it while the Moteino is connected directly to my computer where I can watch the serial monitor.  I can see that the packets from the M0 are arriving.

However when I connect it to the Pi, I never see the node on the IoTGateway.  I know the IotGateway works because I have other nodes connecting to it and they show up fine.

Felix

Oh sorry for catching up too slowly :)
How are other nodes able to show up?
Do you have some other Moteino connected to it?
The gateway.js app only watches 1 serial port, by default the GPIO serial port (ttyAMA0).
If you attach a USB Moteino then it will be another port which you have to change in the settings and restart the gateway.

kwalkerk

I have a Moteino USB(mini connector version, not micro) which is running the PiGateway sketch.  It is connected to my Raspberry Pi via the USB connector.  The IoT Gateway is setup for /dev/ttyUSB0 and all other nodes report just fine in the IoT Gateway.

When I hooked the same Moteino up directly to the USB port on a computer I could see the packets arriving in the serial monitor.

I had modified the example Node sketch to send some text that would be picked up by the Catchall category in metrics.js.

In my zeal to discover what was going on I decided to re-setup my Raspberry Pi in case something had gone awry there.

Much to my chagrin I discovered that I forgot to uncomment the Catchall section of metrics.js.  Now that has been remedied and the IoT is showing the Moteino M0 node just fine.

Seems like I get dumber and dumber.

So sorry for all the time wasted as it certainly was my fault and not any of your hardware or software.

Felix

Quote from: kwalkerk on September 27, 2018, 03:45:21 PM
Seems like I get dumber and dumber.
So sorry for all the time wasted as it certainly was my fault and not any of your hardware or software.
No problem, we tinkerers all feel like that on some days!

I will mark this solved, I appreciate you coming back to report the results.

Thanks for using my products and software solution ;)