Viewing Data on Hologram Network (a newbie question)

So I managed to connect to Hologram (sometimes the modem does it over Verizon and most of the time with AT&T Mobility, which I had no slightest idea that it exists on the west coast (US).

I also managed to send the data from my sensors and I can see on the Dashboard that there was a data transmission…

…but I can’t find how to see that data - the data was in a string format…separated by “\n”.
I thought it somewhere on the Dashboard but I can’t find it, or may be I need now to write an app and call APIs in order to retrieve and display the data (that would be kinda counter intuitive)

Click on the bar at the bottom of the dashboard where it says “All Activity”

So when I click All Activity I am presented with this view - some are messages and some are trigger items. On the right there is a button “View Raw”. When I click on the button I see raw JSON data where I presume the field ‘data’ contains the actual data/message that I sent in base64-encoded form (?). Is there any documentation how to extract the actual data (decode base64? any APIs?)

EDIT: I see that there are all kind of APIs, but what do use exactly to retrieve my data in readable form?

BTW, when I click on All Activity and then on View Raw I do not see the data I just sent minutes ago, only the old one. However, my MicroPython script executes without errors on the client side…I am not sure what to think about it.
I see that Hologram correctly reports that I connected just a minutes ago but All Activity shows only data from days ago…

Is it a bug in Hologram?
My goal is to see the actual data from now in JSON and then being able to retrieve it with API or visualize it on Hologram - and I did not achieve it in the last few days…Can you please assist?

This is the code I use to send data. I do not see the data on Hologram. What am I doing wrong?
The DEVICE_KEY is the Device Key that I found in the Webhook by clicking Create Device Key

print(“Disable MicroPython control and heartbeat of LED”)

pycom.heartbeat(False)
blinkThread = _thread.start_new_thread(blinkForever, (BLUE,))

#Need to use global variables.
#If in each function you delare a new reference, functionality is broken
lte = LTE()
rtc = RTC()
message = “”

lte = getLTE()

HOST = “cloudsocket.hologram.io
PORT = 9999
DEVICE_KEY = “XXXXXXXX”
TOPIC = “ENVTOPIC”

blinkLock.acquire(1)
colorToBlink = WHITE
blinkLock.release()

idx = 0

try:
#print(“Initially, the RTC is {}”.format(“set” if rtc.synced() else “unset”))

lteSocket = socket.socket()
lteSocket.setblocking(True)
print(lteSocket)
dns_records = socket.getaddrinfo(HOST, PORT)
print("got dns_records:")
print(dns_records)

dns_record = dns_records[0][-1]
print("DNS Record: {}".format(dns_record))
lteSocket.connect(dns_record)
print("==== LTE Socket connected")

while (idx < 1):

    print("@@@@@@@@@@@@@@@@@@@@ Transmission #: {}".format(idx))
    #print("Local Time: {}".format(utime.localtime())

    message = CreatePayload()

    #for record in dns_records:
    try:
        data = '{"k": "%s", "d": "%s", "t": "%s"}' % (DEVICE_KEY, message, TOPIC)
        lteSocket.send(bytes(data, 'ascii'))
        time.sleep(1)

        print("==== LTE Socket data sent")
        result = lteSocket.recv(8).decode()
        print("LTE Socket result received: "+result)
    except Exception as err1:
            print("LTE Socket exception: {}".format(err1))
            break
    
    idx += 1

    time.sleep(5)

lteSocket.close()               
print("LTE Socket closed.")

except Exception:
print(“Exception displaying data…”)

finally:
endLTE()

blinkLock.acquire(1)
colorToBlink = None
blinkLock.release()

print("Enable MicroPython control and heartbeat of LED")
pycom.heartbeat(True)

This is the API call to view them, but it should show the same data as what is on the dashboard: Hologram · Apiary

Sometimes it can take 10-20 seconds for the dashboard to refresh that view of the messages so that might be part of the issue.

It does look like you’re sending correctly. What result gets printed by the program?

This is not a matter of 10-20 seconds delay in data display - my data is not there even after 5 minutes not at all…
Here is program printout of the payload that I send. I concatenate all of the lines below into one string and assign message variable to it. Based on the examples that I have seen, when using sockets it does not look that I need to put the payload in a JSON format… And yet, something is not right 'cause I don’t get data in the Hologram…
MPL3115A2 temperature: 22.3125
Altitude: 43.75
Pressure: 100807.2
Temperature: 23.63535 deg C and Relative Humidity: 54.16922 %RH
Dew point: 13.84534 deg C
Humidity Ambient for 24.4 deg C is 51.79968%RH
Light (channel Blue lux, channel Red lux): (219, 292)
Acceleration: (-0.02111816, -0.01733398, 1.006348)
Roll: 1.202173
Battery voltage: 4.686702

EDIT:
I just tried to replace my payload by a simple string “My test message 1” and it went through just fine and I can see it in Hologram. So something in my original message Hologram does not like…I wonder if it’s size…Is there any restriction Hologram imposes on the payload size, or may be characters of the message like line feeds ("\n") ?

What ends up being printed by this line of code?

You probably aren’t properly encoding that payload into JSON format. Instead of the newline character \n for example, you would need that encoded as the string “\n”

Can you use the normal python json library in micropython?

If so, then this is very simple. Make a dict with everything you need instead of filling in a string and then call json.dumps(yourdict)

For example you could do yourdict = {"k":device_key, "d":message, "t":topic} and then encode that as JSON

BTW, in my code:

data = '{"k": "%s", "d": "%s", "t": "%s"}' % (DEVICE_KEY, message, TOPIC)
        lteSocket.send(bytes(data, 'ascii'))

I tried a few things and here what I get:
if my message is

idx = 0
message = "Test message {} line 1".format(idx) + "\n" + "Test message {} line 2".format(idx) 

then it does NOT go through…
But if I remove “\n” then it shows up in Hologram…

BTW, I had no idea that I need to encode the message as JSON when I am using sockets… I am not familiar with JSON MicroPython library (I mostly code in C# and hope that MycoPython has one too) - I will look it up shortly.

EDIT:
Well, I did not pay attention that ‘{“k”: “%s”, “d”: “%s”, “t”: “%s”}’ is actually JSON representation…
At any rate, Hologram or its json parser, or whatever, does not like “\n”.
So I replaced “\n” in my original payload with “@@” (just so I can parse easily later) and the message shows up in Hologram !

MPL3115A2 temperature: 28.75@@Altitude: 47.125@@Pressure: 100764.3@@Temperature: 
31.52901 deg C and Relative Humidity: 37.23197 %RH@@Dew point: 15.19971 deg 
C@@Humidity Ambient for 24.4 deg C is 56.67257%RH@@Light (channel Blue lux, channel Red 
lux): (222, 303)@@Acceleration: (-0.01379395, -0.01525879, 1.003052)@@Roll: 
0.7878806@@Pitch: 1.012411@@Battery voltage: 4.62147

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.