I am trying to measure temperature inside my cabinet

def fifteen_sec_updates():

'''These are the things to do once every 15 seconds'''

global cont

#to_modem = cont

to_modem = {key:cont[key] for key in ['pressure','runcycles','faults','mode']}
    
print('*** Modem - Sending: {}'.format(to_modem))


    ### Output for blues modem

try:

    req = {"req" :"note.add"}
    req["file"] = "vstdata.qo"
    req["sync"] = True
    req["body"] = to_modem

    rsp = card.Transaction(req)

    print(rsp)
    
    #  Get Board Tempoerature
    
    req = {"req": "card.temp"}
    req["sync"] = True
    rsp = card.Transaction(req)


except:
    
    print('No response from modem.  Will keep trying...')

I expected to see results in my events for temperature, but I do not. What am I doing wrong?

Hey @vstadmin a few questions:

What does the output look like when you run this? Do you have an except block for that try and if so, what does it look like?

I haven’t actually tried to read the rsp and do anything with it. My system is a HMI-operated machine controller that doesn’t have a command line output while the HMI is running. I was going write something to attempt and extract the temp from the rsp, but I expected an event to popup in the event on notehub.io.

Understood. I suspect that there’s an exception here that’s being swallowed by the try block. So I can try to repro, what are the contents of global cont and where is that set.

One idea you can try is to add an except block under your try and send that to the Notecard to at least get a “remote” debug view while you’re trying to run the issue down. Example:

try:
  # contents of your try block above
except Exception as e: 
  req = {"req" :"note.add"}
  req["file"] = "error.qo"
  req["sync"] = True
  req["body"] = {"message": e}

   card.Transaction(req)

I actually think I figured it out. I just expected that request to automatically send data to notehub. I assume that it does not since its talking directly the modem.

I’m getting the answer down in the corner of the HMI now.
I’m still clamoring through he API and documentation everyday while trying to improve my use of python. Sometimes what I expect to happen isn’t exactly what does happen.

1 Like

Glad to hear it @vstadmin. And if you run into any other issues or questions, we’re here to help.