FiPy final step of sending data


#1

Hi everyone,

This is my first post on here, so I apologize if I don’t include all of the required information. I am currently putting a Pycom FiPy on to the network. I have succeeded in connecting thanks to the help of this wonderful thread: https://forum.pycom.io/topic/3021/gpy-with-hologram-io-sim/97

I am currently stuck trying to figure out the required code to go from the working example code:

s = socket.socket()
s = ssl.wrap_socket(s)
s.connect(socket.getaddrinfo('www.google.com', 443)[0][-1])
s.send(b"GET / HTTP/1.0\r\n\r\n")
print(s.recv(4096))
s.close()

To actually sending sensor data I am producing to the data engine/dashboard. This is my current code and it is throwing and error on the s.connect

    s = socket.socket()
    s = ssl.wrap_socket(s)
    s.connect(socket.getaddrinfo('cloudsocket.hologram.io', 9999)[0][-1])
    s.send(sensortemp2) 

This is probably a fairly simple problem, so hopefully this should be resolved quickly. Thank you.


#2

A few things:

  1. I am not super familiar with the pycom coding, but it looks like you are trying to use ssl to connect to the cloudsocket (line s = ssl.wrap_socket(s)). The hologram cloud socket does not use any encryption so don’t use that line. That is probably the reason you are failing to connect.

  2. What is the value of sensortemp2? Hologram’s cloud socket expects a json string with required fields “k” or “devicekey” and “d” or “data”. For example:

{"k":"ABCDWXYZ","d":"Hello, World!","t":"TOPIC1"}

See https://hologram.io/docs/reference/cloud/embedded/

If “sensortemp” is not a json string like above, then you will get an error. Note you will need the device key specific to your simcard in place of “ABCDWXYZ”. You can find this by going to the hologram dashboard, opening the page for the specific simcard and in the upper right click on the blue “DEVICE KEY”

Hope that helps


#3

I will test this over the remainder of the week and see if I can get it working! Thank you!


#4

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