Solar powered Tinygs satellite tracking with Deep sleep (or control one thing with another thing)

When looking into 433mhz devices I came across Tiny ground station which tracks Low Earth Orbit LoRa satellites. There are currently just over 1000 ground stations around the earth.


Yes the antennas are made from metal measuring tape.

Working with the 433mhz you learn to make your own antenna.


I use a ground plane antenna.

The better placement of your antenna the more satellites you can pick up.
The longer the coax cable between your ground station and antenna the worse the signal.

I put the station outside but close enough to my WIFI.
A ground station is just an ESP32 with lora. The ESP32 needs power. Getting power outside presents it’s own problems. A long usb cable would be too easy.
An 18650 cell is enough to run the ESP32 through a 3.3 Linear regulator connected to 3.3 V rail for 12hrs.
Connect a 5V solar panel and it will run longer. Where I live the sun currently reaches 12.5 degrees above horizon.
Sometimes there is no significant sunshine for days at a time.
It can be hours between satellites passing into range so there is no need to run the ESP32 all the time.
The current ESP32 firmware for Tinygs doesn’t have a deep sleep. I decided to use an ESP8266 to turn the ESP32 on/off and go into deep sleep itself.

The ESP12F toggles on/off the ESP32 via a MAX16054 connected to the gate of a P Mosfet.
The MAX16054 comes as a SOT23 (this is tiny) and needs soldered to a DIP board. This was the most difficult soldering job.

This is a busy pic.

I needed to know when Sattellites are in range.

  1. Got API from https://www.n2yo.com/
  2. Add satellite N2YO intergration
  3. Pick which satellites I wished to track. I picked 5 with update interval of 40 seconds.(There are limits)
  4. In config.yaml set up proximity
proximity:
  home:
    devices:
      - device_tracker.fees
      - device_tracker.norbi
      - device_tracker.fossasat_2e11
      - device_tracker.satlla_2b
      - device_tracker.fossasat_2e1
    tolerance: 5
  1. add each satellite as a person settings/people add person

  2. set up the zone you can receive satellites setting/areas&zones/zones set up new zone Lora at 1600000m

  3. set up the automations to set sleep time for ESP12F (tinyygs servo)

alias: Tinygs Servo to sleep
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.tinygs_servo_status
    to: "on"
  - platform: homeassistant
    event: start
condition:
  - condition: numeric_state
    entity_id: sensor.nearest_sat
    above: 2100
action:
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleepearly
      payload: "OFF"
      qos: "1"
      retain: false
    alias: sleep off
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
    enabled: true
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleep_mode_time
      payload_template: >-
        {{ (((((states('proximity.home')|float-2100)**2
        )**0.5)/6.5)+15)|round(0)*1000 }}
      qos: "1"
      retain: false
    alias: set sleep time
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
    enabled: true
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleepearly
      payload: "ON"
      qos: "1"
      retain: false
    alias: Sleep now
  - service: mqtt.publish
    data:
      topic: tinygs-servo/available_mode
      payload: offline
      qos: "1"
      retain: false
    alias: Announce offline
mode: single

This uses MQTT to change the sleep time. The payload template is complicated. The distance can get less than 2100 between the trigger firing and the template so it would set the sleep time as a negative number or 0 so it wouldn’t come out of sleep, meaning I would have to disconnect and reconnect the power.
I couldn’t get the satellite intergration to tell me if sat coming towards or going away so I assumed it was coming towards my zone.
It then goes to sleep for a period expecting to wake again when much closer to my zone.

alias: "Tinygs turn on Lora "
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.tinygs_servo_status
    to: "on"
condition:
  - condition: numeric_state
    entity_id: sensor.nearest_sat
    below: 2101
action:
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleepearly
      payload: "OFF"
      qos: "1"
      retain: false
    alias: sleep off
  - service: automation.turn_off
    data: {}
    target:
      entity_id: automation.tinygs_servo_to_sleep
  - service: mqtt.publish
    data:
      topic: tinygs-servo/available_mode
      payload: offline
      qos: "1"
      retain: false
    alias: Set Servo as offline
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: switch.turn_on
    data: {}
    target:
      entity_id:
        - switch.toggle_lora_on_off
    alias: Turn LORA on
    enabled: true
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.tinygs_lora_on_off
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleep_mode_time
      payload: "660100"
      qos: "1"
      retain: false
    alias: Set sleep time to 11mins
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleepearly
      payload: "ON"
      qos: "1"
    alias: Mqtt sleep early on
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: automation.turn_on
    data: {}
    target:
      entity_id: automation.tinygs_wake_lora_auto_off_wait_sleep_lora_wake_lora_auto_on
    alias: Switch to LORA is on sequence
  - service: automation.turn_off
    data: {}
    target:
      entity_id: automation.tinygs_turn_on_lora_then_off_again_later
    alias: Turn self off
mode: single

So if it gets the distance to be less than 2100Km it triggers the automation to toggle the ESP32 on. It sets deep sleep to 11mins (time for satellite to cross my zone)
It then enables the next automation that waits until ESP12F comes back online. It disables the normal automation for setting sleep time and itself. The input boolean tells me if ESP32 is likely to be on.

alias: Tinygs  unknown
description: " "
trigger:
  - platform: state
    entity_id:
      - binary_sensor.tinygs_servo_status
    from: "off"
    to: "on"
condition:
  - condition: state
    entity_id: binary_sensor.tinygs_servo_status
    state: "on"
    enabled: false
action:
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleepearly
      payload: "OFF"
      qos: "1"
      retain: false
    alias: Set sleep early off
  - service: automation.turn_off
    data: {}
    target:
      entity_id:
        - automation.tinygs_turn_on_lora_then_off_again_later
        - automation.tinygs_servo_to_sleep
    alias: Turn off other 2 sleep Autos
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.toggle_lora_on_off
    alias: Turn LORA off
    enabled: true
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.tinygs_lora_on_off
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleep_mode_time
      payload: "200100"
      qos: "1"
      retain: false
    alias: Tell Servo how long to sleep
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - service: mqtt.publish
    data:
      topic: tinygs-servo/available_mode
      payload: offline
      qos: "1"
    alias: Report Servo is offline
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleepearly
      payload: "ON"
      qos: "1"
      retain: false
    alias: Tell Servo to sleep
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
    enabled: true
  - service: script.turn_on
    data: {}
    target:
      entity_id: script.switch_lora_back_off_again_then_send_servo_to_sleep
  - service: automation.turn_off
    data: {}
    target:
      entity_id: automation.tinygs_wake_lora_auto_off_wait_sleep_lora_wake_lora_auto_on
    alias: Turn automation self off
mode: single

Ignore the alias name, it was just something to stand out when writing this. Too many things with Tinygs in the name.
This automation waits for MQTT message to say ESP12F back online to toggle the ESP32 off and set a sleep time of just over 3 mins (to make sure the sat has truly left the zone and no new sat has entered the zone)
Then it turns on a script enable the normal deep sleep and turn on ESP32 automations.

alias: Switch Servo sleep automations back on script
sequence:
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleep_mode_time
      payload: "200100"
      qos: "1"
    alias: Set new 15 sleep time
  - service: mqtt.publish
    data:
      topic: tinygs-servo/available_mode
      payload: offline
      qos: "1"
      retain: false
    alias: Set Servo as offline
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: mqtt.publish
    data:
      topic: tinygs-servo/sleepearly
      payload: "ON"
      qos: "1"
    alias: Mqtt sleep early on
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: automation.turn_on
    data: {}
    target:
      entity_id:
        - automation.tinygs_servo_to_sleep
    alias: Turn on sleep early Seep Automations back on
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: automation.turn_on
    data: {}
    target:
      entity_id:
        - automation.tinygs_servo_to_sleep
        - automation.tinygs_turn_on_lora_then_off_again_later
    alias: Turn Seep Automations back on
mode: single

Small delays are included to allow MQTT server time to receive the messages.

esphome:
  name: tinygs-servo-esp12f

esp8266:
  board: esp01_1m

# Enable logging
logger:
  level: INFO


ota:
  password: "redacted"

wifi:
  ssid: "redacted"
  password: "redacted"
  manual_ip:
    static_ip: 192.168.81.88
    gateway: 192.168.81.1
    subnet: 255.255.255.0
    dns1: 192.168.81.96
    dns2: 8.8.8.8  
  output_power: 18dB

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Tinygs-Servo-Esp12F"
    password: "redacted"
        
i2c:
    sda: 5
    scl: 4
    scan: False

switch:

  - platform: restart
    name: "tinygs-servo Restart"
    


  - platform: gpio
    pin: 1
    id: lora_toggle
    restore_mode: ALWAYS_OFF
    name: "Toggle Lora on off"
    inverted: true
    on_turn_on:
    - delay: 50ms
    - switch.turn_off: lora_toggle  



sensor:
  - platform: template
    name: servo sensor position
    id: my_servo_sensor
    
  
  - platform: wifi_signal
    name: "tinygs-servo WiFi Signal"
    update_interval: 60s     

  - platform: mqtt_subscribe
    name: "Sleep time topic tinygs-servo"
    id: custom_sleep_time_tinygs_servo
    unit_of_measurement: ms
    accuracy_decimals: 0
    topic: tinygs-servo/sleep_mode_time
    on_value:
      then:
       - lambda: |-
          id(deep_sleep_1).set_sleep_duration(id(custom_sleep_time_tinygs_servo).state);

  - platform: ina3221
    address: 0x40
    update_interval: 0.5s
    channel_1:
      shunt_resistance: 0.1 ohm
      current:
        unit_of_measurement: "mA"  
        name: "TinyGS LORA Current"  
        filters:
          - multiply: 1000
          - median:
              window_size: 5
              send_every: 4
              send_first_at: 3
      bus_voltage:
        name: "TinyGS Lora bus Voltage"          
    channel_3:
      shunt_resistance: 0.1 ohm
      current:
        unit_of_measurement: "mA"
        name: "TinyGS Servo Current"   
        filters:
          - multiply: 1000    
          - median:
              window_size: 5
              send_every: 4
              send_first_at: 3           
      bus_voltage:
        name: "TinyGS Servo bus Voltage"
        filters:
          - median:
              window_size: 5
              send_every: 4
              send_first_at: 3
                  

mqtt:
  broker: 192.168.81.155
  username: redacted
  password: redacted
  birth_message:
    topic: tinygs-servo/available_mode
    payload: 'online'
  will_message:
    topic: tinygs-servo/available_mode2
    payload: 'OFF'
  discovery: true
  discovery_retain: true   
  on_message:
    - topic: tinygs-servo/ota_mode
      payload: 'ON'
      then:
        - logger.log: 'OTA Mode ON - Deep sleep DISABLED'
        - deep_sleep.prevent: deep_sleep_1
    - topic: tinygs-servo/sleepearly
      payload: 'ON'
      then:
        - deep_sleep.enter: deep_sleep_1   

 

deep_sleep:
  id: deep_sleep_1
  run_duration: 15s
  sleep_duration: 10min

This is the esphome yaml.

You can see my sat packets over last 3 weeks. You can see several days from 21st with no hits. This was due to a poor ground connection in the soldering that prevented switch turning on/off the ESP32.


Even with no sunshine over several days you can see small drop in voltage across ESP32 Battery.

5 Likes