-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when read analog sensor #4
Comments
Just in case that you may not be aware about this. The analogRead() is an Arduino layer API, and should be used in the Arduino thread. In other word, the analogRead() (or any other Arduino layer API) cannot be used with the LTask.remoteCall(). Please make sure that the analogRead() is not inside LTask.remoteCall(). |
Thanks for quick reply. |
Hi, For the analogRead function, it is correctly suggested by kakadumtk. It must be called outside the LTask.remoteCall(). Here I made a modification to the original sample code and it could run successfully: I read the value in loop() function and then pass it to nativeloop(). You could take a try either. Thanks. void loop() int subscribe_MQTT(int32_t (*callbackHandler)(MQTTCallbackParams), char * sTopic) { Serial.print("Subscribing..."); int publish_MQTT(char * topic, char * message) { // Message setup // Publish setup rc = aws_iot_mqtt_yield(1000); //please don't try to put it lower than 1000, otherwise it may going to timeout easily and no response // Publish if(NONE_ERROR != rc){ boolean nativeLoop(void* user_data) {
} |
Thanks for the quick reply. https://github.com/loovee/aws_mbedtls_mqtt/blob/master/shadow_analog/shadow_analog.ino Thanks. |
Hi, I have modified the code based on my working example, you may raplace the IP_ADDRESS for your own server, since current firmware still not support IP resolve function. /* This sketch connects to a website Change the macro WIFI_AP, WIFI_PASSWORD, WIFI_AUTH and SITE_URL accordingly. created 13 July 2010 */ #include <stdio.h> #include <signal.h> #define TEMP_EN 1 #if TEMP_EN float getTemp() /**
char cafileName[] = AWS_IOT_ROOT_CA_FILENAME; #define ROOMTEMPERATURE_UPPERLIMIT 32.0f static void simulateRoomTemperature(float *pRoomTemperature){
} QoSLevel qos = QOS_0; LWiFiClient c; typedef struct { ShadowReported reported; typedef struct { ShadowDesired desired; char shadowTxBuffer[256]; void ShadowUpdateStatusCallback(const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status, // if (pReceivedJsonDocument != NULL) { void windowActuate_Callback(const char pJsonString, uint32_t JsonStringDataLen, jsonStruct_t *pContext) { MQTTClient_t mqttClient; bool windowOpen = false; // invoked in main thread context
} boolean mqtt_start(void* ctx)
// while (NONE_ERROR == rc) {
// if (NONE_ERROR != rc) {
} boolean bearer_open(void* ctx){ VMINT wifiResolveCallback(vm_soc_dns_result *pDNS) boolean wifiResolveDomainName(void *userData) VMINT resolveState = vm_soc_get_host_by_name(VM_TCP_APN_WIFI, if (resolveState > 0) switch (resolveState)
case VM_E_SOC_WOULDBLOCK: // wait response from network, result could be gotten from callback. void setup() while(!Serial) // keep retrying until connected to AP LTask.remoteCall(&wifiResolveDomainName, (void*)HostAddress); // CONNECT_IP_ADDRESS = IP_ADDRESS; LTask.remoteCall(&bearer_open, NULL); void loop() int publish_Shadow(char * topic, char * message) { rc = aws_iot_shadow_yield(&mqttClient, 1000); //please don't try to put it lower than 1000, otherwise it may going to timeout easily and no response
return rc; char mqtt_message[2048];
} void updateTemp()
} |
hey guys, it's me again. I am testing the kit.
I found another issue, when I try to call analogRead(), the system will crash.
I try to read the real temperature from the the Grove - Temperature Sensor, which is a analog sensor.
ps: digitalWrite is ok.
The text was updated successfully, but these errors were encountered: