PPP to UART Cellular

I have a cellular modem I would like to test. Do you have any example to get me pointed in the right direction?

I got ethernet talking to the outside world now I want to try something a little more challenging.

Great, we need that tested by other modems and other countries/networks. I have been told that networking docs are in the works for next week. You will get all the info you need.

1 Like

Incase you don’t want to wait:

static void Main()
    InitSimCard(); // depends on your cellular + your sim

static bool linkReady = false;

static void DoTestPPP()

    var networkController = NetworkController.FromName("GHIElectronics.TinyCLR.NativeApis.Ppp.NetworkController");
    PppNetworkInterfaceSettings networkInterfaceSetting = new PppNetworkInterfaceSettings()
        AuthenticationType = PppAuthenticationType.Pap,
        Username = "",
        Password = "",

    UartNetworkCommunicationInterfaceSettings networkCommunicationInterfaceSettings = new UartNetworkCommunicationInterfaceSettings()
        ApiName = GHIElectronics.TinyCLR.Pins.SC20260.UartPort.Usart1,
        BaudRate = 115200,
        DataBits = 8,
        Parity = UartParity.None,
        StopBits = UartStopBitCount.One,
        Handshaking = UartHandshake.None,

    networkInterfaceSetting.Address = new IPAddress(new byte[] { 192, 168, 1, 122 });
    networkInterfaceSetting.SubnetMask = new IPAddress(new byte[] { 255, 255, 255, 0 });
    networkInterfaceSetting.GatewayAddress = new IPAddress(new byte[] { 192, 168, 1, 1 });
    networkInterfaceSetting.DnsAddresses = new IPAddress[] { new IPAddress(new byte[] { 75, 75, 75, 75 }), new IPAddress(new byte[] { 75, 75, 75, 76 }) };

    networkInterfaceSetting.MacAddress = new byte[] { 0x00, 0x4, 0x00, 0x00, 0x00, 0x00 };
    networkInterfaceSetting.IsDhcpEnabled = true;
    networkInterfaceSetting.IsDynamicDnsEnabled = true;

    networkInterfaceSetting.TlsEntropy = new byte[] { 0, 1, 2, 3 };


    networkController.NetworkAddressChanged += NetworkController_NetworkAddressChanged;
    networkController.NetworkLinkConnectedChanged += NetworkController_NetworkLinkConnectedChanged;


    while (linkReady == false) ;

    // Network is ready to used

private static void NetworkController_NetworkLinkConnectedChanged(NetworkController sender, NetworkLinkConnectedChangedEventArgs e)
    // Raise event connect/disconnect

private static void NetworkController_NetworkAddressChanged(NetworkController sender, NetworkAddressChangedEventArgs e)
    var ipProperties = sender.GetIPProperties();
    var address = ipProperties.Address.GetAddressBytes();

    linkReady = address[0] != 0;

1 Like

For InitSimCard(), code below we tested on SIM900, SKYWIRE and Tmobile Simcard as well.

For Google Fi, change "telargo.t-mobile.com" to "h2g2"

static void InitSimCard() {
    var serial = GHIElectronics.TinyCLR.Devices.Uart.UartController.FromName(GHIElectronics.TinyCLR.Pins.SC20260.UartPort.Usart1);

    serial.SetActiveSettings(115200, 8, GHIElectronics.TinyCLR.Devices.Uart.UartParity.None, GHIElectronics.TinyCLR.Devices.Uart.UartStopBitCount.One, GHIElectronics.TinyCLR.Devices.Uart.UartHandshake.None);


    SendAT(serial, "AT");

    SendAT(serial, "AT+CGDCONT=1,\"IP\",\"telargo.t-mobile.com\"");
    SendAT(serial, "ATDT*99***1#");
    System.Diagnostics.Debug.WriteLine("OK to start PPP....");

static void SendAT(UartController port, string command)
    command += "\r";

    var sendBuffer = Encoding.UTF8.GetBytes(command);
    var readBuffer = new byte[256];
    var read = 0;

    port.Write(sendBuffer, 0, sendBuffer.Length);

    while (true)
        read += port.Read(readBuffer, read, readBuffer.Length - read);

        var response = new string(Encoding.UTF8.GetChars(readBuffer, 0, read));

        if (response.IndexOf("OK") != -1 || response.IndexOf("CONNECT") != -1)
            System.Diagnostics.Debug.WriteLine(" " + response);
1 Like

This should use SITCore pins instead, correct?

Yes, updated! I was still in low level!

Is there any options available to see any debugging messages while the PPP connection is trying to be made?
I am trying to get a Nimblelink modem to work.

Like some sort of log? I do not think we have that. But we did test one of the nimblelink modems

Yes, something that can be switched ON/Off and just used during development time.
My current situation is that them modem responds to the initial AT commands but then just sits there after that. With no other info its a guessing game.

I will let you know how it goes! :wink:

@Dat_Tran is there a way to troubleshoot a modem connection?

PPP Works!

I tested with Nimblelink NL-SQ-LTE-TSVG modem (LTE CAT3 on Verizon) using a Click to Skywire adapter.

My preferred modem, Digi XBee 3 Cellular, I found out only works with USB PPP, no UART PPP. :slightly_frowning_face:

The code that @Dat_Tran provided worked pretty much out of the box. I did change AuthenticationType to PpppAuthenticationType.None. Not sure if that was an issue or not. My biggest hang-up was not getting a good signal. There was no way to know what was going with the signal. I added some AT commands to check the signal strength.

I also set up the On_Off pin and Reset pins based on the modems datasheet.

Thanks @Dat_Tran and @Gus_Issa for your help.


Isn’t it great that everything just works in TinyCLR 2.0? :nerd_face: Can we say it was worth the wait?

1 Like

What AT commands did you use? Or just used code shared above?

Not sure now I couldn’t get it to work even in AT mode. Always says ERROR, No Service, No Carrier…

Just one SIM900 module it says CONNECT but… without the SIM.

Are quad-band modems still supported in the US? I thought that all quad support was switched over to 3 and 4G by now.

I used the standard AT commands that were in the sample. I did change PppNetworkInterfaceSettings.AuthenticationType to PppAuthenticationType.None. I don’t know if that made any difference or not. My biggest hang-up was I had a T-Mobile/AT&T capable SIM in a Verizon only modem. Once I put a Verizon capable SIM in I was good to go.

In regards to service, if 2G is still available, it would only be on T-Mobile until the end of 2020 I believe. AT&T shut its 2G down. AT&T is sunsetting 3G now and it will be turned off the end of 2021, they no longer allow any new 3G devices on their network. My guess is that your SIM900 just isn’t finding any service providers.


yes, thanks. i got it working back.