Send data to internet (REST API, other?)



  • Hi all,
    I was wondering if there is a way to send the values measured by wireless sensors to the internet service (ideally to RESTful API or another protocol, HTTP-based). The sensors are Arduino with NRF24L01. Could an Ethernet Gateway be used somehow to connect to the internet and send the data? Or is there any alternative solution?
    I basically want to be able to collect the data in the cloud and/or send command from the remote internet server over a secure channel. I do not want to use any third party controller (such as OpenHAB), but do the processing logic on my own in the cloud.
    Thank you for any thoughts!


  • Hardware Contributor

    Hi!

    I made a ethernet gateway send data to Nimbits (http://forum.mysensors.org/topic/363/datalogging-sensors-to-nimbits/3) a while ago.I changed the library to send the data with a json to nimbits. It wasnt stable thought and i gave it up and got myself a controller instead.

    I dont have any code left thought 😞



  • Thanks for your swift advice! Does it mean you hacked the GatewayUtil.h of the EthernetGateway code from GitHub to send the data to REST API?



  • I use something similar but it is on a serial gateway.

    I use a simple nodeJS program running where the serial gateway is connected.
    It reads from serial and sends to a REST api.
    If you're interested in this example I'll gladly share it.

    I've also seen folks using node-red to split the incoming messages and send it to more than one place, but i think it is serial gateway too.

    Cheers



  • Hi barduino,
    Thank you for your response! Yes, an example would be very much appreciated. Does it mean you have this simple serial gateway: http://www.mysensors.org/build/serial_gateway? and run the NodeJS program on the computer it is connected to? What do you use to read from serial gateway and send to REST API, RPi?



  • Hi @pelnarp

    Yes i do have the vanila serial gateway.

    I run the nodeJS on a windows computer or on a raspberry pi depending on my setup, anyway nodeJS is available for may operating system flavors and the code run on all of them.

    You just need to adjust the com port on this line

    var serialPort = new com.SerialPort('COM3', {
        baudrate: 115200,
    	parser: com.parsers.readline('\n')
      });
    

    Where it says COM3 (this is windows) in mac it will be similar to /dev/cu.usbmodem14141 and in raspberry pi or linux something like /dev/ttyACM0 representing the port where you have it connected.

    I use an authentication header to prevent tampering with the RESP API, I strongly reccomend you set up something similar if like me the REST API is on the cloud.

    And to receive the commands this nodeJS app also exposes a REST API which sends the commands back to serial gateway.

    Here are the files package.json gw.js, have fun!

    Anyway some food for though.

    I've seen folks here use a lot of MQTT, seems to be a very popular protocol for IOT and this type of stuff.

    The only reason I'm not using it is because I do not have a WL500 module for a ethernet gateway, I've tried with adafruit CC3000 with no success yet.

    Perhaps building a nodeJS app to translate the serial from MySensors to MQTT might be a good idea...

    Cheers



  • Many thanks for sharing, much appreciated!


Log in to reply
 

Suggested Topics

  • 1
  • 6
  • 3
  • 2
  • 1
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts