Navigation

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

    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
    • Array in send message command

      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,

      posted in Development
      yourry
      yourry
    • RE: void receive not work with RelayActuator.ino ?

      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.

      posted in Troubleshooting
      yourry
      yourry
    • void receive not work with RelayActuator.ino ?

      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

      posted in Troubleshooting
      yourry
      yourry