Unable to publish to losant

#1

Hello,
I’m working on Mongoose os with dallas temperature sensor DS18B20 and esp8266 nodemcu. I’m using js code and i’m able to get the sensor values to the device log of Mongoose. When i’m trying to publish the values to losant using Losant MQTT broker, I’m not able to do the same. Though I’ve given my device id as Losant device id and saved the configuration, it still says Published no topic to /esp8266_49C75D, this device id.

The device log is like this:

[Mar 17 12:23:08.121] bcn 0
[Mar 17 12:23:08.121] del if1
[Mar 17 12:23:08.123] usl
[Mar 17 12:23:08.123] add if1
[Mar 17 12:23:08.124] dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
[Mar 17 12:23:08.130] bcn 100
[Mar 17 12:23:08.130] mgos_wifi_dev_ap_set WiFi AP IP: 192.168.4.1/255.255.255.0 gw 192.168.4.1, DHCP range 192.168.4.2 - 192.168.4.100
[Mar 17 12:23:08.142] mgos_http_server_ini HTTP server started on [80]
[Mar 17 12:23:08.150] mg_rpc_channel_mqtt  0x3fff1934 esp8266_49C75D/rpc/#
[Mar 17 12:23:08.158] mg_rpc_channel_uart  0x3fff1cc4 UART0
[Mar 17 12:23:08.162] mgos_init            Init done, RAM: 52096 total, 41652 free, 41056 min free
[Mar 17 12:23:09.406] mongoose_poll        New heap free LWM: 15672
[Mar 17 12:23:11.403] Sensors found: 1 
[Mar 17 12:23:11.614] Sensor# 0 address: 28ffe006a317046a 
[Mar 17 12:23:12.286] Sensor# 0 Temperature: 28.130000 *C 
[Mar 17 12:23:12.377] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.130000}} 
[Mar 17 12:23:14.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:14.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:16.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:16.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:18.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:18.154] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:20.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:20.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:22.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:22.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:24.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:24.154] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:26.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:26.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:28.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:28.154] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:30.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:30.154] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:32.064] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:32.154] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:34.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:34.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:36.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:36.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:38.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:38.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:40.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:40.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:42.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:42.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:44.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:44.153] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 
[Mar 17 12:23:46.063] Sensor# 0 Temperature: 28.190000 *C 
[Mar 17 12:23:46.159] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.190000}} 

When i try to resave the configuration and flash it, the device log looks like this,

[Mar 17 12:26:42.512] save_cfg             Saved to conf9.json
[Mar 17 12:26:42.628] mgos_vfs_umount_all  Unmounting filesystems
[Mar 17 12:26:42.634] mgos_vfs_dev_close   0x3fff05c4 refs 0
[Mar 17 12:26:42.638] mgos_system_restart  Restarting
[Mar 17 12:26:42.641] bcn 0
[Mar 17 12:26:42.642] del if1
[Mar 17 12:26:42.643] usl
[Mar 17 12:26:42.743] 

[Mar 17 12:26:42.744]  ets Jan  8 2013,rst cause:2, boot mode:(3,7)

[Mar 17 12:26:42.748] 
[Mar 17 12:26:42.765] load 0x40100000, len 1796, room 16 
[Mar 17 12:26:42.769] tail 4
[Mar 17 12:26:42.770] chksum 0x63
[Mar 17 12:26:42.770] load 0x3ffe8000, len 824, room 4 
[Mar 17 12:26:42.773] tail 4
[Mar 17 12:26:42.775] chksum 0x0c
[Mar 17 12:26:42.775] csum 0x0c   Q Z jUJ B  TTTTj-kVVU   U (TT U    U     TT U+UZ I UEJ KP  JZ E   T   P Z  -  P   QT   Z V UP  RQQU T      N  {  N|  l lld`  c      | r  l n   N   l    { l l mode : sta(60:01:94:49:c7:5d) + softAP(62:01:94:49:c7:5
[Mar 17 12:26:42.890] esp_mgos_init2       example-arduino-dallas-temperature-js-1.18 1.0 (20180314-185435/???)
[Mar 17 12:26:42.896] esp_mgos_init2       Mongoose OS 2018031418 (20180314-185435/???)
[Mar 17 12:26:42.902] esp_mgos_init2       SDK 2.1.0(ce90efd); flash: 4M; RAM: 52096 total, 47700 free
[Mar 17 12:26:42.910] esp_print_reset_info Reset cause: 4 (soft reset)
[Mar 17 12:26:42.916] mgos_vfs_dev_open    sysflash () -> 0x3fff05c4
[Mar 17 12:26:42.920] mgos_vfs_mount       Mount SPIFFS @ / (dev 0x3fff05c4, opts {"addr": 32768, "size": 262144}) -> 0x3fff05d4
[Mar 17 12:26:42.988] mgos_vfs_mount       /: size 233681, used: 130269, free: 103412
[Mar 17 12:26:43.081] mgos_sys_config_init MAC: 62019449C75D
[Mar 17 12:26:43.085] mgos_sys_config_init WDT: 30 seconds
[Mar 17 12:26:43.089] mgos_mdns_init       Listening on udp://:5353
[Mar 17 12:26:43.094] mgos_mdns_hal_join_g Joining multicast group 224.0.0.251
[Mar 17 12:26:43.101] mgos_i2c_create      I2C GPIO init ok (SDA: 12, SCL: 14)
[Mar 17 12:26:43.107] mgos_aws_init        AWS Greengrass enable (0)
[Mar 17 12:26:43.111] bcn 0
[Mar 17 12:26:43.112] del if1
[Mar 17 12:26:43.114] scandone
[Mar 17 12:26:43.114] del if0
[Mar 17 12:26:43.114] usl
[Mar 17 12:26:43.114] mode : null
[Mar 17 12:26:43.116] mgos_wifi_set_config WiFi mode: STA
[Mar 17 12:26:43.120] mgos_wifi_set_mode   WiFi mode: STA
[Mar 17 12:26:43.123] mode : sta(60:01:94:49:c7:5d)
[Mar 17 12:26:43.125] add if0
[Mar 17 12:26:43.127] WPA2 ENTERPRISE VERSION: [v2.0] disable
[Mar 17 12:26:43.129] mgos_wifi_setup_sta  WiFi STA: Connecting to JioFi4_1076A8
[Mar 17 12:26:43.137] mgos_http_server_ini HTTP server started on [80]
[Mar 17 12:26:43.146] mg_rpc_channel_mqtt  0x3fff1504 5aa9876c5f623600074b3fbd/rpc/#
[Mar 17 12:26:43.154] mg_rpc_channel_uart  0x3fff18ac UART0
[Mar 17 12:26:43.158] mgos_init            Init done, RAM: 52096 total, 42712 free, 41056 min free
[Mar 17 12:26:44.248] mongoose_poll        New heap free LWM: 17152
[Mar 17 12:26:44.256] mgos_net_on_change_c WiFi STA: connecting
[Mar 17 12:26:46.246] Sensors found: 1 
[Mar 17 12:26:46.457] Sensor# 0 address: 28ffe006a317046a 
[Mar 17 12:26:47.130] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:26:47.221] Published: no topic: /losant/5aa9876c5f623600074b3fbd/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:26:47.386] scandone
[Mar 17 12:26:48.270] state: 0 -> 2 (b0)
[Mar 17 12:26:48.938] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:26:49.017] Published: no topic: /losant/5aa9876c5f623600074b3fbd/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:26:49.270] state: 2 -> 0 (2)
[Mar 17 12:26:49.272] reconnect
[Mar 17 12:26:49.274] scandone
[Mar 17 12:26:49.278] mgos_net_on_change_c WiFi STA: disconnected
[Mar 17 12:26:49.284] mgos_net_on_change_c WiFi STA: connecting
[Mar 17 12:26:50.902] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:26:50.981] Published: no topic: /losant/5aa9876c5f623600074b3fbd/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:26:52.092] scandone
[Mar 17 12:26:52.094] state: 0 -> 2 (b0)
[Mar 17 12:26:52.096] state: 2 -> 3 (0)
[Mar 17 12:26:52.102] state: 3 -> 5 (10)
[Mar 17 12:26:52.104] add 0
[Mar 17 12:26:52.104] aid 2
[Mar 17 12:26:52.104] cnt 
[Mar 17 12:26:52.118] 
[Mar 17 12:26:52.118] connected with JioFi4_1076A8, channel 11
[Mar 17 12:26:52.122] dhcp client start...
[Mar 17 12:26:52.124] mgos_net_on_change_c WiFi STA: connected
[Mar 17 12:26:52.903] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:26:52.980] Published: no topic: /losant/5aa9876c5f623600074b3fbd/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:26:54.902] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:26:54.981] Published: no topic: /losant/5aa9876c5f623600074b3fbd/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:26:54.996] ip:192.168.225.45,mask:255.255.255.0,gw:192.168.225.1
[Mar 17 12:26:55.000] mgos_net_on_change_c WiFi STA: ready, IP 192.168.225.45, GW 192.168.225.1, DNS 192.168.225.1
[Mar 17 12:26:55.010] mgos_mqtt_global_con MQTT connecting to broker.losant.com:1883
[Mar 17 12:26:56.045] mgos_sntp_query      SNTP query to pool.ntp.org
[Mar 17 12:26:56.190] mgos_sntp_ev         SNTP reply from 123.108.200.124: time 1521269815.292536, local 13.435059, delta 1521269801.857477
[Mar 17 12:26:56.916] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:26:56.995] Published: no topic: /losant/5aa9876c5f623600074b3fbd/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:03.298] bcn 0
[Mar 17 12:27:03.298] del if1
[Mar 17 12:27:03.300] usl
[Mar 17 12:27:03.300] add if1
[Mar 17 12:27:03.301] dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
[Mar 17 12:27:03.307] bcn 100
[Mar 17 12:27:03.307] mgos_wifi_dev_ap_set WiFi AP IP: 192.168.4.1/255.255.255.0 gw 192.168.4.1, DHCP range 192.168.4.2 - 192.168.4.100
[Mar 17 12:27:03.319] mgos_http_server_ini HTTP server started on [80]
[Mar 17 12:27:03.327] mg_rpc_channel_mqtt  0x3fff1934 esp8266_49C75D/rpc/#
[Mar 17 12:27:03.335] mg_rpc_channel_uart  0x3fff1cc4 UART0
[Mar 17 12:27:03.339] mgos_init            Init done, RAM: 52096 total, 41652 free, 41056 min free
[Mar 17 12:27:04.585] mongoose_poll        New heap free LWM: 15672
[Mar 17 12:27:06.579] Sensors found: 1 
[Mar 17 12:27:06.790] Sensor# 0 address: 28ffe006a317046a 
[Mar 17 12:27:07.463] Sensor# 0 Temperature: 28.250000 *C 
[Mar 17 12:27:07.553] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.250000}} 
[Mar 17 12:27:09.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:09.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:11.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:11.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:13.241] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:13.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:15.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:15.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:17.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:17.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:19.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:19.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:21.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:21.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:23.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:23.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:25.241] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:25.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:27.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:27.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:29.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:29.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:31.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:31.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:33.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:33.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:35.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:35.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:37.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:37.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:39.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:39.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:41.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:41.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:43.242] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:43.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:45.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:45.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:47.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:47.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:49.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:49.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:51.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:51.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:53.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:53.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:55.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:55.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:57.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:57.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:27:59.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:27:59.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:01.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:01.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:03.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:03.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:05.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:05.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:07.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:07.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:09.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:09.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:11.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:11.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:13.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:13.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:15.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:15.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:17.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:17.329] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:19.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:19.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:21.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:21.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:23.248] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:23.331] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:25.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:25.329] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:27.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:27.332] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:29.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:29.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:31.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:31.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:33.240] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:33.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:35.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:35.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:37.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:37.329] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 
[Mar 17 12:28:39.239] Sensor# 0 Temperature: 28.310000 *C 
[Mar 17 12:28:39.330] Published: no topic: /losant/esp8266_49C75D/state message: {"data":{"temperature":28.310000}} 

If observed, when i re-save the configuration initially the device id changes to losant device id but again it changes back to /esp8266_49C75D.
Can you please help me with this isssue?

#2

It looks like your device starts by correctly making state reports to /losant/5aa9876c5f623600074b3fbd/state, which is correct.

Then, on reconnect, your device ID is changing to esp8266_49C75D, which makes your state reports go to /losant/esp8266_49C75D/state instead, which as you know does not work.

Can you post a sample of the code you have running on the device? There’s not much we can do to diagnose the issue without that. Make sure not to include any sensitive information such as your access key and secret within the code sample.

#3

This is the javascript code that I’m using in Mongoose:

/*
 * Copyright (c) 2014-2017 Cesanta Software Limited
 * All rights reserved
 *
 * This example demonstrates how to use mJS Arduino DallasTemperature
 * library API to get data from DSxx temperature sensors.
 */

// Load Mongoose OS API
load('api_config.js');
load('api_timer.js');
load('api_arduino_onewire.js');
load('api_arduino_dallas_temp.js');
load('api_mqtt.js');

// GPIO pin which has sensors data wire connected
//let pin = 21;
let pin = 13;
// Initialize 1-Wire bus
let ow = OneWire.create(pin);
// Initialize DallasTemperature library
let dt = DallasTemperature.create(ow);
// Start up the library
dt.begin();
// Number of sensors found on the 1-Wire bus
let n = 0;
// Sensors addresses
let sens = [];

// This function reads data from the DS sensors every 2 seconds
Timer.set(2000 /* milliseconds */, true /* repeat */, function() {
  if (n === 0) {
    n = dt.getDeviceCount();
    print('Sensors found:', n);

    for (let i = 0; i < n; i++) {
      sens[i] = '01234567';
      if (dt.getAddress(sens[i], i) === 1) {
        print('Sensor#', i, 'address:', dt.toHexStr(sens[i]));
      }
    }
  }

  dt.requestTemperatures();
  for (let i = 0; i < n; i++) {
    print('Sensor#', i, 'Temperature:', dt.getTempC(sens[i]), '*C');
    let temp = dt.getTempC(sens[i]);
    let topic = '/losant/' + Cfg.get('device.id') + '/state';
    let message = JSON.stringify({
      data: {
        temperature: temp
      }
    });
    let ok = MQTT.pub(topic, message, 1);
    print('Published:', ok? 'yes' : 'no', 'topic:', topic, 'message:', message);
  }
}, null);

And in the configuration window,this is the code:

{
  "sntp": {
    "enable": true,
    "server": "pool.ntp.org",
    "retry_min": 1,
    "retry_max": 30,
    "update_interval": 7200
  },
  "update": {
    "timeout": 300,
    "commit_timeout": 0,
    "url": "",
    "interval": 0,
    "ssl_ca_file": "ca.pem",
    "ssl_client_cert_file": "",
    "ssl_server_name": "",
    "enable_post": true
  },
  "device": {
    "id": "5aa9876c5f623600074b3fbd",
    "password": ""
  },
  "debug": {
    "udp_log_addr": "",
    "mbedtls_level": 0,
    "level": 2,
    "filter": "",
    "stdout_uart": 0,
    "stderr_uart": 0,
    "factory_reset_gpio": -1,
    "mg_mgr_hexdump_file": "",
    "stdout_topic": "",
    "stderr_topic": ""
  },
  "sys": {
    "mount": {
      "path": "",
      "dev_type": "",
      "dev_opts": "",
      "fs_type": "",
      "fs_opts": ""
    },
    "wdt_timeout": 30,
    "atca": {
      "enable": false,
      "i2c_addr": 96,
      "ecdh_slots_mask": 12
    }
  },
  "conf_acl": "*",
  "i2c": {
    "enable": true,
    "freq": 100000,
    "debug": false,
    "sda_gpio": 12,
    "scl_gpio": 14
  },
  "mqtt": {
    "enable": true,
    "server": "broker.losant.com:1883",
    "client_id": "5aa9876c5f623600074b3fbd",
    "user": "Losant access key",
    "pass": "Losant access secret",
    "reconnect_timeout_min": 2,
    "reconnect_timeout_max": 60,
    "ssl_cert": "",
    "ssl_key": "",
    "ssl_ca_cert": "ca.pem",
    "ssl_cipher_suites": "",
    "ssl_psk_identity": "",
    "ssl_psk_key": "",
    "clean_session": true,
    "keep_alive": 60,
    "will_topic": "",
    "will_message": ""
  },
  "aws": {
    "thing_name": "",
    "greengrass": {
      "enable": false,
      "reconnect_timeout_min": 2,
      "reconnect_timeout_max": 60
    }
  },
  "wifi": {
    "sta": {
      "enable": true,
      "ssid": "JioFi4_1076A8",
      "pass": "d2pjvtpbv9",
      "user": "",
      "anon_identity": "",
      "cert": "",
      "key": "",
      "ca_cert": "",
      "ip": "",
      "netmask": "",
      "gw": "",
      "nameserver": "",
      "dhcp_hostname": ""
    },
    "ap": {
      "enable": false,
      "ssid": "Mongoose_??????",
      "pass": "Mongoose",
      "hidden": false,
      "channel": 6,
      "max_connections": 10,
      "ip": "192.168.4.1",
      "netmask": "255.255.255.0",
      "gw": "192.168.4.1",
      "dhcp_start": "192.168.4.2",
      "dhcp_end": "192.168.4.100",
      "trigger_on_gpio": -1,
      "keep_enabled": true
    }
  },
  "http": {
    "enable": true,
    "listen_addr": "80",
    "document_root": "/",
    "ssl_cert": "",
    "ssl_key": "",
    "ssl_ca_cert": "",
    "upload_acl": "*",
    "hidden_files": "",
    "auth_domain": "",
    "auth_file": ""
  },
  "rpc": {
    "enable": true,
    "max_frame_size": 4096,
    "max_queue_length": 25,
    "default_out_channel_idle_close_timeout": 10,
    "acl_file": "",
    "auth_domain": "",
    "auth_file": "",
    "ws": {
      "enable": true,
      "server_address": "",
      "reconnect_interval_min": 1,
      "reconnect_interval_max": 60,
      "ssl_server_name": "",
      "ssl_ca_file": "",
      "ssl_client_cert_file": ""
    },
    "mqtt": {
      "enable": true,
      "topic": "",
      "is_trusted": true
    },
    "uart": {
      "uart_no": 0,
      "baud_rate": 115200,
      "fc_type": 2,
      "wait_for_start_frame": true
    }
  },
  "dash": {
    "enable": false,
    "token": "",
    "server": "wss://mongoose-os.com/dashboard/rpc",
    "ca_file": "ca.pem",
    "heartbeat_interval": 10,
    "send_logs": true
  },
  "dns_sd": {
    "enable": false,
    "host_name": "mOS_esp8266_??????",
    "txt": "",
    "ttl": 120
  },
  "gcp": {
    "enable": false,
    "project": "",
    "region": "",
    "registry": "",
    "device": "",
    "key": "",
    "token_ttl": 3600
  },
  "mjs": {
    "generate_jsc": true
  },
  "spi": {
    "enable": false,
    "debug": false,
    "miso_gpio": 12,
    "mosi_gpio": 13,
    "sclk_gpio": 14,
    "cs0_gpio": 5,
    "cs1_gpio": -1,
    "cs2_gpio": -1
  },
  "pins": {
    "led": 2,
    "button": 0
  }
}
#4

If you change this line so that you reference the device ID directly instead of reaching into the config …

let topic = '/losant/5aa9876c5f623600074b3fbd/state';

Does it work as expected?