// Time values (UTC)gps.GetYear()// a number, eg 2025gps.GetMonth()// a number, eg 1gps.GetDay()// a number, eg 2gps.GetHour()// a number, eg 19gps.GetMinute()// a number, eg 42gps.GetSecond()// a number, eg 1gps.GetMillisecond()// a number, eg 25// Latitude values - broken out by degrees, minutes, secondsgps.GetLatDeg()// a number, eg 40gps.GetLatMin()// a number, eg 44gps.GetLatSec()// a number, eg 30// Latitude values - degrees onlygps.GetLatDegMillionths()// a number, eg 40741668// Longitude values - broken out by degrees, minutes, secondsgps.GetLngDeg()// a number, eg -74gps.GetLngMin()// a number, eg 1gps.GetLngSec()// a number, eg 59// Longitude values - degrees onlygps.GetLngDegMillionths()// a number, eg -74032986// Grid valuesgps.GetGrid6()// a string, eg "FN20XR"// Altitude valuesgps.GetAltitudeFeet()// a number, eg 426gps.GetAltitudeMeters()// a number, eg 130// Speed valuesgps.GetSpeedMPH()// a number, eg 22gps.GetSpeedKPH()// a number, eg 35// Course valuesgps.GetCourseDegrees()// a number, eg 206
These values are available during testing
As you develop your code, the tracker will simulate a genuine GPS lock using the values listed in the API description above.
This helps you work with real values in a repeatable way as you enhance your code.
// Create a new I2C interfaceletsensor=newI2C(0x77)// Detect if the I2C device is operationalsensor.IsAlive()// Read a 1-byte (8-bit) value from a registerletreg=0x10letu8=sensor.ReadReg8(reg)// Read a 2-byte (16-bit) value from a registerletreg=0x10letu16=sensor.ReadReg16(reg)// Write a 1-byte (8-bit) value to a registerletreg=0x10letu8=0b10010011sensor.WriteReg8(reg,u8)// Write a 2-byte (16-bit) value to a registerletreg=0x10letu16=0x03F2sensor.WriteReg16(reg,u16)
// Create a new I2C interfaceletsensor=newI2C(0x77)// Detect if the sensor is operationalif(sensor.IsAlive()){// Do something// ...}else{// Do something else// ...}
// Create a new Pin interfaceletpSensorEnable=newPin(12)// Turn on sensorpSensorEnable.On()// Wait for sensor to come aliveDelayMs(1)// Do stuff// ...// Turn off sensorpSensorEnable.Off()
Only some pins are made available for GPIO control
Status
GPIO Pin List
Available
10, 11, 12, 13, 20, 21
Unavailable
Everything else
GPIO pins can supply a very limited amount of current
The datasheet indicates a maximum of 50mA sink/source total for all GPIO pins.
The output pins are defaulted to 2mA output drive strength each.
You probably don't need to turn your sensor on/off
How much power are you really saving?
But controlling a switch to drop leaflets over North Korea, that's a different question.
// Create new ADC instanceletadc=newADC(26);// Read the calculated voltage value assuming 3.3v referenceadc.ReadVolts();// Read the raw ADC 12-bit value// (ie a value in the range 0 - 4095)adc.ReadRaw();
Only some pins can serve as an ADC source
You have access to two ADC GPIO pins -- 26 and 27.
The spec notes there are 4 ADC GPIO pins. This is how they're allocated.
ADC GPIO
Allocation
26
Available to use
27
Available to use
28
Not available (used by tracker to switch SI5351 on/off)
29
Not available (used by tracker to measure source voltage -- access via SYS API)
ADC values are multi-sampled and averaged automatically
Each ADC read function will take 100 ADC samples and return the average.
// Print to the screen strings, values, etc, to help debug your program.Log(output)// Pause execution of the program for a while, such as after enabling// a sensor, to give it time to become active.//// Delay times are in milliseconds (ms), ie 1,000 ms per second.//// A common delay time to let a sensor wake up is less than 5ms.//// Note -- There is a STRICT time limit imposed on the execution time of// a script, after which it will be canceled and the message NOT sent.// Do NOT delay execution for long periods of time.//DelayMS(ms)
Log(3)// this will have "3" appear on screenletx=3Log(x)// this will have "3" appear on screenLog("x")// this will have "x" appear on screenLog("hi mom")// this will have "hi mom" appear on screen// You can embed values into the output when you put them inside the `${}`// Notice that the quotation marks are not normal, they're `backticks`,// which are the key left of the `1` key in the USA.letx=3Log(`x = ${x}`)// this will have "x = 3" appear on screen