Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
Y

yourry

@yourry
About
Posts
4
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Array in send message command
    Y yourry

    Great, thanks for your reply and help.
    I was able to do what I wanted, I give you some code snippets to make several messages via a for loop,
    I'm not a code proffesional but this works:

    // Initialize messages
    MyMessage msgInA(0,V_CURRENT);
    MyMessage msgWhA(0,V_WATT);
    
    
    #define NSENSORS              6				//used current sensors
    
    void setup()
    {  
    	//initialize energy monitor CurrentSensor
    	for (int i=0; i<NSENSORS; i++)
    	{   
    		wh[i]        = { 0.0 };  //initialize wh
    		lwhtime[i]   = {0};	//initialize time
    		present(i, S_MULTIMETER);  
    	}  
    	for (int i=0; i<NSENSORS; i++)
    	{  
    		present(i, S_POWER);
    	}
    }
    
    
    	
    void loop()
    {
      	for (int i=0; i<NSENSORS; i++)
    	{
    		send(msgInA.setSensor(i).set(Irms[i], 1));
    		send(msgWhA.setSensor(i).set(wh[i], 1));    
    	}
    }
    

    Thanks

    Development

  • Array in send message command
    Y yourry

    Hi there,
    I am currently working on a node with openEnergy Monitor.
    I'm measuring a total of 6 SCT013 current transformer and wondering how in the mySensor code to include everything in a for loop.
    For example, to send the message, I hope to do:

    [...]
    
    MyMessage msgInA0(CHILD_ID_V_A0, V_WATT);
    MyMessage msgInA1(CHILD_ID_V_A1, V_WATT);
    MyMessage msgInA2(CHILD_ID_V_A2, V_WATT);
    MyMessage msgInA3(CHILD_ID_V_A3, V_WATT);
    MyMessage msgInA4(CHILD_ID_V_A4, V_WATT);
    MyMessage msgInA5(CHILD_ID_V_A5, V_WATT);
    #define NSENSORS   
               6
    [...]
    	
    //Read values and send to gateway
    for (int i=0; i<NSENSORS; i++)
    {
    	watt[i] = (emon[i].calcIrms(1480))*230*0.9;
    	send(msgInA[i].set(watt[i], 1)); //Error: not working
    }
    

    But it doesn't work.
    Do you have a trick to avoid writing the same code X times?
    Thank you,

    Development

  • void receive not work with RelayActuator.ino ?
    Y yourry

    Thanks for the answer, I keep the advice.
    Finally I looked for a while and the problem was with the MQTT publish syntax.
    It works perfectly, the difficulty is to find the right publish MQTT request.
    Thank you.

    Troubleshooting

  • void receive not work with RelayActuator.ino ?
    Y yourry

    Hi all,
    I don't understand a problem,
    My receive function is not working in the sktech relayActuator.ino
    If I simply add the following code :

    ....
    void receive(const MyMessage &message)
    {
       Serial.print("--- Incoming Message ---");
      // We only expect one type of message from controller. But we better check anyway.
      if (message.getType()==V_STATUS) {
    ....
    

    I never have anything.
    But in the node logs I do receive the information:
    Relay OFF :

    345110 TSF:MSG:READ,0-180-162,s=180,c=3,t=6,pt=0,l=1,sg=0:0
    

    Relay ON:

    355655 TSF:MSG:READ,0-180-162,s=180,c=3,t=6,pt=0,l=1,sg=0:1
    

    For information I use a gateway+W5100 in MQTT.

    An idea why the receive function is not working here ?

    Thank you all

    Troubleshooting
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular