0

Hello guys im having a problem sending a value to firebase

here's the code that i use

import obd

connection = obd.OBD("/dev/ttyAMA0")

while True:

    cmd1 = obd.commands.RPM 
    response1 = connection.query(cmd1)
    print(response1.value)

    cmd2 = obd.commands.SPEED 
    response2 = connection.query(cmd2)
    print(response2.value)

    cmd3 = obd.commands.SPEED 
    response3 = connection.query(cmd3)
    print(response3.value)

and it works enter image description here

but when i connect it to the firebase

from firebase import firebase
import obd

FBConn = firebase.FirebaseApplication('https://microbittempreader.firebaseio.com/', None)
connection = obd.OBD("/dev/ttyAMA0")

while True:

    cmd1 = obd.commands.RPM 
    response1 = connection.query(cmd1)

    cmd2 = obd.commands.SPEED 
    response2 = connection.query(cmd2)

    cmd3 = obd.commands.SPEED 
    response3 = connection.query(cmd3)

    data_to_upload = {
            'Engine RPM' : response1.value,
        'Vehicle Speed' : response2.value,
        'Engine_Load' : response3.value
        }

    result = FBConn.post('/MyTestData/',data_to_upload)

    print(result)

error: OBDresponse is not serialized

  • The datas dictionary must understand the type of response1.value, response2.value, response3.value i think, try : str(response1.value) and optionaly use urlencoding. I don't see any int() or float() value here – Ephemeral Dec 8 '19 at 9:18
  • Please don't post pictures of text. Instead paste the text direct into the question. – Ingo Dec 11 '19 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.