mycontroller-org / MyControllerDevice

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

analogRead(A0) return 65535 #8

Closed Stephan35 closed 7 years ago

Stephan35 commented 7 years ago

Hello, Here is a new strange thing. as describe , i can't get the value of analogRead(A0)

void sendLUX(){
  McMessage _message;
  //_message.update(SENSOR_LUXMETRE, C_SET, "V_LIGHT_LEVEL");
  //char _luxmeter[21];
 // snprintf_P(_luxmeter, 20, "%s", analogRead(A0) );
  Serial.print("Envoie de Luxmeter:");
  Serial.println(analogRead(A0));
  //snprintf_P(_luxmeter, 20, "%d", String(analogRead(A0)));
  ////send(_message.set(_luxmeter));
  _message.update(SENSOR_LUXMETRE, C_SET, V_LEVEL);
  //snprintf_P(_luxmeter, 20, "%d", analogRead(A0));
  send(_message.set(analogRead(A0)));
}
MC[I]: Booting ESP8266 device...
MC[I]: WIFI not connected, trying connection...
MC[I]: Connecting to WiFi with ssid[PLANETE_TERRE] and with password.......................OK
MC[I]: WiFi BSSID:[4A:59:CC:FA:28:74], RSSI:[-78 dBm, 44 %], IP:[192.168.0.16], StatusCode:[3]
MC[I]: Configuration(NodeEUI:[ESP_8C0125], Mqtt{mDNS-status:[0], Server:[192.168.0.25], Port:[1883], FeedId:[esp], User:[]})
MC[I]: MQTT settings(Broker:[192.168.0.25], Port:[1883])
MC[I]: MQTT authenticating as anonymous
MC[I]: MQTT connected :)
MC[I]: MQTT topic subscribed:[in_esp/ESP_8C0125/#]
MC[I]: Initialization done...
Envoie de Luxmeter:65535
-78 dBmEnvoie de Luxmeter:65535

Best regards

jkandasa commented 7 years ago

@Stephan35 We can use A0(ADC) of ESP8266 to read internal VCC or as ADC. By default, MyControllerDevice uses ADC to read VCC. You have to disable this on the file McConfig.h when you want to use ADC externally.

Disable this line,

#define ENABLE_READ_VCC
Stephan35 commented 7 years ago

Works fine . Could you add this comment for futher user who ask same (like me ;-) ) Best regards.