Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. yourry
    3. Best
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Best posts made by yourry

    • RE: Array in send message command

      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

      posted in Development
      yourry
      yourry