# Protocol Documentation

**URL:** <https://community.fieldkit.org/t/protocol-documentation/109>\
**Category:** Main Community Hub\
**Created:** [May 21, 2021, 1:09pm UTC](https://community.fieldkit.org/t/protocol-documentation/109 "2021-05-21T13:09:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sara](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.fieldkit.org/sara/32/42_2.png) [@Sara](https://community.fieldkit.org/u/Sara)\
**Post date:** [May 21, 2021, 1:09pm UTC](https://community.fieldkit.org/t/protocol-documentation/109/1 "2021-05-21T13:09:32Z")

</div>

@jlewallen Is there some documentation on the protocol to access the hardware using network sockets? I could dig around in the github codes but it may be quicker if I could have a few pointers on where to look!

@shashikiran.ganesh

---

<div class="post-metadata">

**Author:** ![jlewallen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.fieldkit.org/jlewallen/32/15_2.png) [@jlewallen](https://community.fieldkit.org/u/jlewallen)\
**Post date:** [May 21, 2021, 5:41pm UTC](https://community.fieldkit.org/t/protocol-documentation/109/2 "2021-05-21T17:41:15Z")

</div>

Hey there!

Unfortunately, documentation isn’t something I’ve got a lot of bandwidth for but I can definitely help to point out some resources for anybody feeling adventurous.

FieldKit uses Google’s Protocol Buffers to encode/decode to define the structure of its various messages and saved data.

[GitHub - fieldkit/app-protocol: protocol buffers for hardware communications, primarily used by the mobile app.](https://github.com/fieldkit/app-protocol) This repository contains the schema for communicating with the stations over WiFi. Stations create a web server that has various endpoints. It’s a good resource for seeing the kinds of things you can ask of stations, as well as the source code for the HTTP routing itself on the stations:

> <https://github.com/fieldkit/firmware/blob/main/fk/networking/default_routes.h>

[GitHub - fieldkit/fkc](https://github.com/fieldkit/fkc) This is a `golang` client that can be run on a desktop and used to communicate with stations. Querying status, live readings, etc… You can also use `curl` to download data off of them.

[GitHub - fieldkit/data-protocol: protocol buffers for stored/logged data and information.](https://github.com/fieldkit/data-protocol) This repository contains the schema for persisted data. Any data you download off the device will have these messages.

I hope this is enough to get started!

Jacob

---

<div class="post-metadata">

**Author:** ![shashikiran.ganesh](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.fieldkit.org/shashikiran.ganesh/32/76_2.png) [@shashikiran.ganesh](https://community.fieldkit.org/u/shashikiran.ganesh)\
**Post date:** [May 22, 2021, 5:26am UTC](https://community.fieldkit.org/t/protocol-documentation/109/3 "2021-05-22T05:26:22Z")

</div>

Thanks @jlewallen  
This is good to start with. I’ll post here if any further queries.

Regards,  
Shashi

---

<div class="post-metadata">

**Author:** ![shashikiran.ganesh](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.fieldkit.org/shashikiran.ganesh/32/76_2.png) [@shashikiran.ganesh](https://community.fieldkit.org/u/shashikiran.ganesh)\
**Post date:** [May 22, 2021, 2:31pm UTC](https://community.fieldkit.org/t/protocol-documentation/109/4 "2021-05-22T14:31:55Z")

</div>

> [@jlewallen](#):
>
> [GitHub - fieldkit/fkc](https://github.com/fieldkit/fkc) This is a `golang` client that can be run on a desktop and used to communicate with stations. Querying status, live readings, etc… You can also use `curl` to download data off of them.

fkc worked well. I could get the live readings. Now, I have to work out a shell script to read the weather parameters.

I could read the binary data file directly using http:///fk/v1/download/data but have to understand the format.

Looks like a good start though!  
Thanks,  
Shashi

---

<div class="post-metadata">

**Author:** ![shashikiran.ganesh](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.fieldkit.org/shashikiran.ganesh/32/76_2.png) [@shashikiran.ganesh](https://community.fieldkit.org/u/shashikiran.ganesh)\
**Post date:** [November 20, 2021, 2:53am UTC](https://community.fieldkit.org/t/protocol-documentation/109/5 "2021-11-20T02:53:14Z")

</div>

Hi,  
I worked out the following script to run as a cron job on a raspberry pi. It appends readings to a file in the format:  
YYYYMMDD HH:mm:ss humidity temp1 pressure rain windspeed wind\_dir

I had initially connected the FieldKit station to my desktop via my home wifi router. Seemed to be working fine except that it would lose connection once in a while. After making the FK as an AP and using a raspberry pi to access the data it is better.

* * *

#!/bin/bash  
. /home/pi/.bashrc

/usr/local/bin/fkc --address 192.168.2.1 -get 2\>&1 \> /dev/null | awk -v d="`date '+%Y%m%d%H%M%S'`" ‘BEGIN{print d," \n { \n"}{if (NR \> 5) print $0}END{print “\r\n”}’ | awk ‘{if (NR \> 1) print $0}’ | jq ‘.liveReadings[0].modules[1].readings[0,1,2,4,5,6].value’ | tr -s ‘\n’ ‘\t’ |awk -v d="`date '+%Y%m%d %H:%M:%S'`" ‘{print d,$0}’ \>\> /home/pi/Instruments/FieldKit/sensor\_data\_fk.log

* * *

Planning to take the setup to our observatory now for deployment. Fingers crossed that I wouldn’t have issues there.  
Thanks,  
Shashi

---

<div class="post-metadata">

**Author:** ![lindsaystarke](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.fieldkit.org/lindsaystarke/32/8_2.png) [@lindsaystarke](https://community.fieldkit.org/u/lindsaystarke)\
**Post date:** [November 23, 2021, 2:02pm UTC](https://community.fieldkit.org/t/protocol-documentation/109/6 "2021-11-23T14:02:17Z")

</div>

Very cool! Please report back if you are able.

---

<div class="post-metadata">

**Author:** ![shashikiran.ganesh](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.fieldkit.org/shashikiran.ganesh/32/76_2.png) [@shashikiran.ganesh](https://community.fieldkit.org/u/shashikiran.ganesh)\
**Post date:** [December 29, 2021, 9:43am UTC](https://community.fieldkit.org/t/protocol-documentation/109/7 "2021-12-29T09:43:40Z")

</div>

Hi,

Since last few days my station is not responding to the fkc commands. I had someone remotely restart the system but the problem persists.

```auto
pi@raspberrypi:~ $ fkc -address 192.168.2.1 -status
2021/12/29 15:07:21 Sending: {
  "type": 18,
  "time": 1640770641
}
[33 68 79 67 84 89 80 69 32 104 116 109 108 32 80 85 66 76 73 67 32 34 45 47 47 87 51 67 47 47 68 84 68 32 72 84 77 76 32 52 46 48 49 47 47 69 78 34 32 34 104 116 116 112 58 47 47 119 119 119]
2021/12/29 15:08:21 error: proto: cannot parse invalid wire-format data
pi@raspberrypi:~ $ 

```

I am able to connect to the system on [HTTP://192.168.2.1/](HTTP://192.168.2.1/) and am connected to the station with the station as the access-point. I would be able to connect to the system via mobile app only sometime next month when I plan to visit the observatory. Till then any debugging would have to be via remote communication. Any suggestions @jlewallen@Sara ?

Season’s greetings and happy holidays!  
Shashi

---

<div class="post-metadata">

**Author:** ![Sara](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.fieldkit.org/sara/32/42_2.png) [@Sara](https://community.fieldkit.org/u/Sara)\
**Post date:** [December 29, 2021, 9:56am UTC](https://community.fieldkit.org/t/protocol-documentation/109/8 "2021-12-29T09:56:58Z")

</div>

Hello Shashi!

Do you have an SD card in your station? If so, can you please send the contents of the card in a zip file to me?

Thank you and happiest holidays!

Sara
