mycontroller-org / MyControllerDevice

MyController supported MQTT ESP8266 library
http://www.mycontroller.org
Apache License 2.0
4 stars 4 forks source link

Request or Need some sample , please. #7

Closed Stephan35 closed 6 years ago

Stephan35 commented 7 years ago

Hello, Now my esp can talk with MyController, could you post or help for sending data from esp to MyController with this lib.

First i tried to set luxmeter with this :

#include <MyController.h>
MyController mc;

  present(S_LIGHT, SENSOR_LUXMETRE, SENSOR_LUXMETRE);
  request(SENSOR_LUXMETRE, V_STATUS); \\V_LIGHT ?

I don't know how to send value to MyController


void loop() {
long now = millis();
  mc.loop();
  //You can add your logic here.
  if (now - lastRecu > 100 ) {
    lastRecu = now;
    send(SENSOR_LUXMETRE, analogRead(A0)); \\ which method ?
  }
}

In the same way , i would like to send state fo some binary input ...

Thanks

Stephan35 commented 7 years ago

Here is a sample to send a value ... i miss something

Here is error from log :

void sendLUX(){
  McMessage _message;
  _message.update(BC_SENSOR, C_INTERNAL, SENSOR_LUXMETRE);
  char _luxmeter[21];
  snprintf_P(_luxmeter, 20, "%d Lux", analogRead(A0));
  send(_message.set(_luxmeter));
}
2017-02-22 23:59:15,841 ERROR [Thread-6] [org.mycontroller.standalone.message.MessageMonitorThread:119] Throws exception while processing!, [RawMessage(gatewayId=1, data=65535 Lux, subData=out_esp/ESP_8C0125/SENSOR_BC/C_INTERNAL/LUXMETRE/0, isTxMessage=false, networkType=MY_CONTROLLER, timestamp=1487804355771)]
java.lang.IllegalArgumentException: No enum constant org.mycontroller.standalone.message.McMessageUtils.MESSAGE_TYPE_INTERNAL.LUXMETRE

Maybe i get it false with out_esp/ESP_8C0125/SENSOR_BC/C_INTERNAL/LUXMETRE/0

Will have a look in mqtt datagram to see what is waiting for ... in progress .

jkandasa commented 7 years ago

@Stephan35 I have added an example. https://github.com/mycontroller-org/MyControllerDevice/blob/master/examples/RelayActuatorAndTemperature/RelayActuatorAndTemperature.ino

Stephan35 commented 7 years ago

@jkandasa Thanks for this example. Is it possible to have an explanation for kind of device and wich kind of data is required , example:

#define S_LIGHT                       "S_LIGHT"  // For ?
#define V_LIGHT                       "V_LIGHT" // For ?

What is difference between S_LIGHT and V_LIGHT , how can i know this .

S for string return ? V for value return ? I_ for ?

is it possible tu put a comment in front of each one in McMessage.h

Thanks. Best regards

jkandasa commented 7 years ago

@Stephan35 updated!

njbuch commented 7 years ago

Can i please see the complete example for the light sensor? That would be very helpful :)

jkandasa commented 6 years ago

@njbuch do you want to see LDR example?

njbuch commented 6 years ago

No, I have it working now. Thanks anyway!