0

Adafruit Feather 32u4 FONA io.run() stuck in loop ?
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Sun Sep 01, 2019 9:17 am

I just purchased this board and antenna:
Adafruit Feather 32u4 FONA PRODUCT ID: 3027
Slim Sticker-type GSM/Cellular Quad-Band Antenna - 3dBi uFL PRODUCT ID: 1991

and started to experiment using FONA to publish sensor data to io.adafruit.com
I had previously created an account and successfully been running a Adafruit Feather HUZZAH with ESP8266 board for about a week now with no issues using WiFi, but wanted to try using a cellular solution.


I started with this code example from:
Arduino\libraries\Adafruit_IO_Arduino\examples\adafruitio_15_temp_humidity and used the example adafruitio_15_temp_humidity.ino
I followed the instructions and edited config.h and commented out all the wifi lines and uncommented the FONA lines:

#include "AdafruitIO_FONA.h"
AdafruitIO_FONA io(IO_USERNAME, IO_KEY);

for simple testing purposes I removed the lines of code using the DHT22 temp sensor and replaced them with
a integer counter I increment every 30 seconds and publish that value. In io.adafruit.com I created a new feed called lightlevel

and have this in the code before setup()
AdafruitIO_Feed *lightlevel = io.feed("lightlevel");
int ctr =0;

it started running around 8:35 pm on 8/31 and I could see it was posting data of the ctr value every 30 seconds but when I got up this morning it stopped around 2:38 am (ran ok for about 6 hours) The last value it posted was 594

when I go to my account on io.adafruit.com, select Profile, Monitor and do not see any errors (was not sure if I exceeded some threshold ?)


Live Errors
0 errors clear errors

Current Status
Free Usage
Feeds: 2 of 10
Dashboards: 1 of 5
Rate: 30 / minute
Current Usage: 2 / min
Storage: 30 days


Currently on the board I see this pattern of the network blue LED:
64ms on, 3 seconds off - the module has made contact with the cellular network
but then changes to
64ms on, 300ms off - the GPRS data connection you requested is active


My code is very simple at this point, in the serial monitor it appears to be connected but never
gets to the Serial.Println, like it is stuck in iorun(). It was displaying the serial.println when I first started the sketch the previous day and posting data on the IO site under feeds.


void loop() {
io.run();
ctr++;
Serial.print("CTR: ");Serial.println(ctr);
lightlevel->save(ctr); // lightlevel is the name of my feed
delay(30000); // wait 30 seconds
}


in the serial monitor window I see these lines repeating over and over almost like it is in a loop.
I assume this is output from the io.run() line but it never gets to my Serial.println line, did it lose a connection or cell service or exceed a threshold?

Connecting to TCP
---> AT+CIPSHUT
<--- SHUT OK
---> AT+CIPMUX=0
<--- OK
---> AT+CIPRXGET=1
<--- OK
AT+CIPSTART="TCP","io.adafruit.com","1883"
<--- OK
<--- STATE: IP STATUS
---> AT+CIPSTATUS
<--- OK
<--- STATE: IP STATUS



This is what the serial monitor window looked like last night when it was running ok:
CTR: 42 --> this is my Serial.println in the code I added
Writing packet
---> AT+CIPSTATUS
<--- OK
<--- STATE: CONNECT OK
AT+CIPSEND=74
0x30 0x48 0x0 0x18 0x6A 0x69 0x6D 0x6B 0x31 0x32 0x33 0x2F 0x66 0x2F 0x6C 0x69 0x67 0x68 0x74 0x6C 0x65 0x76 0x65 0x6C 0x2F 0x63 0x73 0x76 0x22 0x34 0x32 0x22 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30
<--- >
<--- SEND OK
---> AT+CIPSTATUS
<--- OK
<--- STATE: CONNECT OK
Reading data..


I restarted the board this morning and it took a long time to get a connection, these lines repeated around 60 times before it connected.
is it possible cellular connection got dropped and the io.run in the mainloop was not able to detect a lost connection ?

. ---> AT+CGATT?
<--- +CGATT: 0
---> AT+CREG?
<--- +CREG: 0,2
. ---> AT+CGATT?
<--- +CGATT: 0
---> AT+CREG?
<--- +CREG: 0,2
. ---> AT+CGATT?
<--- +CGATT: 0
---> AT+CREG?
<--- +CREG: 0,2
. ---> AT+CGATT?
<--- +CGATT: 0
---> AT+CREG?
<--- +CREG: 0,1
---> AT+CIPSHUT
<--- SHUT OK
---> AT+CGATT=1
<--- +CME ERROR: unknown
---> AT+CIPSTATUS
<--- OK
<--- STATE: IP INITIAL
Connecting to TCP

and it is now posting data again at 9/1/19 8:27am
blue network LED is flashing 64ms on, 300ms off (the GPRS data connection you requested is active)

I see this in the serial monitor window every 30 seconds as it posts a new value for ctr:
CTR: 22 (this is my serial.println displaying)
Writing packet
---> AT+CIPSTATUS
<--- OK
<--- STATE: CONNECT OK
AT+CIPSEND=74
0x30 0x48 0x0 0x18 0x6A 0x69 0x6D 0x6B 0x31 0x32 0x33 0x2F 0x66 0x2F 0x6C 0x69 0x67 0x68 0x74 0x6C 0x65 0x76 0x65 0x6C 0x2F 0x63 0x73 0x76 0x22 0x32 0x32 0x22 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30
0H

it has been running again for about 30 minutes
as of 2019/09/01 8:58:04am the last value posted in the feed is 60 so it appears to be working again but starting to wonder if io.run hangs for some reason ?


random observation:
in my code I have: lightlevel->save(ctr);
I noticed it seems to be uploading 4 values, 24 is my ctr value followed by 3 more values of 0
jimk123/f/lightlevel/csv"24",0.0000000e+00,0.0000000e+00,0.0000000e+00

When I view the feeds screens for lightlevel i see:
Created at Value Location
2019/09/01 8:37:27am 24 0, 0, 0

looking at the library code 'location' appears to be lat,long and altitude but why does the interface upload these each time ?
is their a param to only upload my value ?

thanks

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Wed Sep 04, 2019 7:20 am

I have been letting this run over a few days and periodically it seems to stop accepting connections and the blue network LED instead of a quick flash only flashes every 3 seconds . I also saw this in the serial monitor window - Failed to send packet.

Code: Select all | TOGGLE FULL SIZE
Read:   CTR: 6437
Writing packet
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
AT+CIPSEND=76
 0x30 0x4A 0x0 0x18 0x6A 0x69 0x6D 0x6B 0x31 0x32 0x33 0x2F 0x66 0x2F 0x6C 0x69 0x67 0x68 0x74 0x6C 0x65 0x76 0x65 0x6C 0x2F 0x63 0x73 0x76 0x22 0x36 0x34 0x33 0x37 0x22 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30 0x2C 0x30 0x2E 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x65 0x2B 0x30 0x30
0
   <--- >
   <---
Failed to send packet.
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
Reading data..
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
   ---> AT+CIPRXGET=4
   <--- +CIPRXGET: 4,44
44 bytes available

Is there some tool or command I can run to test the TCP connection to io.adafruit.com on what I assume is port 1883 ?
I am using windows 10 w/Chrome

Also is there a line of code or function I can add to the sketch to tell me the RSSI signal strength ? Not sure if the destination is rejecting the TCP request or the cell connection is too weak ?
thanks

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Wed Sep 04, 2019 7:49 am

I found this command to test the network connection from my win10 machine in powershell

PS C:\Users\Jim> Test-NetConnection -ComputerName "io.adafruit.com" -InformationLevel "Detailed" -port 1883


ComputerName : io.adafruit.com
RemoteAddress : 52.7.124.212
RemotePort : 1883
NameResolutionResults : 52.7.124.212
52.72.201.158
MatchingIPsecRules :
NetworkIsolationContext : Internet
IsAdmin : False
InterfaceAlias : Wi-Fi
SourceAddress : 192.168.2.183
NetRoute (NextHop) : 192.168.2.1
TcpTestSucceeded : True

but on the feather FONA board in the serial window all I see is: (it seems to be stuck in the io.run() function)

Connecting to TCP
---> AT+CIPSHUT
<--- SHUT OK
---> AT+CIPMUX=0
<--- OK
---> AT+CIPRXGET=1
<--- OK
AT+CIPSTART="TCP","io.adafruit.com","1883"
<--- OK

not sure where the problem is ?

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Wed Sep 04, 2019 2:47 pm

it hung again and this time I pushed the RST button on the FONA board, it seems to connect, send 1 packet and now is just looping with this data in the serial monitor window over and over:

a google search says: AT+CGATT? = The execution command is used to attach the MT to, or detach the MT from, the GPRS service and a status of 1 = attached, not sure why it is in this loop ?
Code: Select all | TOGGLE FULL SIZE
<--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?

Adafruit Tech support - do you have access to any logs to help pinpoint if the error is on my side or the io.adafruit host ?

thanks

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by brubell on Thu Sep 05, 2019 10:03 am

Do you see the 32u4 FONA connecting in the monitor page?
https://io.adafruit.com/monitor

brubell
 
Posts: 604
Joined: Fri Jul 17, 2015 10:33 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Thu Sep 05, 2019 12:52 pm

I had unplugged the FONA board since it was not upload data at all anymore. I just plugged it in and

The Network blue LED is flashing fast and in the io.adafruit.com site under Profile, monitor I see:
Live Errors
0 errors clear errors

but no data from that feed.

I am also running a Adafruit Feather HUZZAH ESP8266 with 4 feeds that is working fine. Am I exceeding a threshold ? I thought the basic service said 5 feeds which is what I have defined.

This is my entire Loop code and it never makes it to the Serial.println("io.run"); line. lightlevel is a arbitrary feed name I created to keep the code as simple as possible for test purposes and I just increment a counter and try to publish it.
Code: Select all | TOGGLE FULL SIZE
void loop() {
  Serial.println("io.run");
  io.run();
  ctr++;
  Serial.print("CTR: ");Serial.println(ctr);
  lightlevel->save(ctr);
  delay(30000); // wait 30 seconds
}


thanks
see this in the serial monitor window:
Code: Select all | TOGGLE FULL SIZE
Connecting to Adafruit IOAttempting to open comm with ATs
   ---> AT
   <---
   ---> AT
   <---
   ---> AT
   <--- AT
   ---> AT
   <--- AT
   ---> ATE0
   <--- ATE0
   ---> ATE0
   <--- OK
   ---> AT+CVHU=0
   <--- OK
   ---> ATI
   <--- SIM800 R13.08

OK

RDY

+CFUN: 1

   ---> AT+GMM
   <--- SIMCOM_SIM800H

OK

   ---> AT+CPMS="SM","SM","SM"
   <--- ERROR
   ---> AT+CGATT?
   <--- +CGATT: 0
   ---> AT+CREG?
   <--- +CREG: 0,2
.   ---> AT+CGATT?
   <--- +CGATT: 0
   ---> AT+CREG?
   <--- +CREG: 0,2
.   ---> AT+CGATT?
   <--- +CGATT: 0
   ---> AT+CREG?
   <--- +CREG: 0,2
.   ---> AT+CGATT?
   <--- +CGATT: 0
   ---> AT+CREG?
   <--- +CREG: 0,2
.   ---> AT+CGATT?
   <--- +CGATT: 0
   ---> AT+CREG?
   <--- +CREG: 0,2
.   ---> AT+CGATT?
   <--- +CGATT: 0
   ---> AT+CREG?
   <--- +CREG: 0,2
.   ---> AT+CGATT?
   <--- +CGATT: 0
   ---> AT+CREG?
   <--- +CREG: 0,2
.   ---> AT+CGATT?
   <--- +CGATT: 0
   ---> AT+CREG?
   <--- +CREG: 0,1
   ---> AT+CIPSHUT
   <--- SHUT OK
   ---> AT+CGATT=1
   <--- +CME ERROR: unknown
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: IP INITIAL
Connecting to TCP
   ---> AT+CIPSHUT
   <--- SHUT OK
   ---> AT+CIPMUX=0
   <--- OK
   ---> AT+CIPRXGET=1
   <--- OK
AT+CIPSTART="TCP","io.adafruit.com","1883"
   <--- OK
   <--- CONNECT OK
Writing packet
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
AT+CIPSEND=23
0x10 0x15 0x0 0x4 0x4D 0x51 0x54 0x54 0x4 0xFFFFFF82 0x1 0x2C 0x0 0x0 0x0 0x7 0x6A 0x69 0x6D 0x6B 0x31 0x32 0x33
<--- >
   <--- SEND OK
Reading data..
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
   ---> AT+CIPRXGET=4
   <--- +CIPRXGET: 4,4
4 bytes available
1 bytes read
 0x20
Read:   Reading data..
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
   ---> AT+CIPRXGET=4
   <--- +CIPRXGET: 4,3
3 bytes available
1 bytes read
 0x2
Read:   Reading data..
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
   ---> AT+CIPSTATUS
   <--- OK
   <--- STATE: CONNECT OK
   ---> AT+CIPRXGET=4
   <--- +CIPRXGET: 4,2
2 bytes available
2 bytes read
 0x0 0x5
Read:   .   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?
   <--- +CGATT: 1
.   ---> AT+CGATT?

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Thu Sep 05, 2019 1:03 pm

I justed added this line in setup()
Serial.print("IO.STATUS=");Serial.println(io.status());

it seems to connect, send a packet but then loop (see last post of serial output) and displays a value of '11' for io.status()
thanks

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Sat Sep 07, 2019 6:35 pm

Adafruit tech support:

I started this post on September 1 and still have not heard from anyone in tech-support, I do not want to keep repeating details in the post, but clearly something is not working with the hardware, software and or hosting service and I need your help in troubleshooting it

I seem to have two scenarios with this board, the first is it will connect and post values anywhere from a few hours up until 20 hours or so hours and then just get stuck in the main loop in the Io.run call. The second scenario is when it starts it appears to initially connect but never enters the main loop.

Today I took the device about 65 miles south my current location, where I plan to use it, where I’ve been using another fona 2g shield for about a year that is rocksolid but not using the Adafruit io service. I tried running it with a 2000 mA Lipo battery and the antenna documented above but it never seemed to connect at all, I would get one blue flash , pause for 3 seconds and repeat.

When I came back home I plugged it back into the laptop with a USB And lipo and it connected and started uploading values. Then I unplugged it from the USB cable, removed the battery, re-inserted the battery and the same symptoms where the blue LED will flash once every three seconds but I do not see any data getting logged. I thought it could run for awhile just on the lipo battery?

I could really use some suggestions on further troubleshooting tips
Thanks

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Tue Sep 10, 2019 10:12 pm

Adafruit tech support
It has been 9+ days and no one has replied :(

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by adafruit2 on Wed Sep 18, 2019 1:55 pm

hiya - its extremely hard to debug why your FONA works sometimes. it could be battery level, it could be antenna, it could be coverage. its def able to get to th enetwork *sometimes* but failing others. cellular is like that.
without being there it wont be possible for us to do diagnosis. we can refund the feather and you can pick up a Particle Cellular kit, they're experts at cellular, and perhaps their 3G or LTE board will work better
https://www.adafruit.com/?q=particle%20cellular

adafruit2
Site Admin
 
Posts: 18783
Joined: Fri Mar 11, 2005 7:36 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by jimk123 on Wed Sep 18, 2019 7:06 pm

My gut feeling is the network is OK, I have been using a fona 2g shield for about two years with a mega and it is rocksolid. When I load the fona sample code to send a text message on the feather that works OK. I feel like the problem lies somewhere in the Io.run function call and was hoping you folks could offer some suggestions on what is going on in that function and if there’s any properties I can display prior to calling it or set up a watchdog?

Also any thoughts on why the board never works and it powered up under battery power only? The lipo battery is fully charged so I don’t think that is the issue. Maybe I just got a bad board and should try another one

I looked at the particle link you provided and that seems to be a proprietary solution and I assume I cannot use the Adafruit IO libraries on that board? I already paid for cellular plan through Ting.

jimk123
 
Posts: 188
Joined: Sun Dec 26, 2010 7:04 pm

Re: Adafruit Feather 32u4 FONA io.run() stuck in loop ?

by adafruit2 on Thu Sep 19, 2019 2:03 am

its really hard to tell but it could be the board is bad, its probably not adafruit.io cause the code works with your other setup. we recommend the mega+shield setup if you can use that, it will be more stable - lots more memory!
particle is proprietary but they are experts at cellular, its their main focus!

adafruit2
Site Admin
 
Posts: 18783
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.