Linked Questions

Popular Questions

Using cURL command in Python script

Asked by At

I'm working on VOC system and I send and receive data of SGP30 sensor over RFM69HCW modules. I run my script on Raspberry but we want to send data from our script to server via cURL command. We will use HTTPS POST and I've been searching a lot about cURL commands but I would like to know if there's any way to implement cURL command into my Python script. We want to send VOC and CO variables to our server that all for now.

Here's my script:

import serial
import time
import select
import sys
from datetime import datetime

serialport = serial.Serial("/dev/ttyAMA0", 115200, timeout=0.5)
d = str('%d-%m-%Y_%H-%M-%S'))
out = open('podatki'+d+'.txt', 'w')

out.write("MERITVE VOC SISTEMA\nDatum meritev: %s\n" %(str('%d-%m-%Y'))))
        while True:
                inp, outp, err =[sys.stdin, serialport], [], [], .2)
                print "-"
                if serialport in inp:
                        line = serialport.readline().split(";")
                        print line
                        print line[3]+";"+line[4]
                        VOC = int(line[3])
                        CO= int(line [4])
                        out.write('%.0f\t%.0f\t%s\n' %(VOC,CO,str('%H:%M:%S'))))
except KeyboardInterrupt:
        print "/////////////////////////////////////"
        print "Zaprli ste program!"
        out.write("\n\nProgram se je ustavil: %s" %(str('%d-%m-%Y ob %H:%M:%S'))))

Ignore some parts of my script cause I'm making this for my company and we speak Slovenian language so that's why there are some words in my language in it. I hope that someone will help me and I will be really happy for any help that I'll get.

Thank you :)

Related Questions