Some time ago I was connecting DHT11 sensor to Arduino UNO and wrote a simple library based on the one from Arduino website.
At the moment I'd like to connect DHT11 to Intel Edison with Arduino Expansion Board running Yocto Linux. While trying to rewrite the library to Python I expected a problem with microseconds's sleeps in that language and finally decided to remake Raspberry Pi DHT11 Library using mraa. However, sensor isn't working as well. I found the topic on Intel forum blaming Edison ports fast IN/OUT switching inability. The proposed solution using two wires also didn't help me.
After this introduction, a few questions come to my mind:
Since both Raspberry and Edison are computer systems with real
processors and Linux (unlike the Arduino which consists of simple
microcontroller), why are people facing a problem with DHT11 on
Edison, while those who are using Raspberry aren't?
What is the source of those problems? Is it connected with
non-deterministic OS timing on Edison (RPi has the same, hasn't
it?), with digital pins flaw or both?
Is it even possible to solve this using two wires (alternatively
with a diode)? Maybe it's impossible without a suggested tri-state
buffer?
What is the simplest way to connect one-wire devices to Edison?
The 1-Wire protocol, as you know, requires deterministic timing.
It is not possible to do deterministic timing on a computing platform like Edison, or even a PC. You might get somewhere close to it using usleep() but your app may get interrupted at any time, thereby messing up your timings.
What you need to do when using a system without deterministic timing of GPIO is attach the sensor using an interface. That interface should use a small micro which DOES have deterministic timing. (ie a Pic, ATTINY, etc).
OR -
Use an existing peripheral on your system which does have deterministic timing, such as a UART.
I wrote a blog-post some years ago on how you can use a UART to do 1-Wire protocol. You should be able to find it here: http://wphost.spider-e.com/?p=231
Related
How can I set HIGH or LOW to a usb port connections using Python.
This could be used in come custom usb device.
For Example,
Consider I have a LED connected to the usb port(DATA Line) .
Now through the code I want to blink it or control it.
Now this can be easily achieved by using any micro controller, Arduino, Raspberry Pi
But I want to achieve this with with a normal computer and python.
[EDIT]
Can I achieve this by making a C or C++ API and make a wrapper to use it in Python. Is yes then what will be the best way to achieve it?
NOTE :
My main objective isn't just blinking some LED. I just gave it as an example.
I want to be able to directly control the USB ports.
Quoting : https://www.cmd-ltd.com/advice-centre/usb-chargers-and-power-modules/usb-and-power-module-product-help/usb-data-transfer-guide/#:~:text=How%20is%20data%20sent%20across,amounts%20known%20as%20'packets'.
Within the standard USB 2.0 connector you can see four metal strips. The outer two strips are the positive and ground of the power supply. The two central strips are dedicated to carrying data.
With the newer USB 3.0 connector, the data transfer speed is increased by the addition of extra data-carrying strips; four extra signalling wires help USB 3.0 achieve its super speed.
I want to set the values of the Data pins.
By my saying HIGH LOW please don't misunderstand that I want to set the value to +5V and GND. But I mean to control its value directly via my code without any external driver present in the computer.
I mentioned HIGH LOW to just make the language simple and so that it is easier to understand.
Controlling components like LEDs from devices like Arduino and Raspberry Pi are done using GPIO pins. In contrast, USB is designed for data transfer and not for maintaining more constant high or low signals like GPIO. It also consumes different voltage and current levels than GPIO pins and could potentially damage components meant for GPIO.
However, you can get USB to GPIO adapters for this purpose (see here for an example discussion on these options).
In terms of Python, you can use packages such as PyUSB or the libusb Python wrapper to control/transfer data/communicate with USB devices (such as the USB to GPIO adapters). The companies providing the adapters might also have designed their own easy-to-use Python package to wrap around a lower-level driver (probably written in C). See this USB controlled LED device as an example with its own Python driver. The drivers are just software programs that take in relatively simple commands from the user for what they want a device to do. They then encapsulate the lower-level complexities required for following a protocol to communicate the user's intention to the USB device and controlling the USB port at the lowest possible software level.
You cannot achieve that for several reasons:
The USB port has its own protocol of connection. Data is transmitted in packets with starting and ending bits. The negotiation and handshake process is done in the hardware layer between microchips. This process also selects the communication speed in the bidirectional data line. You have to direct access to the pin (like GPIO) to turn LEDs ON and Off or create your own connection protocol. This cannot be done in USB.
There are also voltage and current limitations. The data line is not +5 and GND. The data line is 2.8v for D+ and 0.3v for D- and both with respect to the GND. The data is transmitted and received differentially (D+ with respect to D-) and they are not compared with the GND for 1s and 0s.
The button line is you have no direct control over USB.
This is my first post. I am trying to make a drum kit using a raspberry pi. The drum triggers are some peizoelectric sensors. I have used pygame inside python to play sounds. When the script detected gpio inputs, it played drum sounds. It was fine for the most part but due to latency issues, I took another approach and decided to use puredata.
I want python to detect gpio inputs and then send signals to puredata, which will play the desired sounds.
My question is, how can I get python to send simple signals to puredata??? I am running both python and pd on the same pi.
Also, what do you think of this approach i.e. using puredata directly from gpio inputs? Can having a microcontroller like arduino to send the signals as midi signals to pd affect anything???
Thank you in advance!
I'm going back about a decade but I used Python to send data from the 3d modelling software Blender to PureData using the socket library.
This article might help a bit more with packaging up and sending across.
If you know what your components within PD are expecting as an input that will help you know how best translate your input triggers into packages to ship over socket to PD.
I'm running a Python script on a Raspberry Pi Zero that records audio, does some processing and TF analysis. Right now the Raspberry is always connected to the power supply, but I want to run while on the move by attaching a battery. However, most of the models of battery and power management boards I have found can't report to the Rasp Pi when the battery is low so you can do a "soft" power down.
What is the risk of the Raspberry Pi Z shutting down suddenly when the battery runs out of juice?
Is there any option that the power management board has a I2C/GPIO comm with the CPU so you can read the battery level?
Four years ago I worked on a project that used a Raspberry (it wasn't the Pi Z, but I think the problem is similar). We also came across into this problem. So, sharing my experiences with you according your topics:
our project was using a battery and sometimes it it runs out of juice. At first it seems ok. But later we got a problem on the SD card that we needed to replace it. So, based on my experience, I don't recommend you to do that
In the project we also had a Arduino communicating with the raspberry. So we just use a tensorflow divisor to mesuare the voltage on Arduino analog in, and send it to raspberry using the USB port. Of course, it is not your case, we just use it because we already had this hardware on the project. For your case, I think a safe option is buy a shield that do that for you. I don't know your budget, but it's a good idea.
I'm making a Skeeball program and boards that both work off of a raspberry pi and GPIO sensors with a tkinter gui. The first table and program is working great and now I was thinking about the possibility of adding a second table with multiplayer games.
Each pi would have to talk to each other, preferably over a LAN network instead of using I2C or serial pins. Basically I just need something mostly to pass variables from one pi to another.
My first thought was to use pickle to save to a shared network folder since I'm already using pickle to save my highscores. I just have no clue how to set up a shared folder over raspbian and I'm guessing that probably a pretty bad approach to solving the problem.
I'm also really new when it comes to python and raspbian so sorry if this problem is something super easy all I could find online was how to have a pi talk with a windows pc or an arduino.
Thanks for any help you can give me!
This may seem like a bit of an odd question, but I was wondering if it is possible to associate two drivers with a peripheral device?
The reason I ask is that I am building an input device for Maya using an Arduino microcontroller. The Arduino already has its own device driver, but I was thinking of developing a UMDF driver to take the data that comes in from Arduino over the serial port and pre-process it ready to go into Maya.
Right now, I have two Python programs running - a 32-bit Python program running outside of Maya which listens to the serial port and converts the data to a form which a second 64-bit program inside the 64-bit version of Maya can understand and use in the Maya scene. This works fine, but it is a bit annoying having to start that external server program every time I want to use this device in Maya. If I can have a UMDF driver ready to jump into action when the appropriate type of data comes in off the Arduino then this would help immensely. Will this approach work?
It's more a comment/suggestion than an answer, but maybe it would be worth to invest some time and check if the filter driver would do the job for you. In WDM you can put it above the kernel device driver on the driver stack for that device, and use it to pre-process your device data. I think it is also possible in UMDF.
See Creating a New Filter Driver (MSDN).
You may always try to use Teensy/Teensyduino instead of Arduino to implement a virtual keyboard, mouse, joystick or other HID device. This does not require Windows drivers, and accessing the keyboard or joystick from Maya may be easier that the serial port.