Hello, Can you help me? LDR Sensor



  • Hi everyone,

    I'm new at this forum, i've been following the site for a while but only now I took the decision to actualy make a post.

    Well, let me introduce myself first. My name is Nathan, I'm a Mecatronic engeneering student in Brazil (yes, I know its cliche but... pardon my english sometimes)

    I'm gonna build this topic as a seek for help and a record for the development of my project.

    About the project

    I'm trying to build a Wireless Network Sensor using the boards and codes avalible at this site to monitor 2 LDR mote sensores.

    For the guys who don't know what a WNS stands for, is a network made out of one gateway and motes (sensores with batteries and microcontrollers wich can comunicate between themselfs).

    I need HELP
    Well, in my original project, i would build a gateway and 2 motes with LDR sensores.

    I need the motes to be able to comuniate with themselfs and then one of them to comunicate with the gateway.

    I've been trying to think how can I do this using the codes and librarys at this site but unfortunaly WIRELESS comunication is not my area.

    I know a buch about arduino and programing, but not enough to figure this all out by myself.

    so, here cames my question.

    I want to conect one gateway to my PC, to both recive and send data, I want to make 2 other boards with battery to comunicate between themselfs and with the gateway atached at the computer, and after all this work be able to see the data in my computer (serial monitor would be nice)

    ANY IDEA HOW SHULD I START THIS?

    I know my asking too much, but let me thank you guys in advance and tell you that I already have the arduino boards and the Radio boards and already build a gateway with buttons leds but no sensors!

    Ty


  • Admin

    @Nathan-Matos Welcome to MySensors - nice to have you on board. Your project sounds interesting and is a great match for MySensors. I would start by reading the getting started section and from there plan to build a serial gateway that connects to your PC and one LDR sensor first (no need to complicate it with two just yet). Given you know a bit about Arduino programming, this should be that hard. To keep things simple, you can ignore anything to do with Controllers because you PC will be effectively that through the Arduino IDE and plan to use static node addresses (for example, gateway is 0, node one is 1, node 2 is two).

    Once you have the gateway and a single LDR sensor working, I would add a second LDR sensor that also communicates with the gateway. Once you have one gateway and two independent sensors, you can modify your sensor node sketches so each node sends messages directly to the other by using creating a MyMessage to send and then calling setDestination() on it to set the peer node that you would like to send to.

    Good luck and look forward to hearing about your progress along the way.



  • Thank you very much,
    I already read the whole Getting Started Section, Very instructive.

    One of my many doubts was about the controller, I can already read de debug through the Debug and serial monitor (easy to understand) so I was wondering why I would need them.. Ty for the awnser!

    I kind of understood the Node IP adress thing. I mean, I saw a few videos on youtube using the MySensors but I'm not entirely familiar with the library.

    Perhaps you know the Mysensors.h set of instructions and maybe and example of the program

    Again, thank you very much and I promess you, once I finish, to donate a small amount, buy a few thing in the store and put my whole project into the forum!


  • Admin

    @Nathan-Matos said:

    Perhaps you know the Mysensors.h set of instructions and maybe and example of the program

    Did you see all the examples packaged with MySensors? A great place to start - https://github.com/mysensors/MySensors/tree/development/examples.

    For the serial gateway, the sketch couldn't be simpler - https://github.com/mysensors/MySensors/blob/development/examples/GatewaySerial/GatewaySerial.ino

    For the LDR sensor, you can probably adapt one of the existing example sensor sketches for your needs - for example, the existing light sensor example https://github.com/mysensors/MySensors/blob/development/examples/LightSensor/LightSensor.ino

    Oh, and don't forget the build section - here are all the details for building 1 of two different light level sensors - https://www.mysensors.org/build/light-bh1750

    Does this help?



  • Thank you, many times thank you!

    I was just looking for this!



  • @blacey
    OK Blacey, my savior , let me update the project.

    I was able to study and control pretty well the LDR mote, put a #Include MY_NODE on it, a child number also and im reading with the serial the value perfecty, it only sends the message once the value is changed and I'm loving it.

    As for the gateway in other hand, I have no clue how im going to set it to receive the data LDR mote is SENDING.

    I try to look a bit into the site but the only line of code I find about it was
    gw.getStatus(1,11,0)

    can you pls give me a light over here ? (got the joke... give me a light, Light dependent resistor LDR.. hum? it was a little fun c'mon)

    What command should I use at my gateway in order to recive messenges from other NODE /Children/Boards and etc...

    Edit

    https://www.mysensors.org/download/sensor_api_20

    That's what I was looking for, a set of basic instructions!


  • Admin

    @Nathan-Matos Yes, I got the joke and appreciate the humor 😉

    That said, if you are monitoring the node over serial, you will want to do the same thing with the gateway but be sure to enable MY_DEBUG so it logs the messages to the Arduino serial console.

    This line in lightLevel sketch is where the value is sent to the gateway. Assuming you have the node speaking to the gateway using either NRF or RFM radios, then you should see the messages appearing in the serial console. Normally a home automation controller plugin would connect to the gateway and use the Serial API but in this setup, you will be a human controller so you will need to interpret the Serial API yourself to verify the behavior.

    You will want to power up your gateway first and then power up your node(s) at which point you should see the node send the sketch version to the gateway followed by presenting its LDR child sensor to the gateway. You should see these interactions in the serial console of the gateway. Finally, whenever the light level changes and the node sends the new level to the gateway, you should see that too.

    Finally, are you using Windows or a Mac? If Windows and/or you are familiar with Wine, I recommend that you consider using @tekka's awesome MYSController that he developed for debugging MySensors networks. The way to think about it for your purposes, is that it will run on your PC and connect to your gateway over the serial connection and present the Serial API information to you in a much more human consumable form... You can find additional info in this forum post.

    So, to reiterate, once you have a single node talking to a single gateway connected to your PC, then you should introduce MYSController and at that point, start working on a second node and implementing the node-to-node communication.

    Thanks for the update and great progress so far!



  • Ty, it worked like a charm and now I'm understanding the protocol a little bit more.

    For now im satisfied with my results, but I will keep seeking for automation solutions like this and i feel like a found a realy good comunitty in here with helpfull ppl to suport and awnser my questions.

    Ty very much, I can't even tell you how much happy I'm for see this whole thing actualy working!


  • Admin

    @Nathan-Matos Clearly you are a quick study and have made great progress in a short time. Let us know if you need anything else.


Log in to reply
 

Suggested Topics

60
Online

11.4k
Users

11.1k
Topics

112.7k
Posts