Author Topic: Communication between Pi and Moteino  (Read 2473 times)

ecliptic

  • NewMember
  • *
  • Posts: 22
  • Country: us
Communication between Pi and Moteino
« on: February 02, 2018, 11:32:54 PM »
I have a few general questions on programming the Moteino and Pi.  I'm pretty new to microcontroller programming, and I'm trying to understand just the basics of how communication works between a Moteino and Pi.

I currently have a Raspberry Pi 3 and a Moteino Mega with a trace antenna.  I'm using Microsoft IoT Core for the Pi 3 since I'm most familiar with the Microsoft stack.  I'm trying to use the Pi as a hub that receives data from 1 or more Moteinos.  My assumption is that the programming examples on this forum are enough to help me get two moteinos to communicate each other.

My question is how does the Raspberry Pi get the data off of the Moteino.  I've read using USB or a GPIO pin, but I guess I was looking for the "correct" approach.  I don't plan on adding a ton of Moteino's (maybe 4). 

So to sum it up, my questions are 1) How to send data from the Moteino to the Pi (send over USB)  2) How to poll/parse the data on the Pi to read that data.

Any guidance on how to get me started would be great!  I think the Win Core IoT stack should provide me the API's I need, I just need to know which interface to use :)  Thank you so much!

LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Re: Communication between Pi and Moteino
« Reply #1 on: February 03, 2018, 01:56:31 AM »
My question is how does the Raspberry Pi get the data off of the Moteino.
It uses serial com. port, on which and to which it reads/sends data. One moteino will have to serve as PI gateway (you have sketch for that). That one will translate RF data to serial and back if needed. Think of it as giving PI RF com. port, something like wifi

  I've read using USB or a GPIO pin, but I guess I was looking for the "correct" approach.  I don't plan on adding a ton of Moteino's (maybe 4). 

How to poll/parse the data on the Pi to read that data.
For that you need to look gateway app. It has to be specific form, that gateway can understand and interpret the data in it

On gateway it will look something like that
Code: [Select]
7:55:16 AM : {"_id":5,"updated":1517640913832,"rssi":30,"metrics":{"C":{"label":"C","value":0.25,"unit":"°","updated":1517640913832,"pin":1,"graph":1},"RSSI":{"label":"RSSI","value":-37,"unit":"db","updated":1517640913832,"graph":1,"pin":0}},"descr":"ds18b20","type":"WeatherMote","label":"Outdoor Sensor"}


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6867
  • Country: us
    • LowPowerLab
Re: Communication between Pi and Moteino
« Reply #2 on: February 03, 2018, 06:48:03 PM »
To add to what Luka said,
It depends on how you connect your Moteinos. The Moteinos with a 6 pin header, can communicate directly over serial GPIO (all Moteinos are currently 3.3v levels so no conflict with the 3.3v GPIO of the Pi).

You simply connect moteino-TX to Pi-RX (if you have 1 way communication) and vice versa (if you also want data from the Pi back).

Then you simply read data from the GPIO serial port (it is /dev/ttyAMA0 in linux, not sure in win but probably a COMxx port?). It is common to send a carriage return between messages from your Moteino, to know when to "stop" reading characters in 1 message, and continue reading another incoming message.
If you connect a Moteino through a FTDI-Adapter (or equivalent USB-serial converter) then you would connect to the USB and it would simply be another serial/COM port on your Pi, not the GPIO one. Also note that on Raspbian there are common issues enabling the GPIO serial port, read about it here.

Also the Gateway app I've developed is something to look into if you just want a secure mobile-friendly interface to control nodes and log data from them on your Pi. A moteino can serve as the "gateway" node to all your other nodes, a sample sketch for it is here.

Thanks for supporting Low Power Lab developments by purchasing genuine products from the webshop!

ecliptic

  • NewMember
  • *
  • Posts: 22
  • Country: us
Re: Communication between Pi and Moteino
« Reply #3 on: February 04, 2018, 11:50:43 AM »
Thanks for the help!  I've been looking at the gateway.js and sketch files based on your comments.  Felix, the product is great by the way.  Before discovering the Moteino, I was trying to piece together my own controller.  This device/site/community is outstanding!

Once I complete my project, I'll put it up on github.  Thanks for the help.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6867
  • Country: us
    • LowPowerLab
Re: Communication between Pi and Moteino
« Reply #4 on: February 05, 2018, 04:53:13 PM »
Thanks for the help!  I've been looking at the gateway.js and sketch files based on your comments.  Felix, the product is great by the way.  Before discovering the Moteino, I was trying to piece together my own controller.  This device/site/community is outstanding!
I'm happy you feel that way!  ;D