Post Tweets With Your Raspberry Pi

Raspberry Pi is famous for its great computing strength and ability to run the Linux operating system. In today’s tutorial, you’ll learn how to make your Raspberry Pi tweet. You can add extra features to this project to post tweets autonomously if any specific event occurs. Let’s get started.

Required Parts

You’ll need following parts to make this project.

  • Raspberry Pi running Raspbian OS (Any model)
  • USB Mouse
  • USB Keyboard
  • HDMI Compatible Monitor
  • HDMI Cable
  • USB power supply for Raspberry (5V 2A)
  • Working Internet Connection

Create App In Twitter

You need to create an app in Twitter so that Raspberry Pi can use to make tweets on your behalf. Go here to make a twitter app. The Raspberry Pi will require following parameters to make tweets:

  • Consumer Key (API Key)
  • Consumer Secret (API Secret)
  • Access Token
  • Access Token Secret

You can find all these details from your app.

Creating An App In Twitter
Creating An App In Twitter

Store Keys In Raspberry Pi

In this step, you need to create a python file in your Raspberry Pi and store all the Keys and Tokens there. Create a file named keys.py in your working folder with all information in it.

consumer_key = "Place your consumer key here"
consumer_secret = "Place your consumer secret key here"
access_token = "Place the access token here"
access_token_secret = "place the access token secret here"
Get Access Keys And Access Tokens From App
Get Access Keys And Access Tokens From App

Now, save the file and go the nex step of this tutorial.

Install Twython

Well, what is Twython actually? Twython is the premier Python library providing an easy way to access the Twitter data. It’s been tested by companies, educational institutions and individuals alike. This amazing library will make our job a lot easier and the code much shorter. To install the Twython library, follow the given steps:

 sudo apt-get update sudo apt-get upgrade
 sudo apt-get install python-setuptools
 sudo easy_install pip
 sudo pip install twython
 sudo pip install requests
 sudo pip install requests-oauthlib

pip is required to install Twython, so it’s installed in 3rd step. But if you already have pip installed, just ignore that step.

Write The Python Script & Run It

Open a file in your working directory in your Raspberry Pi and rename it to twitter.py. Make sure that it is in the same directory wit previously created keys.py file. Now, copy-paste the following code using any editor or IDE:

import sys

from twython import Twython
from keys import (
 consumer_key,
 consumer_secret,
 access_token,
 access_token_secret
)
twitter = Twython(
 consumer_key,
 consumer_secret,
 access_token,
 access_token_secret
)
message = "My first tweet using Rapberry Pi! Yeh!"
twitter.update_status(status=message)
print("Raspberry Pi successfully tweeted: %s " % message)

Pretty simple, isn’t it? Actually, the Twython library performs lots of tasks behind the screen keeping the code surprisingly small.

Now, save the file and open terminal in your raspberry pi. Write the following command and hit the Enter key to run this Python script:

python twitter.py

That’s all. Now you can see that is your Raspberry Pi is tweeting successfully.

A Brief Introduction to CE Mark on Products

When you flip any electronic device (your TV screen, laptop, power supply, computer mouse, …etc) you will see lots of marks. These marks are conformity marking for certain quality and technical standards such as: CE, FCC and UL. Today we are going to investigate more about the CE mark.

CE Mark. Image Courtesy of EEVBlog

What is CE?

CE is a mandatory conformity marking for certain products sold within the EU and Turkish market. The mark means that the manufacturer declares that the product meets the requirements of EU products rules. As the formal documents say, this mark is a key indicator but not a proof of a product’s compliance with EU legislation and it enables the free movement of products within the EEA and Turkish market.

How to get CE certificate?

It can be self-certified by a manufacturer by following some directives according to the type of your product. For example, if your product is designed to be used with a voltage rating of between 50 and 1000 V for alternating current (A.C.) and between 75 and 1500 V for direct current (D.C.), then you must meet the Low Voltage Directive.

Every Directive has a number of requirements that the product needs to meet. However, The manufacture should prepare the Declaration of Conformity which is a document states that the product meets the requirements of the directive(s) which apply to it. More steps are required to self-certificate your product. To know more about the full procedure refer to this Wikipedia article. Another option is to pay for a third party certification body to do all the process for you.

Test Report(on the left)-Certificate of Compliance (on the right). Image Courtesy of EEVBlog

Dаvid Jones, EEVBlog, did a short video with lots of important notes about the CE mark that worth watching. He also mentioned how some manufactures use Chinese Export mark instead of original CE mark to deceive consumers.

 

Plug And Debug With ScanaQuad SQ200 Logic Analyzer and Signal Generator

The ScanaQuad 200 by Ikalogic is a high-performance 4-channel logic analyzer and digital pattern generator. It is designed to be the best companion of a hobbyist when working on serial protocols like UART, SPI, I2C, 1-Wire, USB, I2S, CAN, LIN, RS232, RS485, and more. With the ScanaQuad 200 Logic Analyzer, you can capture signals, you can play them back, and you can even program genuine test signals using ScanaStudio software and generate them.

Connecting ScannaSquad with PC to analyze signal
Connecting ScanaQuad with PC to analyze signal

Being able to capture and generate logic patterns simultaneously with a single tool, it is quite useful while testing and debugging logic signals. Now, you can achieve these same features with modern function generators and oscilloscopes. But unfortunately, these devices usually carries a price that puts them out of reach of those who only need them occasionally. So, the ScanaQuad is the best and the cheapest solution for hobbyists.

The sampling frequency of the ScanaQuad SQ200 is minimum 10KHz and maximum 200MHz, with 50MHz of input bandwidth. It has a stunning sampling resolution of ±5ns only. SQ200 is capable of handling ±15V input signal in continuous signal mode and the ±50V input signal in 10ms pulse mode.  The function of the four ports of this logic analyzer can be defined by the user with the help of the ScanaStudio software. The user can also control pulse width and duty cycle of the output signal. Complex data sequences may be programmed to simulate several communication protocols using JavaScript. ScanaQuad SQ200 comes with predefined sets of various protocol decoders. This logic analyzer even allows users to create their own protocol decoders.

The following table shows the input characteristics of SQ200:

Input resistance (Fixed) 1MΩ
Input resistance (optional) 10KΩ
Input Capacitance (Max.) 4pF
Input voltage range (continuous) ±15V
Input voltage range (10ms pulse) ±50V
Pull-Up resistance (optional) 10KΩ
Low-Level input voltage (VIL MAX) Adjustable
High-Level input voltage (VIL MIN) Adjustable
Adjustable threshold range 0V to 4.5V
Threshold hysteresis 350mV

The following table represents output characteristics:

Output resistance 270Ω
Output current (Max.) 20mA
Output High-Level voltage (VOH) Adjustable
Adjustable output voltage range (VOH) 1.65V to 5.5V

Finally, the below table shows all the timing characteristics:

Sampling Frequency (Max.) 200MHz
Sampling Resolution (Max.) ±5ns
Input bandwidth (Max.) 50MHz
Output frequency (Max.) 50MHz
Sampling Frequency (Min.) 10KHz
Embedded memory 16MB
Sampling Depth (Points/channel) 4M
Sampling Period (Max. at FS = 1MHz) 4s
Sampling Period (Max. at FS = 25MHz 160ms
Sampling Period Example (Max. no. of 115200 BAUD UART words at FS = 1MHz) 40K Words
SqannaStudio software shows analyzed signal
SqannaStudio software shows analyzed signal

ScanaQuad SQ200 supports lots of protocols by default and user can add his/her own protocol as mentioned earlier. Supported protocols (default) are:

  • 1-Wire
  • CAN
  • DHT11/22
  • DMX-512
  • HC-SR04
  • I²C
  • I²S
  • JTAG
  • LCD at 4 bits
  • LIN
  • Manchester
  • Maple
  • MIDI
  • NMEA 0183
  • nRF24L01
  • Oregon Scientific
  • Parallel Bus
  • PWM
  • SENT
  • SPI
  • SPI WIZnet W5100
  • UART
  • USB 1.1

The SQ200 has a really tiny form factor of 50mm × 50mm with a 7.5mm of thickness. As it weighs only 80g, you can carry it easily in your pocket without any problem. You can purchase this amazing product from the official site of IkaLogic at 149€ and change the way you debug and analyze signals.

Opendime v2 – Genuine Verified Bitcoin Credit Stick

Opendime announced their USB stick that allows you to spend Bitcoin like a dollar bill:

Opendime is a small USB stick that allows you to spend Bitcoin like a dollar bill. Pass it along multiple times. Connect to any USB to check balance. Unseal anytime to spend online.

Hopefully everyone who needed an Opendime for Christmas has got it under the tree already, because we are now out of stock! But the big news is we’ve redesigned the hardware and improved it. Same price, same concept, but some useful improvements.

Opendime v2 – Now Genuine Verified Bitcoin Credit Stick – [Link]

42 of the Most Useful Raspberry Pi Commands

circuitbasics.com has posted an article about the most usefull Raspberry Pi commands:

Sometimes it’s hard to keep track of all the Raspberry Pi commands you use, so I created a list of some of the most useful and important ones that will make using Linux on the Raspberry Pi a lot easier. But first a quick note about user privileges…

42 of the Most Useful Raspberry Pi Commands – [Link]

3.5A Unipolar Stepper Motor Driver

Compact Unipolar stepper motor driver can drive unipolar motor up to 3.5A and supply range 10 To 50V DC. This compact board is based on STK672-440BN IC from ON semiconductor. The STK672-440BN is a hybrid IC for use as a unipolar, 2-phase stepper motor driver with PWM current control with Micro-stepping.

Note: This Board can work with motor supply up to 36V DC, for 50V DC Supply Remove IC U2 LM317, and provide 5V Logic supply from external source. Default Enable pin is High for normal operations, pull down 0 to disable the operations, for internal Power on Reset R7 is 0E , C4 can be omit or its fine as it is.

3.5A Unipolar Stepper Motor Driver – [Link]

NetWorker – an advanced web server with PIC18F67J60

rs-online.com have published an advanced webserver project based on PIC18F67J60 microcontroller.

An Internet connection would be a valuable addition to many projects, but often designers are put off by the complexities involved. The ‘NetWorker’, which consists of a small printed circuit board, a free software library and a ready-to-use microcontroller-based web server, solves these problems and allows beginners to add Internet connectivity to their projects. More experienced users will benefit from features such as SPI communications, power over Ethernet (PoE) and more.

NetWorker – an advanced web server with a microcrontroller – [Link]

Isolated 24V to 12V 10W Flyback Power Supply

maximintegrated.com power supply experts have a reference design of a 24V to 12V flyback converter.

Maxim’s power supply experts have designed and built a series of isolated, industrial power-supply reference designs. Each of these power supplies efficiently converts 24V into useful voltage rails at a variety of power levels. Every power rail is isolated with a readily available transformer from multiple, global vendors, providing for quick, convenient transformer selection. Each design has been tested for load and line regulation, as well as efficiency and transient performance. As with all Maxim reference designs, the BOM, schematics, layout files, and Gerber files are all available. In addition, boards are available for purchase; most boards feature through-hole pins for immediate board placement and accelerated prototyping.

Isolated 24V to 12V 10W Flyback Power Supply – [Link]

ATtiny85 Tiny OLED Watch

An ATtiny85 and a 64×48 OLED display hand clock:

This is the third in my series of minimalist watches based on the ATtiny85. This version displays the time by drawing an analogue watch face on a miniature 64×48 OLED display. It uses a separate crystal-controlled low-power RTC chip to keep time to within a few seconds a month, and puts the processor and display to sleep when not showing the time to give a battery life of over a year.

ATtiny85 Tiny OLED Watch – [Link]

RELATED POSTS

Getting started with Python and Arduino MKR1000 for secure IoT projects

A getting start guide to program Arduino MKR1000 in Python:

The MKR1000 is described as a powerful board that combines the functionality of an Arduino Zero (already supported by Zerynth) and the connectivity of a Wi-Fi Shield, with a Cryptochip for secure communication. The design also includes a Li-Po charging circuit that allows the Arduino MKR1000 to run on battery power or external 5V, charging the Li-Po battery while running on external power.

Getting started with Python and Arduino MKR1000 for secure IoT projects – [Link]