MySensors controller with Rasberry Pi 3 & Windows IoT



  • Hi everyone !

    For my studies, I choose to create a "home monitoring" project. My project need to request a many informations like temperature, .. via a gateway using mysensor API. My controller need to be on Windows IoT (C#) and I need to write all the informations in database. So, everything is good except one thing.

    After searching a looooong time i'm blocked !

    I want to create my own controler working on Rpi with IoT (C#) but I don't know how send message to my gateway in serial USB. I found nothing about how to send request.

    I want to know how send request from my controller to my gateway. I can use an external API to do that, but I don't know what ><

    Please, someone can help me?

    Thank you 🙂

    PS : Sorry if my english is too bad, I'm a french guy !


  • Mod

    @MrVince big welcome to the MySensors community!
    The serial api is used for communication with a gateway. The api is described here: https://www.mysensors.org/download/serial_api_20

    You can also look at HomeGenie, which is an open source controller written in C#.



  • @mfalkvidd Thanks for the welcome !

    I already look and studies the API. I understand a format and how build a Message but not how send it to my gateway.

    I've look this https://developer.microsoft.com/en-us/windows/iot/docs/wra on MSDN to connect an Arduino to a Raspberry, but there is something I can't understand. Do I need to create a string with a good format and send it to gateway? If yes, how, and if not, what I need to do.

    Maybe it's obvious and there is something I can't understand, I'm sorry if it's that

    EDIT : One more thing about the API, it's to the Arduino right?


  • Hardware Contributor

    Hi,

    I think you should start by taking a look at a Serial UART example for VS, for learning how com port session, communication are handled.
    A very good exercise, could be to start by trying to code a Serial monitor. Then it should be easier to understand.
    See above link from @mfalkvidd for the serial api and use it from your homemade Serial monitor, sending command, reading etc..
    Or as sugested too, you could take a look how Homegenie works (serial communication, threads, database etc.)



  • @scalz I will look thanks 🙂


  • Mod

    Keep in mind that mysensors gw also works over ethernet and mqtt



  • Hy everyone ! So, THIS IS WORKING ! Thanks a lot 🙂

    Now, new problemes ! (It's not funny without)

    I build a serial gateway and a motionsensor

    This is my log

    0_1496323093938_Screenshot_1.jpg image url)

    0;0;3;0;9 -> ok it's a gateway init
    0;0;3;0;14 -> gateway is ready

    but, what is the next one? Normally I will receive just x;x;x;x;x; right? what's about read: 255-255....

    Thank you 🙂


  • Mod



  • Ok, if I right, there is a trouble with a motionsensor who want an ID ?

    Do I need to give it one, or it's done by a gateway?


  • Hardware Contributor

    @MrVince - It is done by the controller. The GW never assign ID.
    You could set a static ID in the node as well.



  • @sundberg84 It's work ! Thank you 🙂



  • Hi everyone !

    Let's do a check up :

    • Read from a GW in serial connection : ok
    • Read information when I give a static ID : ok
    • Find a node who want an ID : ok
    • Give an ID to a node with my controller : nope

    So, the question is, if I receive '255;255;3;0;3;' my controller understand it's an ID_REQUEST and I need to use an ID_RESPONSE, but if I want to give an ID I need to build something like this :

    node-id ; child-sensor-id ; command ; ack ; type ; payload

    node-id : ??
    child-id : ??
    command : 3 for internal
    ack : 0 ?
    type : 4 for response
    payload : new ID (ex: 101)

    What are the node-id & child-id if the sensor doesn't have one?

    One more time, I want to thank's all of you, with your help it's more easier to understand and I start to see the end !

    EDIT : One more thing, I have an idea. I want to open a pop-up when a new sensor is on to choose for wich room is it.
    Can I give an temporary ID (like 254), wait for a first message with ID 254, with a first message I can see what type of sensor is, open a pop up, and give a new ID after I choose the room?


  • Mod

    the controller should keep track of the assigned IDs and respond with the following free one, I don't think you can change the ID via software, unless there is a way to change it in eeprom and reboot node so it will read it from eeprom and boot with that



  • @gohan ok

    I understand for the controller, but I think I miss something about the ID_RESPONSE

    Imagine this situation:

    I have just one sensor with no ID
    The GW send me (the controller) : '255;255;3;0;3;' // Sensor want a node_ID
    If I want to give it the ID 1, what I need to send to the gw? I think something like '255;255;3;0;4;1', that's right?

    EDIT : I try and it's work now, but I need to clear EEPROM first



  • Thank you for sharing the details.


Log in to reply
 

Suggested Topics

  • 1
  • 3
  • 5
  • 10
  • 2
  • 1

67
Online

11.4k
Users

11.1k
Topics

112.7k
Posts