Using TRB142 with PPP over RS232 - storing settings permanently

I’m attempting to use the TRB142 together with a Campbell Scientific CR300 datalogger in PPP mode.
The datalogger controls the power to the modem, so it will only be on for the 1-2 minutes a day it takes to send data to our server.

I have set the modem control to full and I can get PPP working when echo is activated (ATE1) - so every time the datalogger powers up the modem it will send ATE1, and without this command PPP is not working for me.

The problem is that the power consumption remains high (10x the expected) when the datalogger is idle and modem is shut down, and as far as I can tell its caused by the RS232 port remaining active. Power consumption is critical for this application. Without the echo command the power consumption is low and as expected for idle sleep. I have previously configured similar setups with other modems over RS232 (Maestro/Lantronix M100 and M114) where this has not been an issue - but in these cases the datalogger does not need to send ATE1 inside the modem power up routine as its always active.

Is there a way to set the TRB142 to always echo and storing this setting permanently so it remains after powering down the modem? Being a novice at this, I also appreciate other tips on how to solve this (i.e. proper setup of PPP with Campbell dataloggers with TRB142).

This topic was automatically closed after 15 days. New replies are no longer allowed.

Hello,

We apologize for a late response.
To clarify, it seems you would like the modem to retain the ATE1 setting from boot. If RS232 is configured in full modem control mode, you can achieve this by using the AT&W command to save the following settings:

ATE
ATQ
ATS0
ATS7
ATS10
ATS12
ATV
ATX
AT&C
AT&D
AT+IPR
AT+CREG
AT+CGREG
AT+CEREG

Additionally, the ATZ command can be used to save these parameters:

ATE
ATQ
ATS0
ATS7
ATS10
ATS12
ATV
ATX
AT&C
AT&D
AT+CREG
AT+CGREG
AT+CEREG

Therefore, running the following commands in the RS232 modem console should be sufficient:

ATE1
AT&W

Let me know if any additional help is needed!

Best regards,

And as for establishing a PPP connection, as well as other useful information, I’d like to send you a manual.
I’ve sent you a form to fill out. Once you fill it out, I will contact you and provide the manual. Please use 5813 as the ticket ID. Thanks!

Best regards,

Hi All.

I’m trying to do pretty much the same thing and have created a new thread here.

PPP Help: Connect Campbell Scientific CR350 via TRB142 to MQTT Server.

I don’t suppose either of you guys could contact me and help me out.
I can’t seem to figure out how to chat or message in this forum.

Thanks
Gareth

Thanks @Daumantas - I eventually did get it working back in May, and part of what was done/tested was the ATE1 and AT&W. Great to have this list of settings and how to store them.

Not sure if the problems I had were only due to the modem, or also just how the datalogger works (and the biggest issue probably being my limited understanding of all of this), but what eventually got it working was to run ATE1 in the logger program each time the modem was started and also turn it off each time the modem was shut down. So below are the CR Basic routines that are called in my logger program to power up and down the modem (modem powered on SW12). These can probably be simplified and improved, but it works for our use case at least. The datalogger needs to be configured with PPP on RS232 and use the baud rate in the settings in the program (we used 115200), and the modem in “full modem control mode”. Maybe with the settings @Daumantas listed below this is no longer needed, but I’m not able to test this as the setup is deployed in the field. Hope this can be of some help to you @balistic

Sub ModemOn
  SW12(True)
  Delay(1,20, sec) ' Delay until the modem is ready to receive serial commands
  SerialOpen (Modemport,Modembaud,0,0,100)
  SerialOut (Modemport,"ATE1","OK",3,1500) ' ATE1 is needed for PPP to work on TRB142.
  SerialClose(Modemport) ' Needed so PPP can continue
  Delay(1,1, sec)
  P3_IP = PPPOpen
EndSub

Sub ModemOff
  SerialOpen (Modemport,Modembaud,0,0,100)
  SerialOut (Modemport,"+++","OK"+CHR(13),1,150)
  SerialOut (Modemport,"AT+CFUN=0"+CHR(13),"OK"+CHR(13),1,300)
  SerialOut (Modemport,"ATE0"+CHR(13),"OK",1,500)
  Delay (1,2,sec)
  SerialClose(Modemport)
  PPPClose
  SW12(False)
EndSub

1 Like

Also pinging @babbey from the other thread (I was not allowed to mention more than 2 people at the time in a post).

Hi @balistic ,

Sent you a form to fill out to your email address. I’ll send you the PPP connection manual privately.
In the form, please use ID 5813.

Best regards,

Appreciate the ping @rkivl!

I had a chat with one of the engineers here in Australia which basically resulted in resetting the TRB256 back to factory defaults and starting again, and got connected to a Campbells CR310 datalogger through the ethernet port (and have an MQTT broker running on the modem). Now that I’ve cracked that nut I’m hopeful that I’ll have more success going back to the RS232 connection when I get back in the office in a couple of days.

@balistic I’ll see if I can work out how to get directly in touch with you, given the ridiculous 15-day hard limit on these topics - until a kindly engineer re-opens them it seems! :slightly_smiling_face:

Cheers!

@Daumantas I have another configuration example to work through from the wiki pages, but if you could also send me this PPP connection manual that would be great.

Hello @babbey ,
Sure, I’ve sent you a form to fill out, please use 58132 as the ID. Thanks!

Received the file thanks @Daumantas - but in the end the solution to my problem was in @rkivl’s post. Adding the ATE1 command to our power-up sequence seems to have solved it for me. I’m going to make a few posts here to try to cover off what settings in the logger and the TRB256 worked for me - hopefully they’ll help anyone else who stumbles across this thread in the future.

Actually, I’ll try to cover this off in two posts - I saw another thread mentioning people being prevented from posting for 14 hours due to making too many posts so I’ll avoid that if I can…

Campbell Scientific CR310 datalogger settings (using Device Config)

Com Port Settings tab: ComPort RS-232 (duh), baud rate 115200; we don’t have the loggers talking to each other over PakBus so Beacon and Verify Intervals are both 0 and there are no neighbors
Ethernet tab: Disable Ethernet Power (possibly not relevant but I set this so that I was SURE the RS232 connection was being used)
PPP tab: Config/Port Used: RS232
IP Address: 0.0.0.0
User Name and Password:
Modem Dial String: ATD*99***1#dial string might be different for you
Modem Dial Response: CONNECT

Think that’s all that matters for the logger, so here’s the code we use when powering up the modem:

Dim Echo_Query As String * 50
Dim Echo_Ok As Boolean
Dim Echo_Retry As Long
  
SerialOpen(ComRS232,115200,3,0,1000)
SerialFlush(ComRS232)
  
For Echo_Retry = 1 To 3
  Delay(1,500,mSec)
  SerialOut(ComRS232,"ATE1" + CHR(13),"",1,20)
  SerialIn(Echo_Query,ComRS232,100,0,50)
  Echo_Ok = InStr(1,Echo_Query,"OK",2)
  If Echo_Ok Then ExitFor
Next Echo_Retry

Note that this is a tiny part of over 3000 lines of code, so if it seems like a bit of overkill there’s a reason… :smiley:

TRB256 settings in the next post!

TRB256 settings

Hmm, seems like I don’t have this licked just yet… My connection dropped out while I was looking through the modem settings, but that could have been because I also tried to use the CLI to retrieve our APN configuration. Will keep an eye on this and see what happens.

OK, a quick note on our environment. I work for a Government department, and we pay telstra (main telco in Australia) for a VPN and SIM card with static IP addresses, so we have to do some configuration before enabling full control in the serial services section. Your situation may be the same or different, but I’m going to assume that if you’re playing around with this stuff you’ll know how you need to configure the connection in the Network → Mobile section.

Once that’s done, head to Services → Modem Control - add a new instance using the rs232 device (again, duh). Enable it, set Baud rate to 115200, 8-1-None-None, and set Mode to Full Control (add a startup message on the Advanced tab if you like - I found this useful in troubleshooting as I could watch for this message when in watch mode in Device Config’s Terminal tab)

I think that should cover most of it, but I won’t be surprised if I’ve missed something, as I was playing around with the ethernet connection before coming back to this RS232 stuff. @balistic if this doesn’t work for you let me know and we’ll see if we can work out what I’ve missed to get you up and running! :slight_smile:

Hi All
I have tried to implement all the seting above.
But still haven’t quite got this sorted yet.
Sorry for the delay, as I have only just had time to test.
@babbey, @rkivl, I have setup a temporary email address if you guys are willing to help me, incase this forum becomes looked. Much appreciated.
trb1422024@gmail.com

I have implemented the following in my program and configured the cr350.
ComPort: RS-232
Baud: 115200
PPP Comport: RS-232
Dial String: ATD99**1#
Response: CONNECT

'   NEW MODEM SETUP TRIAL
    P3Open = PPPClose  
    Delay(1,1, sec)  
    SerialOpen(ComRS232,115200,3,0,1000)
    SerialFlush(ComRS232)
    
    For Echo_Retry = 1 To 3
      Delay(1,500,mSec)
      SerialOut(ComRS232,"ATE1" + CHR(13),"",1,20)
      SerialIn(Echo_Query,ComRS232,100,0,50)
      Echo_Ok = InStr(1,Echo_Query,"OK",2)
      If Echo_Ok Then ExitFor
    Next Echo_Retry
    
    SerialClose(ComRS232) ' Needed so PPP can continue
    Delay(1,1, sec)
    P3Open = PPPOpen

My ppp state: switches between the two following states, no IP Address is assigned.

ppp state: close success → program opening
ppp state: program closing → close success

One thing I forgot to note is it appears that you need to let the modem connect to the network at least once before enabling the RS232 connection under Serial Utilities > Modem Control. I guess this would fit between configuring the connection in the Network → Mobile section and then adding the instance in the Services → Modem Control section. After configuring the connection you should be able to see if it’s been successful, at which point you can configure (or enable) the RS232 connection, run the logger code and cross your fingers! :slight_smile:

Sorry, only realised this while trying to document configuring a modem from scratch for our tech support guys who will need to do this in the future…

And I only mention it because it’s caused us issues in the past, but double-check the Dial String for your location/service provider.

Good luck, hope that helps!!

Back again…

I can’t share our field-implemented code, so I’ve spent way more time than my manager would be happy with adapting it to just configure an RS232 PPP connection between a TRB256 and a CR310 (although this should work fine on just about all Campbells loggers). Seems to be reasonably robust and I imagine there are still some bugs in there, but I’m hoping this will help anyone needing to make a similar connection.

One thing that did cross my mind in all of this: I was assuming that this strange need to send an ATE1 command to the modem was a Teltonika requirement, but it could equally be something that the datalogger needs to kick-start PPP… If anyone (looking at you, @rkivl and @Daumantas :grin:) is able to shed some light on this that would be great.

babbey

' small script to test resetting a TRB256 modem and re-establishing the PPP connection
Public _ As String * 1 : ReadOnly _ :
Public Program_Status As String * 100
Public Modem_Status As String * 100
Public __ As String * 1 : ReadOnly __ :
Public PTemp, Batt_volt
Public RSSI_Value As String
Public IP_Addr As String * 20
Public ___ As String * 1 : ReadOnly ___ :
Public Modem_Reset As Boolean

'Define Subroutines
Sub Delay_With_Message(Delay_Ctr As Long, CountDown_Message As String * 100, Completed_Message As String * 50)
  Do While Delay_Ctr > 0
    Delay_Ctr -= 1
    Sprintf(Modem_Status,CountDown_Message & " (%i secs)",Delay_Ctr)
    Delay(1,1,sec)
  Loop
  Modem_Status = Completed_Message
EndSub  'Delay_With_Message

'Main Program
BeginProg
  Program_Status = "BeginProg"
  Modem_Reset = 0
  IP_Addr = IPInfo(1,0)

  Scan (2,Sec,0,0)
    Battery(Batt_volt)
    PanelTemp(PTemp,_50Hz)
    If IP_Addr <> "0.0.0.0" Then Sprintf(Modem_Status,"IP Address = %s",IP_Addr)
  NextScan
    
  SlowSequence
  Scan (1,Sec,0,0)
    If IP_Addr = "0.0.0.0" Then
      Modem_Status = "IP Address Unavailable"
      Modem_Reset = 1
      Delay_With_Message(35,"IP Address Unavailable, resetting modem in","Modem reset begun") ' Need this delayed message to know what's happening after sending program to logger
    EndIf

    If Modem_Reset <> 0
      Program_Status = "Modem Reset routine"

      Dim Modem_Query1 As String * 50
      Dim CSQ_Result(2) As Long, RSSI_result
      Dim RSSI_Str As String * 30
      Dim Ok1 As Boolean
      Dim Retry1 As Long
      Dim Echo_Query As String * 50
      Dim Echo_Ok As Boolean
      Dim Echo_Retry As Long

      #If (LoggerType = CR1000X) OR (LoggerType = CR350)
        SW12(SW12_1,1)  'When MODEM_HARDWARE_RESET is enabled using a CR1000X logger, SW12-1 is dedicated to switching Modem Reset Relay.
      #Else
        SW12(1)
      #EndIf
      Delay(1,1,Sec)

      Modem_Status = "Modem Powered Down"
      IP_Addr = "0.0.0.0"

      Delay_With_Message(40,"Modem powering up in","Modem powered up")
      #If (LoggerType = CR1000X) OR (LoggerType = CR350)
        SW12(SW12_1,0)
      #Else
        SW12(0)
      #EndIf

      Modem_Status = "Modem Powering Up..."
      Program_Status = "Modem Powerup Cycle"
      Delay_With_Message(90,"Modem powerup completing in","Poerup Cycle complete")
      Modem_Status = "Modem powercycled, attempting to establish PPP connection..."

      RSSI_result = NAN
      RSSI_Str = "Unavailable"

      SerialOpen (ComRS232,115200,3,0,300)
      SerialFlush(ComRS232)

      For Retry1 = 1 To 3
        Program_Status = "Sending AT+CSQ"
        Delay(1,500,mSec)
        SerialOut(ComRS232,"AT+CSQ" + CHR(13),"",1,20)
        SerialIn(Modem_Query1,ComRS232,100,0,50)

        SplitStr(CSQ_Result,Modem_Query1,"",2,0)
        Ok1 = InStr(1,Modem_Query1,"+CSQ:",2) > 0 AND ((CSQ_Result(1) >=0) AND (CSQ_Result(1) < 100))
        If (CSQ_Result(1) >=0) AND (CSQ_Result(1) <=30) Then ExitFor
      Next Retry1

      If Ok1 Then
        If (CSQ_Result(1) >=0) AND (CSQ_Result(1) <=31) Then
          RSSI_result = CSQ_Result(1) * 2 - 113
          RSSI_Str = Round(RSSI_result,0)
        EndIf
      Else
        Modem_Status = "Signal strength query failed"
      EndIf

      SerialClose(ComRS232)
      RSSI_Value = RSSI_result

      SerialOpen (ComRS232,115200,3,0,1000)
      SerialFlush(ComRS232)

      For Echo_Retry = 1 To 3
        Program_Status = "Sending ATE1"
        Delay(1,500,mSec)
        SerialOut(ComRS232,"ATE1" + CHR(13),"",1,20)
        SerialIn(Echo_Query,ComRS232,100,0,50)
        Echo_Ok = InStr(1,Echo_Query,"OK",2)
        If Echo_Ok Then ExitFor
      Next Echo_Retry
      Modem_Reset = 0
      SerialClose(ComRS232)
      Program_Status = "SerialClose"
    EndIf
    IP_Addr = PPPOpen
    Program_Status = "PPP configured! :)"
  NextScan
EndProg

Thanks for sharing @babbey, I think its great for the community to have this for future reference as well! As for the ATE1 command, I don’t really know myself and this is also not my field of expertise. This was the first Teltonika modem I tried with RS232, and other modems I have used over RS232 on Campbell dataloggers (Maestro/Lantronix) did not require ATE1 to be sent after it was configured. I don’t recall exactly, and I cannot check that now with deployed equipment, but the logger did not seem to receive the echos properly without sending ATE1 from the modem when looking as the terminal “Comms Watch” on the RS232 port (Campbell Terminal, “W” to enter comms watch). One can experiment more looking at the comms watch while sending AT commands I guess. For now we are happy it “just works” and that we have low power consumption :slight_smile:

No worries @rkivl - if I had a dollar for every time I’ve found the solution to one of my problems on some years-old forum… Well, it’s good to have a chance to give back! I also get a great deal of information from the Comms Watch function - and get to feel a little like Cypher or Tank at the same time… :laughing:

I was thinking about that ATE1 command, and you’re right - we don’t send that to our existing modems, and they’ve been connecting happily for years. We do use the AT+CSQ command so I tried commenting out the ATE1, and nope, no PPP connection, so it’s definitely the ATE1 command, and unless someone can advise otherwise, definitely a Teltonika/TRB thing - or maybe just the Quectel modem chip they’re using.

Anyway, I also realised that my code lacks a little hardware context, so here’s a picture/wiring diagram for the relay we use to power-cycle the modem:


(Not shown: modem -ve connection back to logger G)

Setting SW12(1) or SW12(SW12_1,1) powers down the modem, and setting either to zero allows the power to flow. We reset the modems once a day but also run an hourly ping test which will force a reset if unsuccessful. @balistic let us know if you’ve had some success - if not I’ll get in touch on that email you provided and see if I can help get you up and running. The number of features the TRB256 offers makes it well worth pushing through these teething problems in my opinion!

Since it’s now closed for replies, @Daumantas perhaps you could put a note in the other thread PPP Help: Connect Campbell Scientific CR350 via TRB142 to MQTT Server - Teltonika Networks - Teltonika Community pointing people to this one?