How to read strings send from standard firmata in python

Greetings everone,
hope you are doing great.
I am using standard firmata library compiled to arudino uno to read string of the values of temperature and humidity of the sensor DHT11, I am using the below code that integrated the library with standard firmata. However, this code send string to python but I do not know how to read the values in python. any support is more than appreciated.
snipppets from the arudion code:

void loop()
  byte pin, analogPin;

  /* DIGITALREAD - as fast as possible, check for changes and output them to the
   * FTDI buffer using Serial.print()  */

  /* STREAMREAD - processing incoming messagse as soon as possible, while still
   * checking digital inputs.  */
  while (Firmata.available())

  // TODO - ensure that Stream buffer doesn't go over 60 bytes

  currentMillis = millis();
  if (currentMillis - previousMillis > samplingInterval) {
    previousMillis += samplingInterval;
    /* ANALOGREAD - do all analogReads() at the configured sampling interval */
    for (pin = 0; pin < TOTAL_PINS; pin++) {
      if (IS_PIN_ANALOG(pin) && Firmata.getPinMode(pin) == PIN_MODE_ANALOG) {
        analogPin = PIN_TO_ANALOG(pin);
        if (analogInputsToReport & (1 << analogPin)) {
          Firmata.sendAnalog(analogPin, analogRead(analogPin));
    // report i2c data for all device with read continuous mode enabled
    if (queryIndex > -1) {
      for (byte i = 0; i < queryIndex + 1; i++) {
        readAndReportData(query[i].addr, query[i].reg, query[i].bytes, query[i].stopTX);




so this function Firmata.sendAnalog(analogPin, analogRead(analogPin)); sends the value from arudion to python, how to read the value in python?
Thanks in advance

any suggestions ? I would appriciate even a little guidence to the right resouces to look at.

Can you show me an example of this string

Hi @sumguy I really do appriciate your kind response.
this is the function used in arudion IDE Firmata.sendString().
I do not know how to read the values sent from this function in arudino to python. as I want to read the values in python.
thank you

Hi @kdawoud91, I don't have much experience using the DHT11, but I think you are headed in the wrong direction.

If you are using firmata to interface with python using a library such as pyfirmata, you need to establish communication with the arduino through the python script also. This is done pretty simply, if you look up pyfirmata documentation it will be clear.

I am unsure if there is a particular library in python to correlate the values read from the DHT11 pins to actual temp/humidity values though.

What I think you may need to do is write a python program to read the signal from the DHT11, then pass those values to a function with maps the voltage/current read from the DHT11 to a curve.

Does that make sense?

thank you very much for your kind response. I have looked to the class
class pyfirmata.pyfirmata. Port (board , port_number , num_pins=8 ) in the doc, there is enable_reporting () function, I will see if using this function can help reading the values.
Thank you

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