[SOLVED] Error in python script

How can I fix this?

                    params = urllib.urlencode({'field1': temp, 'key':'O20UQUFXLGCGY7FJ'})     # use your API key generated in the thingspeak channels for the value of 'key'

Here my script. Please fix it for me…

Hey Yapkoloi,

I’d like to give you a gentle nudge to read the directions. We have a great example for using Thingspeak here: http://www.dexterindustries.com/BrickPi/projects/thingspeak-temperature-log/

Some of the first directions are to setup a thingspeak account, and to put your credentials in. That’s what you’re doing on that first line. We have some great pictures on the tutorial to walk you through that process.



Hi John,

I already follow the instruction at dexterindustries.com and tutorial at instructable. I also already setup teamspeak.com and apply it’s API key.Now the problem is at the python script. That’s why I’m asking you at here. Understand? I out of my mind now… Please help me…


So it seems that the error you’re getting in picture 1 is just an indentation error. The original is spaced out with spaces, not tabs. You can either correct yours by just deleting the white space on the line that’s throwing an error and replacing it with spaces.

I’ve just updated the example to have correct white spacing. You can also re-download the script and put your thingspeak credentials in again. https://github.com/DexterInd/BrickPi_Python/tree/master/Project_Examples/Thingspeak%20Temperature%20Logging

Hi John,

I still got the error even after delete the space and add the space back. I don’t know what to do now…

Did you try to download the script I reloaded to github?

Hi John,

I have try and I got the result. Thank you very much John… :slight_smile:


Glad we got this figured out. I wish I could explain more to you about the whitespace though, it’s really critical to understand to be able to program in Python.


I don’t have knowledge in python but to solve this, I try to understand how it run and I still just don’t get it. By the way, thank you very much John. And I would like to ask something how to make the python script run automatically when we turn ON the Pi?