No Twitter module for Sensor Twitter Example?

hi,

msy I know do I get the Twitter module into raspberry? it says no twitter module when I ran the python wifi_twit.py.

You will find all instructions here: https://www.dexterindustries.com/projects/sensors_to_twitter/ most notably step 6 talks about installing the Twitter module

Cleo

Like tzewei_79 I have the same problem. I followed the instructions including makeing the Sensor2Twitter folder (which seems unnecessary) and $sudo pip install python-twitter.
If I run as python wifi_twit.py I get AttributeError ‘Api’. If I run as python3 wifi_twit.py I still get ImportError: … ‘twitter’.

Hello @jhphelan
The reason for creating a Sensor2Twitter folder is that the original folder is read only if you’re using Raspbian for Robots.

Also if you want to use Python3, you will need to install with pip3
sudo pip3 install python-twitter

You will also need to run the code with sudo, unfortunately
sudo python3 wifi_twit.py

Hope this helps!
Cleo

ETA:
I’ve just tried
pip install python-twitter
followed by
python wifi-twit.py
and that worked for me. But you can’t install with sudo and run without, or vice versa.

I’m using R4R.
$ sudo pip3 install python-twitter seemed to work. I can also run from Idle-3 ok.
BUT now I get–
"Duplicate Tweet or Twitter Refusal: Third argument must be a list of at lease one, but not more than 32 integers."
I commented out the Twitter calls to eliminate that.
I seems to crash at:
grovepi.analogWrite(led,light_intensity/4)
I added a 3d argument but it didn’t like that either, saying there should only be 2.
I thought maybe it didn’t like a float from light_intensity/4.
I changed it to:
grovepi.analogWrite(led, int(light_intendity/4)) and it got past that.
Then it crashed on temp, humid being nan (Not a Number). Turns out the "Getting Started with the GrovePi+ Starter Kit user manual shows the DHT being plugged into A2 instead of D2 which, being a digital sensor is WRONG. [The user manual is fraught with errors and should be replace by a pdf download!] (The program has it right as D2).
Putting it in the right port still gives ‘nan’ errors. [This sensor is apparently NOTORIOUS for giving frequent out of range outputs.] I recall a nan trap from Home_Weather_Display.py and will (try to) adopt that. Eventually it may get out to Twitter!

Taking a cue from Home_Weather_Display.py I got temp & hum from sensor then t = str(temp) & h = str(hum) and posted %s %s for t and h.
Even w/o the nan trap this stopped the errors.
Removing the Twitter blocks I was FINALLY able to twit the data to my phone. Whew!

I noticed errors in three of six of the GrovePi+ projects in the starter kit…what to do? LED Fade states connect “Rotary encoder in Port A0” but the illustration has it connecting in A2 on my board. Button and Buzzer project states “Rotary to Port A0” but there isn’t a rotary on this project. The illustration has the button in D4 which is NOT mentioned in the verbiage. Ultrasonic and Relay project illustration shows Relay in D2 and Ultrasonic in D3 but the verbiage actually tells me to connect “Buzzer Module to Port D2, the Rotary to Port A0”! There is no buzzer or rotary in the Ultrasonic and Relay project. Help me please, I just want to get some straight answers. You haven’t made it easy to start.

Hey guys,

So I got my Sensors2Twitter project working, after having pretty much all the above issues.

Because I started the project using the old instructions and I was also using a Noobs version of Raspbian, then trying to fix it by installing other packages and out of frustration hunting any folders named twitter and deleting them(not recommended) to try then reinstall, i was not having much luck.

I eventually reflashed Raspbian for Robots to my sd card, followed these “Getting Started” instructions, followed by these “Sensor to Twitter” instructions.

It worked Yayy!!

I am currently trying to integrate ThingSpeak functionality into the project. I am not overly familiar with Python so still working on it. I will try to fork the project on GitHub and share if I get it going. Also the exception handling is not too helpful either so i may try to fix that, I had a space in one of my access tokens which could have easily been detected.

Also last thing, I originally had my Pi hooked up to and old monitor through HDMI. It is tremendously more responsive to work with the Pi through VNC.

Check out my project on twitter at @GroveZeppelin.

Thanks guys
Benn

Hey guys,

So I got my project working. I have also added Thingspeak functionallity, which is worth checking out if you are interested in IoT if you haven’t already.

I have posted my code to https://github.com/stopkickingtherobots/GrovePi_Twitter_Thingspeak.
Hope this helps a few people out.

Cheers
Benn

1 Like