Home › Forums › Mayfly Data Logger › Cannot connect to internet for clock sync with NIST › Reply To: Cannot connect to internet for clock sync with NIST
You shouldn’t really need the development board. If you’re going to use a bunch of the XBee’s I’d say it’s a $70 well spent, but you shouldn’t *need* it.
Nothing looks wrong in your program. I’m guessing you’re just not connecting to the internet. What build flags are you running with? Can you set all of these and post the log from the serial port monitor:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
build_flags = -DSDI12_EXTERNAL_PCINT -D TINY_GSM_RX_BUFFER=64 -D TINY_GSM_YIELD_MS=2 -D TINY_GSM_DEBUG=Serial -D MS_LOGGERMODEM_DEBUG -D MS_LOGGERMODEM_DEBUG_DEEP -D MS_DIGIXBEE_DEBUG -D MS_DIGIXBEECELLULARTRANSPARENT_DEBUG -D MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP -D MS_DIGIXBEE_DEBUG -D MS_DIGIXBEELTEBYPASS_DEBUG -D MS_DIGIXBEELTEBYPASS_DEBUG_DEEP |
The output might be very long; you’ll probably see a _lot_ of lines that are AT+CEREG? and responses to that. That’s the Mayfly asking the cellular chip on the XBee3 if it’s registered on the network yet. If you eventually get a +CEREG=5 (or 1), you’re registered. If the response is still a 2 or 4 you’re not registered with the network. If you get as far as being registered and then you’re still not able to post data, that’s a problem with your code or my library. If you’re never registered, it’s the bee or the sim.
Some things to try if you’re not getting registered:
- Increase the time
modem.connectInternet(120000L)
up to 10 or 15 minutes (it’s in ms, 120000L = 2 minutes; 600000L = 10 minutes, the “L” tells the compiler it’s a “long” number). Making the initial connection with a new sim/board/tower may take a really long time.
- Flip back and forth between using “bypass” and “transparent” mode. See if one works.
- Run a basic program on your Mayfly that just wakes up the bee and leaves it awake. Let it sit a long while and see if you ever connect. Something like this should work:
-
C++12345678910111213141516171819202122#include <Arduino.h>void setup(){Serial.begin(115200);Serial1.begin(9600);pinMode(23, OUTPUT); // make sure the XBee is awakedigitalWrite(23, LOW);}void loop(){delay(1000);Serial1.print("+++"); // Enter command modedelay(1000);Serial1.print("ATAI\r"); // Ask if we're connected to the networkwhile (Serial1.available()){Serial.write(Serial1.read());}delay(300000L); // wait 5 minutes before asking again}
If you eventually get a “0” (zero) response, you’re finally connected. A “22” or “FF” means it’s searching or the status is unknown. A “25” means registration has been denied – if you get that, your APN that you set in your other code must have been wrong – I doubt you’ll get this.